Skip to content

Commit

Permalink
Merge pull request #1636 from newrelic/servlet-init-null-check
Browse files Browse the repository at this point in the history
Null checks on ServletContext in servlet instrumentation modules.
  • Loading branch information
jtduffy authored Dec 6, 2023
2 parents a4feb9d + 07d77c7 commit 9f144fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public abstract class Servlet_Instrumentation {

@Trace(dispatcher = true)
public void init(ServletConfig config) {
AgentBridge.privateApi.setServerInfo(config.getServletContext().getServerInfo());
ServletContext ctx = config.getServletContext();
if (ctx != null && ctx.getServerInfo() != null) {
AgentBridge.privateApi.setServerInfo(ctx.getServerInfo());
}

Weaver.callOriginal();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public abstract class Servlet_Instrumentation {

@Trace(dispatcher = true)
public void init(ServletConfig config) {
AgentBridge.privateApi.setServerInfo(config.getServletContext().getServerInfo());
ServletContext ctx = config.getServletContext();
if (ctx != null && ctx.getServerInfo() != null) {
AgentBridge.privateApi.setServerInfo(ctx.getServerInfo());
}

Weaver.callOriginal();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public abstract class Servlet_Instrumentation {

@Trace(dispatcher = true)
public void init(ServletConfig config) {
AgentBridge.privateApi.setServerInfo(config.getServletContext().getServerInfo());
ServletContext ctx = config.getServletContext();
if (ctx != null && ctx.getServerInfo() != null) {
AgentBridge.privateApi.setServerInfo(ctx.getServerInfo());
}

Weaver.callOriginal();
}
Expand Down

0 comments on commit 9f144fd

Please sign in to comment.