|
60 | 60 | * <p>Works with Tyrus 1.3.5 (WebLogic 12.1.3) and Tyrus 1.7+ (GlassFish 4.1.x).
|
61 | 61 | *
|
62 | 62 | * @author Rossen Stoyanchev
|
| 63 | + * @author Brian Clozel |
63 | 64 | * @since 4.1
|
64 | 65 | * @see <a href="https://tyrus.java.net/">Project Tyrus</a>
|
65 | 66 | */
|
@@ -181,13 +182,20 @@ protected static class Tyrus17EndpointHelper implements TyrusEndpointHelper {
|
181 | 182 |
|
182 | 183 | private static final Constructor<?> constructor;
|
183 | 184 |
|
| 185 | + private static boolean constructorWithBooleanArgument; |
| 186 | + |
184 | 187 | private static final Method registerMethod;
|
185 | 188 |
|
186 | 189 | private static final Method unRegisterMethod;
|
187 | 190 |
|
188 | 191 | static {
|
189 | 192 | try {
|
190 | 193 | 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 | + } |
191 | 199 | registerMethod = TyrusWebSocketEngine.class.getDeclaredMethod("register", TyrusEndpointWrapper.class);
|
192 | 200 | unRegisterMethod = TyrusWebSocketEngine.class.getDeclaredMethod("unregister", TyrusEndpointWrapper.class);
|
193 | 201 | ReflectionUtils.makeAccessible(registerMethod);
|
@@ -216,13 +224,13 @@ public Object createdEndpoint(ServerEndpointRegistration registration, Component
|
216 | 224 | Object sessionListener = accessor.getPropertyValue("sessionListener");
|
217 | 225 | Object clusterContext = accessor.getPropertyValue("clusterContext");
|
218 | 226 | try {
|
219 |
| - if (constructor.getParameterTypes().length == 9) { |
| 227 | + if (constructorWithBooleanArgument) { |
220 | 228 | return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
|
221 |
| - "/", registration.getConfigurator(), sessionListener, clusterContext, null); |
| 229 | + "/", registration.getConfigurator(), sessionListener, clusterContext, null, Boolean.TRUE); |
222 | 230 | }
|
223 | 231 | else {
|
224 | 232 | return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
|
225 |
| - "/", registration.getConfigurator(), sessionListener, clusterContext, null, Boolean.TRUE); |
| 233 | + "/", registration.getConfigurator(), sessionListener, clusterContext, null); |
226 | 234 | }
|
227 | 235 | }
|
228 | 236 | catch (Exception ex) {
|
|
0 commit comments