Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#NEWRELIC-6527 guard lettuce npe #1204

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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