Skip to content

4.0.0 JAX-RS ExceptionMapper disrupts metrics, health endpoints #7959

@tjquinno

Description

@tjquinno

Environment Details

  • Helidon Version: 4.0.0
  • Helidon SE or Helidon MP MP
  • JDK version:
  • OS:
  • Docker version (if applicable):

Problem Description

Adding a general, catch-all JAX-RS exception mapper to an app disrupts the metrics and health endpoints (and perhaps other observers' endpoints as well).

As coded in the repo, the MP QuickStart app correctly responds to the /health and /metrics endpoints.

If you add an exception mapper to the app, then it is invoked when the /health and /metrics endpoints are accessed.

Steps to reproduce

  1. cd examples/quickstarts/helidon-quickstart-mp
    mvn package

    The preceding commands work, including running unit tests which ping the health and metrics endpoints.

  2. Add the following class to the MP QuickStart app:

    package io.helidon.examples.quickstart.mp;
    
    import jakarta.ws.rs.core.Response;
    import jakarta.ws.rs.ext.ExceptionMapper;
    import jakarta.ws.rs.ext.Provider;
    
    @Provider
    public class GeneralExceptionMapper implements ExceptionMapper<Exception>  {
        @Override
        public Response toResponse(Exception e) {
            return Response.status(500).entity(e.getMessage()).build();
        }
    }
  3. Now mvn package fails during the /health or /metrics endpoint tests because the exception mapper returns 500 responses.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions