parent
88e9dcef0c
commit
c2d71922d7
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.web.socket.server.jetty;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -28,6 +29,7 @@ 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;
|
||||
|
||||
|
|
@ -38,7 +40,9 @@ import org.springframework.http.server.ServerHttpResponse;
|
|||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.http.server.ServletServerHttpResponse;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.web.context.ServletContextAware;
|
||||
import org.springframework.web.socket.WebSocketExtension;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
|
|
@ -167,7 +171,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Serv
|
|||
}
|
||||
|
||||
private List<WebSocketExtension> buildWebSocketExtensions() {
|
||||
Set<String> names = this.factory.getExtensionFactory().getExtensionNames();
|
||||
Set<String> names = getExtensionNames();
|
||||
List<WebSocketExtension> result = new ArrayList<>(names.size());
|
||||
for (String name : names) {
|
||||
result.add(new WebSocketExtension(name));
|
||||
|
|
@ -175,6 +179,18 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Serv
|
|||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
private Set<String> getExtensionNames() {
|
||||
try {
|
||||
return this.factory.getExtensionFactory().getExtensionNames();
|
||||
}
|
||||
catch (IncompatibleClassChangeError ex) {
|
||||
// 9.4.20.v20190813: ExtensionFactory (abstract class -> interface)
|
||||
Method method = ClassUtils.getMethod(ExtensionFactory.class, "getExtensionNames");
|
||||
return (Set<String>) ReflectionUtils.invokeMethod(method, this.factory.getExtensionFactory());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgrade(ServerHttpRequest request, ServerHttpResponse response,
|
||||
String selectedProtocol, List<WebSocketExtension> selectedExtensions, Principal user,
|
||||
|
|
|
|||
Loading…
Reference in New Issue