Upgrade Jetty to 9.4.21

Make use of the new getAvailableExtensionNames() method.

Closes gh-23799
This commit is contained in:
Rossen Stoyanchev 2019-10-24 20:46:59 +01:00
parent 9689a59ab1
commit 7f8966774e
2 changed files with 7 additions and 5 deletions

View File

@ -33,7 +33,7 @@ ext {
groovyVersion = "2.5.8"
hsqldbVersion = "2.4.1"
jackson2Version = "2.9.9"
jettyVersion = "9.4.20.v20190813"
jettyVersion = "9.4.21.v20190926"
junit5Version = "5.3.2"
kotlinVersion = "1.2.71"
log4jVersion = "2.11.2"

View File

@ -30,7 +30,6 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
import org.eclipse.jetty.websocket.server.HandshakeRFC6455;
import org.eclipse.jetty.websocket.server.WebSocketServerFactory;
@ -180,14 +179,17 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Serv
return result;
}
@SuppressWarnings({"unchecked"})
@SuppressWarnings({"unchecked", "deprecation"})
private Set<String> getExtensionNames() {
try {
return this.factory.getExtensionFactory().getExtensionNames();
return this.factory.getAvailableExtensionNames();
}
catch (IncompatibleClassChangeError ex) {
// Fallback for versions prior to 9.4.21:
// 9.4.20.v20190813: ExtensionFactory (abstract class -> interface)
Method method = ClassUtils.getMethod(ExtensionFactory.class, "getExtensionNames");
// 9.4.21.v20190926: ExtensionFactory (interface -> abstract class) + deprecated
Class<?> clazz = org.eclipse.jetty.websocket.api.extensions.ExtensionFactory.class;
Method method = ClassUtils.getMethod(clazz, "getExtensionNames");
return (Set<String>) ReflectionUtils.invokeMethod(method, this.factory.getExtensionFactory());
}
}