Skip to content

Commit

Permalink
Merge pull request #935 from jenkinsci/fix-npe
Browse files Browse the repository at this point in the history
Fix NullPointerException when pipeline execution is interrupted and resurrected
  • Loading branch information
cyrille-leclerc authored Sep 5, 2024
2 parents 5a30048 + 864b4f0 commit 77b35ef
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
public abstract class AbstractMonitoringAction implements Action, OtelMonitoringAction {
private final static Logger LOGGER = Logger.getLogger(AbstractMonitoringAction.class.getName());

@CheckForNull
transient SpanAndScopes spanAndScopes;


final String traceId;
final String spanId;
protected String spanName;
Expand All @@ -50,7 +50,7 @@ public AbstractMonitoringAction(Span span, List<Scope> scopes) {
this.w3cTraceContext = w3cTraceContext;
}

LOGGER.log(Level.FINE, () -> "Span " + getSpanName() + ", thread=" + spanAndScopes.scopeStartThreadName + " opened " + spanAndScopes.scopes.size() + " scopes");
LOGGER.log(Level.FINE, () -> "Span " + getSpanName() + Optional.ofNullable(spanAndScopes).map(sas -> ", thread=" + sas.scopeStartThreadName + " opened " + sas.scopes.size() + " scopes").orElse(", null spanAndScopes") );
}

public String getSpanName() {
Expand All @@ -65,7 +65,7 @@ public Map<String, String> getW3cTraceContext() {
@Override
@CheckForNull
public Span getSpan() {
return spanAndScopes.span;
return spanAndScopes == null ? null : spanAndScopes.span;
}

public String getTraceId() {
Expand Down

0 comments on commit 77b35ef

Please sign in to comment.