Skip to content

Commit

Permalink
try to instantiate the handler before upgrading
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Jan 29, 2021
1 parent dbc40b6 commit d44a532
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
Expand Up @@ -2387,11 +2387,6 @@ public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IO
if (response.isCommitted())
throw new IllegalStateException("Cannot upgrade committed response");

_channel.servletUpgrade(); // tell the channel that it is now handling an upgraded servlet
HttpConnection httpConnection = (HttpConnection)_channel.getConnection();
httpConnection.getParser().servletUpgrade(); // tell the parser it's now parsing content
AsyncContext asyncContext = forceStartAsync(); // force the servlet in async mode

T handler;
try
{
Expand All @@ -2402,6 +2397,11 @@ public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IO
throw new ServletException("Unable to instantiate handler class", e);
}

_channel.servletUpgrade(); // tell the channel that it is now handling an upgraded servlet
HttpConnection httpConnection = (HttpConnection)_channel.getConnection();
httpConnection.getParser().servletUpgrade(); // tell the parser it's now parsing content
AsyncContext asyncContext = forceStartAsync(); // force the servlet in async mode

ServletOutputStream outputStream = response.getOutputStream();
ServletInputStream inputStream = getInputStream();
handler.init(new WebConnection()
Expand Down

0 comments on commit d44a532

Please sign in to comment.