Skip to content

Commit 54bb06c

Browse files
committed
[UNDERTOW-2370] Guard against non-servlet ctx request with ServletNameAttribute in access log
1 parent 895346a commit 54bb06c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

servlet/src/main/java/io/undertow/servlet/attribute/ServletNameAttribute.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class ServletNameAttribute implements ExchangeAttribute {
3535

3636
public static final ExchangeAttribute INSTANCE = new ServletNameAttribute();
3737
public static final String NAME = "Servlet Name";
38+
public static final String UNDEFINED = "No-Servlet";
3839

3940
private ServletNameAttribute() {
4041

@@ -43,7 +44,11 @@ private ServletNameAttribute() {
4344
@Override
4445
public String readAttribute(final HttpServerExchange exchange) {
4546
ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
46-
return src.getCurrentServlet().getManagedServlet().getServletInfo().getName();
47+
if (src != null) {
48+
return src.getCurrentServlet().getManagedServlet().getServletInfo().getName();
49+
} else {
50+
return UNDEFINED;
51+
}
4752
}
4853

4954
@Override

0 commit comments

Comments
 (0)