Skip to content

Commit

Permalink
Merge pull request #884 from jenkinsci/prevent-npe
Browse files Browse the repository at this point in the history
Prevent NullPointerException
  • Loading branch information
kuisathaverat authored Jul 3, 2024
2 parents d26eebc + a0042dc commit bc48573
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package io.jenkins.plugins.opentelemetry.opentelemetry;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.NonNull;
import io.jenkins.plugins.opentelemetry.OtelUtils;
import io.jenkins.plugins.opentelemetry.opentelemetry.autoconfigure.ConfigPropertiesUtils;
Expand Down Expand Up @@ -51,8 +50,8 @@
public class ReconfigurableOpenTelemetry implements OpenTelemetry, Closeable {

protected final Logger logger = Logger.getLogger(getClass().getName());
Resource resource;
ConfigProperties config;
Resource resource = Resource.empty();
ConfigProperties config = ConfigPropertiesUtils.emptyConfig();
OpenTelemetry openTelemetryImpl = OpenTelemetry.noop();
final ReconfigurableMeterProvider meterProviderImpl = new ReconfigurableMeterProvider();
final ReconfigurableTracerProvider traceProviderImpl = new ReconfigurableTracerProvider();
Expand Down Expand Up @@ -118,7 +117,7 @@ public void configure(@NonNull Map<String, String> openTelemetryProperties, Reso

} else { // NO-OP

this.resource = Resource.getDefault();
this.resource = Resource.empty();
this.config = ConfigPropertiesUtils.emptyConfig();
setOpenTelemetryImpl(OpenTelemetry.noop());

Expand Down Expand Up @@ -197,12 +196,12 @@ protected OpenTelemetry getOpenTelemetryDelegate() {

@NonNull
public Resource getResource() {
return Preconditions.checkNotNull(resource);
return resource;
}

@NonNull
public ConfigProperties getConfig() {
return Preconditions.checkNotNull(config);
return config;
}

@Override
Expand Down

0 comments on commit bc48573

Please sign in to comment.