Skip to content

Commit

Permalink
guard lettuce npe (#1204)
Browse files Browse the repository at this point in the history
merging with tomee.py test fail. False positive. Test is faulty and is being disabled until faultiness resolved. All other tests pass here.
  • Loading branch information
tbradellis authored Apr 14, 2023
1 parent f34b0f5 commit f559a15
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.newrelic.api.agent.Segment;
import com.newrelic.api.agent.Token;

import java.util.logging.Level;

public class NRHolder {
private String segmentName = null;
private Segment segment = null;
Expand Down Expand Up @@ -45,7 +47,7 @@ public void end() {
token.linkAndExpire();
token = null;
}
if (segment != null) {
if (segment != null && params != null) {
String operation = params.getOperation();
if (operation.equalsIgnoreCase("expire")) {
segment.ignore();
Expand All @@ -56,9 +58,13 @@ public void end() {
params = null;
segment = null;
} else {
String operation = params.getOperation();
if (!operation.equalsIgnoreCase("expire")) {
NewRelic.getAgent().getTracedMethod().reportAsExternal(params);
if (params != null) {
String operation = params.getOperation();
if (!operation.equalsIgnoreCase("expire")) {
NewRelic.getAgent().getTracedMethod().reportAsExternal(params);
}
} else {
NewRelic.getAgent().getLogger().log(Level.WARNING, "DatastoreParameters was null for Lettuce instrumentation. Unable to report as external.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.newrelic.api.agent.Segment;
import com.newrelic.api.agent.Token;

import java.util.logging.Level;

public class NRHolder {
private String segmentName = null;
private Segment segment = null;
Expand Down Expand Up @@ -45,7 +47,7 @@ public void end() {
token.linkAndExpire();
token = null;
}
if (segment != null) {
if (segment != null && params != null) {
String operation = params.getOperation();
if (operation.equalsIgnoreCase("expire")) {
segment.ignore();
Expand All @@ -56,9 +58,13 @@ public void end() {
params = null;
segment = null;
} else {
String operation = params.getOperation();
if (!operation.equalsIgnoreCase("expire")) {
NewRelic.getAgent().getTracedMethod().reportAsExternal(params);
if (params != null) {
String operation = params.getOperation();
if (!operation.equalsIgnoreCase("expire")) {
NewRelic.getAgent().getTracedMethod().reportAsExternal(params);
}
} else {
NewRelic.getAgent().getLogger().log(Level.WARNING, "DatastoreParameters was null for Lettuce instrumentation. Unable to report as external");
}
}
}
Expand Down

0 comments on commit f559a15

Please sign in to comment.