Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jakarta HealthCheckServlet object mapper and status indicator #3924

Merged
merged 1 commit into from Jan 24, 2024

Conversation

joschi
Copy link
Member

@joschi joschi commented Jan 24, 2024

  • Allow overriding the ObjectMapper instance used in HealthCheckServlet with the servlet attribute io.dropwizard.metrics.servlets.HealthCheckServlet.mapper
  • Allow setting the HTTP status code used to indicate health to 200 (OK) with the servlet attribute io.dropwizard.metrics.servlets.HealthCheckServlet.httpStatusIndicator, or with the HTTP query parameter httpStatusIndicator per request

Refs #1821
Refs #1871
Fixes #3918

@joschi joschi added this to the 4.2.25 milestone Jan 24, 2024
@joschi joschi self-assigned this Jan 24, 2024
@joschi joschi requested review from a team as code owners January 24, 2024 21:23
- Allow overriding the `ObjectMapper` instance used in `HealthCheckServlet` with the servlet attribute `io.dropwizard.metrics.servlets.HealthCheckServlet.mapper`
- Allow setting the HTTP status code used to indicate health to 200 (OK) with the servlet attribute `io.dropwizard.metrics.servlets.HealthCheckServlet.httpStatusIndicator`, or with the HTTP query parameter `httpStatusIndicator` per request

Refs #1821
Refs #1871
@joschi joschi enabled auto-merge (squash) January 24, 2024 21:28
Copy link

github-actions bot commented Jan 24, 2024

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@joschi joschi merged commit b116e89 into release/4.2.x Jan 24, 2024
7 checks passed
@joschi joschi deleted the jakarta-servlets-pr-1871 branch January 24, 2024 21:52
Copy link

sonarcloud bot commented Jan 24, 2024

Quality Gate Failed Quality Gate failed

Failed conditions

78.6% Coverage on New Code (required ≥ 80%)
31.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

final ServletConfig servletConfig = mock(ServletConfig.class);
when(servletConfig.getServletContext()).thenReturn(servletContext);
when(servletContext.getAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY)).thenReturn(registry);
when(servletContext.getAttribute(HealthCheckServlet.HEALTH_CHECK_MAPPER)).thenReturn("IRELLEVANT_STRING");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irrelevant typo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But at least it's a consistent type. 😂

❯ rg IRELLEVANT_STRING
metrics-servlets/src/test/java/com/codahale/metrics/servlets/MetricsServletTest.java
258:                .thenReturn("IRELLEVANT_STRING");

metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java
217:                .thenReturn("IRELLEVANT_STRING");
229:        when(servletContext.getAttribute(HealthCheckServlet.HEALTH_CHECK_MAPPER)).thenReturn("IRELLEVANT_STRING");

metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/MetricsServletTest.java
258:                .thenReturn("IRELLEVANT_STRING");

metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java
215:                .thenReturn("IRELLEVANT_STRING");
227:        when(servletContext.getAttribute(HealthCheckServlet.HEALTH_CHECK_MAPPER)).thenReturn("IRELLEVANT_STRING");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overriding HTTP status code of healthcheck servlet is not possible anymore
2 participants