Skip to content

Commit f87d897

Browse files
committed
Jetty HTTP method NPE:
``` Caused by: java.lang.NullPointerException at io.jooby.internal.jetty.JettyContext.getMethod(JettyContext.java:139) at io.jooby.ErrorHandler.errorMessage(ErrorHandler.java:122) at io.jooby.DefaultContext.sendError(DefaultContext.java:530) at io.jooby.DefaultContext.sendError(DefaultContext.java:515) at io.jooby.CoroutineRouter$route$1$$special$$inlined$CoroutineExceptionHandler$1.handleException(CoroutineExceptionHandler.kt:82) at kotlinx.coroutines.CoroutineExceptionHandlerKt.handleCoroutineException(CoroutineExceptionHandler.kt:25) ... 11 more ```
1 parent 601fe28 commit f87d897

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

TODO

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@ java.io.IOException: Close org.eclipse.jetty.server.HttpConnection$SendCallback@
1515
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
1616
at java.lang.Thread.run(Thread.java:748)
1717
```
18+
19+
FeaturedKotlinTest.coroutineNoSuspend:
20+
async:
21+
22+
```
23+
Suppressed: java.io.IOException: Close org.eclipse.jetty.server.HttpConnection$SendCallback@4b406dd7[PROCESSING][i=HTTP/1.1{s=200,h=3,cl=-1},cb=org.eclipse.jetty.server.HttpChannel$SendCallback@e42eadb] in state PROCESSING
24+
at org.eclipse.jetty.util.IteratingCallback.close(IteratingCallback.java:428)
25+
at org.eclipse.jetty.server.HttpConnection.onClose(HttpConnection.java:510)
26+
at org.eclipse.jetty.io.SelectorManager.connectionClosed(SelectorManager.java:345)
27+
at org.eclipse.jetty.io.ManagedSelector$DestroyEndPoint.run(ManagedSelector.java:967)
28+
... 3 more
29+
```

modules/jooby-jetty/src/main/java/io/jooby/internal/jetty/JettyContext.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public class JettyContext implements DefaultContext {
9191
private HashMap<String, String> responseCookies;
9292
private boolean responseStarted;
9393
private Boolean resetHeadersOnError;
94+
private String method;
95+
private String pathString;
9496

9597
public JettyContext(Request request, Router router, int bufferSize, long maxRequestSize) {
9698
this.request = request;
@@ -136,7 +138,10 @@ public JettyContext(Request request, Router router, int bufferSize, long maxRequ
136138
}
137139

138140
@Nonnull @Override public String getMethod() {
139-
return request.getMethod().toUpperCase();
141+
if (method == null) {
142+
method = request.getMethod().toUpperCase();
143+
}
144+
return method;
140145
}
141146

142147
@Nonnull @Override public Route getRoute() {
@@ -149,7 +154,10 @@ public JettyContext(Request request, Router router, int bufferSize, long maxRequ
149154
}
150155

151156
@Nonnull @Override public String pathString() {
152-
return request.getRequestURI();
157+
if (pathString == null) {
158+
pathString = request.getRequestURI();
159+
}
160+
return pathString;
153161
}
154162

155163
@Nonnull @Override public Map<String, String> pathMap() {

0 commit comments

Comments
 (0)