[ 
https://issues.apache.org/jira/browse/HADOOP-18815?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ConfX updated HADOOP-18815:
---------------------------
    Description: 
h2. What happened?

Attempt to start an {{HttpServer2}} failed due to an NPE thrown in 
{{{}MetricsSystemImpl{}}}.
h2. Where's the bug?

In line 1278 of {{{}HttpServer2{}}}, if the support for prometheus is enabled 
the server registers a prometheus sink:
{noformat}
        if (prometheusSupport) {
          DefaultMetricsSystem.instance()
              .register("prometheus", "Hadoop metrics prometheus exporter",
                  prometheusMetricsSink);
        }{noformat}
However, a problem is that if the MetricsSystemImpl returned by the 
DefaultMetricsSystem.instance has not been start nor init, the config of the 
metric system would be set to null, thus failing the nullity check at the start 
of MetricsSystemImpl.registerSink. A better way of handling this would be to 
check in advance if the metric system has been initialized and initialize it if 
it has not been initialized.
h2. How to reproduce?

(1) set hadoop.prometheus.endpoint.enabled to true

(2) run org.apache.hadoop.http.TestHttpServer#testHttpResonseContainsDeny
h2. Stacktrace
{noformat}
java.io.IOException: Problem starting http server
        ...
Caused by: java.lang.NullPointerException: config
    at 
org.apache.hadoop.thirdparty.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:899)
    at 
org.apache.hadoop.metrics2.impl.MetricsSystemImpl.registerSink(MetricsSystemImpl.java:298)
    at 
org.apache.hadoop.metrics2.impl.MetricsSystemImpl.register(MetricsSystemImpl.java:277)
    at org.apache.hadoop.http.HttpServer2.start(HttpServer2.java:1279)
    ... 34 more{noformat}
For an easy reproduction, run the reproduce.sh in the attachment.

We are happy to provide a patch if this issue is confirmed.

  was:
h2. What happened?

Attempt to start an {{HttpServer2}} failed due to an NPE thrown in 
{{{}MetricsSystemImpl{}}}.
h2. Where's the bug?

In line 1278 of {{{}HttpServer2{}}}, if the support for prometheus is enabled 
the server registers a prometheus sink:
{noformat}
        if (prometheusSupport) {
          DefaultMetricsSystem.instance()
              .register("prometheus", "Hadoop metrics prometheus exporter",
                  prometheusMetricsSink);
        }{noformat}
However, a problem is that if the MetricsSystemImpl returned by the 
DefaultMetricsSystem.instance has not been start nor init, the config of the 
metric system would be set to null, thus failing the nullity check at the start 
of MetricsSystemImpl.registerSink. A better way of handling this would be to 
check in advance if the metric system has been initialized and initialize it if 
it has not been initialized.
h2. How to reproduce?

(1) set hadoop.prometheus.endpoint.enabled to true

(2) run 
org.apache.hadoop.http.TestHttpServer#testHttpResonseContainsDenyStacktrace
{noformat}
java.io.IOException: Problem starting http server
        ...
Caused by: java.lang.NullPointerException: config
    at 
org.apache.hadoop.thirdparty.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:899)
    at 
org.apache.hadoop.metrics2.impl.MetricsSystemImpl.registerSink(MetricsSystemImpl.java:298)
    at 
org.apache.hadoop.metrics2.impl.MetricsSystemImpl.register(MetricsSystemImpl.java:277)
    at org.apache.hadoop.http.HttpServer2.start(HttpServer2.java:1279)
    ... 34 more{noformat}
For an easy reproduction, run the reproduce.sh in the attachment.

We are happy to provide a patch if this issue is confirmed.


> unnecessary NullPointerException encountered when starting HttpServer2 with 
> prometheus enabled 
> -----------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-18815
>                 URL: https://issues.apache.org/jira/browse/HADOOP-18815
>             Project: Hadoop Common
>          Issue Type: Bug
>    Affects Versions: 3.3.3
>            Reporter: ConfX
>            Priority: Critical
>         Attachments: reproduce.sh
>
>
> h2. What happened?
> Attempt to start an {{HttpServer2}} failed due to an NPE thrown in 
> {{{}MetricsSystemImpl{}}}.
> h2. Where's the bug?
> In line 1278 of {{{}HttpServer2{}}}, if the support for prometheus is enabled 
> the server registers a prometheus sink:
> {noformat}
>         if (prometheusSupport) {
>           DefaultMetricsSystem.instance()
>               .register("prometheus", "Hadoop metrics prometheus exporter",
>                   prometheusMetricsSink);
>         }{noformat}
> However, a problem is that if the MetricsSystemImpl returned by the 
> DefaultMetricsSystem.instance has not been start nor init, the config of the 
> metric system would be set to null, thus failing the nullity check at the 
> start of MetricsSystemImpl.registerSink. A better way of handling this would 
> be to check in advance if the metric system has been initialized and 
> initialize it if it has not been initialized.
> h2. How to reproduce?
> (1) set hadoop.prometheus.endpoint.enabled to true
> (2) run org.apache.hadoop.http.TestHttpServer#testHttpResonseContainsDeny
> h2. Stacktrace
> {noformat}
> java.io.IOException: Problem starting http server
>         ...
> Caused by: java.lang.NullPointerException: config
>     at 
> org.apache.hadoop.thirdparty.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:899)
>     at 
> org.apache.hadoop.metrics2.impl.MetricsSystemImpl.registerSink(MetricsSystemImpl.java:298)
>     at 
> org.apache.hadoop.metrics2.impl.MetricsSystemImpl.register(MetricsSystemImpl.java:277)
>     at org.apache.hadoop.http.HttpServer2.start(HttpServer2.java:1279)
>     ... 34 more{noformat}
> For an easy reproduction, run the reproduce.sh in the attachment.
> We are happy to provide a patch if this issue is confirmed.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to