Upgrade Jetty and harden WebSocket upgrade lifecycle

This commit is contained in:
Amer Agovic
2026-05-01 13:47:23 -05:00
parent c86fc03c2e
commit bfb6ff82bf
4 changed files with 18 additions and 10 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ tasks.withType(JavaCompile) {
}
dependencies {
def jettyVersion="12.0.15"
def jettyVersion="12.0.32"
def bstoreVersion="1.0.0-SNAPSHOT"
implementation "org.eclipse.jetty:jetty-server:${jettyVersion}"
implementation "org.eclipse.jetty.http2:jetty-http2-server:${jettyVersion}"
@@ -45,6 +45,7 @@ public abstract class Response {
protected final ArrayList<HTTP.Header> headers=new ArrayList<>();
protected final ArrayList<HTTP.Cookie> cookies=new ArrayList<>();
protected CompletableFuture<Object> promise;
protected boolean upgradedToWebSocket;
protected Response(Request request) {
this.request = request;
@@ -158,6 +159,10 @@ public abstract class Response {
return promise!=null;
}
public boolean isUpgradedToWebSocket() {
return upgradedToWebSocket;
}
/**
* Initiate an async promise chain using supplyAsync.
* Gets executor from request's CallSession.
@@ -236,7 +236,9 @@ public class JettyApp extends App implements Servlet {
// Only end session if not async (async will end session when completing)
if(resp.isPromised()==false){
ss.end();
resp.complete();
if(!resp.isUpgradedToWebSocket()){
resp.complete();
}
}else{
resp.promiseLast((result, error) -> {
if(result instanceof Exception){
@@ -186,6 +186,7 @@ public class ServletResponse extends Response {
*/
@Override
public com.reliancy.jabba.WebSocketSession upgradeToWebSocket(String route, com.reliancy.jabba.Session appSession) throws IOException {
upgradedToWebSocket=true;
return ServletWebSocketSession.create(this,route, appSession);
}
}