Fix websocket compatibility with Tyrus 1.9 - 1.12

As of Tyrus 1.9, `TyrusEndpointWrapper`'s constructor has a new Boolean
argument (which is mandatory).

This commit reflectively chooses the right constructor method for Tyrus
1.9+ versions.

Issue: SPR-13566
master
Brian Clozel 9 years ago
parent 59637ee708
commit b7e75c5db4
  1. 6
      spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java

@ -216,9 +216,15 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
Object sessionListener = accessor.getPropertyValue("sessionListener"); Object sessionListener = accessor.getPropertyValue("sessionListener");
Object clusterContext = accessor.getPropertyValue("clusterContext"); Object clusterContext = accessor.getPropertyValue("clusterContext");
try { try {
if (constructor.getParameterCount() == 9) {
return constructor.newInstance(registration.getEndpoint(), registration, provider, container, return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
"/", registration.getConfigurator(), sessionListener, clusterContext, null); "/", registration.getConfigurator(), sessionListener, clusterContext, null);
} }
else {
return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
"/", registration.getConfigurator(), sessionListener, clusterContext, null, Boolean.TRUE);
}
}
catch (Exception ex) { catch (Exception ex) {
throw new HandshakeFailureException("Failed to register " + registration, ex); throw new HandshakeFailureException("Failed to register " + registration, ex);
} }

Loading…
Cancel
Save