Skip to content

Commit c33c26a

Browse files
committed
Support for GlassFish 4.1.1 (Tyrus 1.9 - 1.12)
Issue: SPR-13566
1 parent 0086dd8 commit c33c26a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
* <p>Works with Tyrus 1.3.5 (WebLogic 12.1.3) and Tyrus 1.7+ (GlassFish 4.1.x).
6161
*
6262
* @author Rossen Stoyanchev
63+
* @author Brian Clozel
6364
* @since 4.1
6465
* @see <a href="https://tyrus.java.net/">Project Tyrus</a>
6566
*/
@@ -181,13 +182,20 @@ protected static class Tyrus17EndpointHelper implements TyrusEndpointHelper {
181182

182183
private static final Constructor<?> constructor;
183184

185+
private static boolean constructorWithBooleanArgument;
186+
184187
private static final Method registerMethod;
185188

186189
private static final Method unRegisterMethod;
187190

188191
static {
189192
try {
190193
constructor = getEndpointConstructor();
194+
int parameterCount = constructor.getParameterTypes().length;
195+
constructorWithBooleanArgument = (parameterCount == 10);
196+
if (!constructorWithBooleanArgument && parameterCount != 9) {
197+
throw new IllegalStateException("Expected TyrusEndpointWrapper constructor with 9 or 10 arguments");
198+
}
191199
registerMethod = TyrusWebSocketEngine.class.getDeclaredMethod("register", TyrusEndpointWrapper.class);
192200
unRegisterMethod = TyrusWebSocketEngine.class.getDeclaredMethod("unregister", TyrusEndpointWrapper.class);
193201
ReflectionUtils.makeAccessible(registerMethod);
@@ -216,8 +224,14 @@ public Object createdEndpoint(ServerEndpointRegistration registration, Component
216224
Object sessionListener = accessor.getPropertyValue("sessionListener");
217225
Object clusterContext = accessor.getPropertyValue("clusterContext");
218226
try {
219-
return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
220-
"/", registration.getConfigurator(), sessionListener, clusterContext, null);
227+
if (constructorWithBooleanArgument) {
228+
return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
229+
"/", registration.getConfigurator(), sessionListener, clusterContext, null, Boolean.TRUE);
230+
}
231+
else {
232+
return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
233+
"/", registration.getConfigurator(), sessionListener, clusterContext, null);
234+
}
221235
}
222236
catch (Exception ex) {
223237
throw new HandshakeFailureException("Failed to register " + registration, ex);

0 commit comments

Comments
 (0)