Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dj707chen
Copy link
Contributor

@dj707chen dj707chen commented Sep 5, 2024

After consuming the latest SNAPSHOT of http4s-core, this http4s-prometheus-metrics build failed:

org.http4s.metrics.prometheus.PrometheusServerMetricsSuite:
==> X org.http4s.metrics.prometheus.PrometheusServerMetricsSuite.A http routes with a prometheus metrics middleware should register a 2xx response  0.039s java.lang.NullPointerException: null
    at org.http4s.metrics.prometheus.Prometheus.createMetricsCollection(Prometheus.scala:344)
    at org.http4s.metrics.prometheus.Prometheus.buildCustomMetricsOps(Prometheus.scala:131)
    at org.http4s.metrics.prometheus.Prometheus.build(Prometheus.scala:126)
    at org.http4s.metrics.prometheus.Prometheus$.metricsOps(Prometheus.scala:408)
    at org.http4s.metrics.prometheus.PrometheusServerMetricsSuite.$anonfun$buildMeteredRoutes$1(PrometheusServerMetricsSuite.scala:236)

The root cause is that the singleton creation of EmptyCustomLabels is calling the apply(), which just return the singleton instance, thus it is in infinite loop.

SizedSeq0 has the same issue.

This PR fixes these two issues by calling constructor explicitly.

@mergify mergify bot added series/0.23 PRs targeting 0.23.x module:core labels Sep 5, 2024
@samspills samspills added this to the 0.23.28 milestone Sep 5, 2024
@dj707chen dj707chen changed the title Fix EmptyCustomLabels and SizedSeq0 singleton creation Fix EmptyCustomLabels and SizedSeq0 singleton creation issue Sep 5, 2024
Copy link
Member

@danicheg danicheg left a comment

Choose a reason for hiding this comment

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

final abstract really seems abnormal

@samspills samspills merged commit 895f328 into http4s:series/0.23 Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:core series/0.23 PRs targeting 0.23.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants