diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactory.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactory.java index 62cad85070d..1dd6eadc7fd 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactory.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactory.java @@ -27,8 +27,8 @@ import javax.websocket.MessageHandler; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; import org.eclipse.jetty.websocket.jsr356.metadata.MessageHandlerMetadata; -import org.eclipse.jetty.websocket.jsr356.utils.ReflectUtils; /** * Factory for {@link MessageHandlerMetadata} diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointScanner.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointScanner.java index 50572389be5..70075e47b7b 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointScanner.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointScanner.java @@ -33,7 +33,7 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.common.events.annotated.AbstractMethodAnnotationScanner; import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException; -import org.eclipse.jetty.websocket.jsr356.utils.ReflectUtils; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; public class AnnotatedEndpointScanner extends AbstractMethodAnnotationScanner> { diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageCallable.java index d2998bcc7d2..3b2d6fd1cb5 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageCallable.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageCallable.java @@ -24,10 +24,10 @@ import javax.websocket.Decoder; import javax.websocket.Encoder; import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; import org.eclipse.jetty.websocket.jsr356.EncoderFactory; import org.eclipse.jetty.websocket.jsr356.InitException; import org.eclipse.jetty.websocket.jsr356.JsrSession; -import org.eclipse.jetty.websocket.jsr356.utils.ReflectUtils; public class OnMessageCallable extends JsrCallable { diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/Param.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/Param.java index 2744e2654a9..fd916d8a4c4 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/Param.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/Param.java @@ -18,7 +18,7 @@ package org.eclipse.jetty.websocket.jsr356.annotations; -import org.eclipse.jetty.websocket.jsr356.utils.ReflectUtils; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; public class Param { diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/DecoderMetadataSet.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/DecoderMetadataSet.java index 2397b16927a..0307b3caf86 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/DecoderMetadataSet.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/DecoderMetadataSet.java @@ -25,8 +25,8 @@ import javax.websocket.Decoder; import org.eclipse.jetty.websocket.api.InvalidWebSocketException; import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; import org.eclipse.jetty.websocket.jsr356.MessageType; -import org.eclipse.jetty.websocket.jsr356.utils.ReflectUtils; public class DecoderMetadataSet extends CoderMetadataSet { diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/EncoderMetadataSet.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/EncoderMetadataSet.java index a95adcac8c5..5f1b279e0b8 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/EncoderMetadataSet.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/EncoderMetadataSet.java @@ -25,8 +25,8 @@ import javax.websocket.Encoder; import org.eclipse.jetty.websocket.api.InvalidWebSocketException; import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; import org.eclipse.jetty.websocket.jsr356.MessageType; -import org.eclipse.jetty.websocket.jsr356.utils.ReflectUtils; public class EncoderMetadataSet extends CoderMetadataSet { diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/utils/ReflectUtilsTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/utils/ReflectUtilsTest.java index 222476e2127..f8e040bbee3 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/utils/ReflectUtilsTest.java +++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/utils/ReflectUtilsTest.java @@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.jsr356.utils; import static org.hamcrest.Matchers.*; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; import org.junit.Assert; import org.junit.Test; diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/utils/TypeTree.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/utils/TypeTree.java index a00216a7a48..648ebd41d09 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/utils/TypeTree.java +++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/utils/TypeTree.java @@ -24,6 +24,8 @@ import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.lang.reflect.WildcardType; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; + public class TypeTree { public static void dumpTree(String indent, Type type) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java index 503f909bc52..1b404511467 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java @@ -25,6 +25,7 @@ import java.util.Objects; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.api.WebSocketException; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; /** * A Callable Method @@ -71,8 +72,31 @@ public class CallableMethod } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - String err = String.format("Cannot call method %s on %s with args: %s",method,pojo,args); - throw new WebSocketException(err,e); + StringBuilder err = new StringBuilder(); + err.append("Cannot call method "); + err.append(ReflectUtils.toString(pojo,method)); + err.append(" with args: ["); + + boolean delim = false; + for (Object arg : args) + { + if (delim) + { + err.append(", "); + } + if (arg == null) + { + err.append(""); + } + else + { + err.append(arg.getClass().getName()); + } + delim = true; + } + err.append("]"); + + throw new WebSocketException(err.toString(),e); } } diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/utils/ReflectUtils.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/ReflectUtils.java similarity index 99% rename from jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/utils/ReflectUtils.java rename to jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/ReflectUtils.java index 3b14860f400..eb6e3c52b52 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/utils/ReflectUtils.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/ReflectUtils.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.jsr356.utils; +package org.eclipse.jetty.websocket.common.util; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -344,8 +344,7 @@ public class ReflectUtils public static String toString(Class pojo, Method method) { StringBuilder str = new StringBuilder(); - str.append(pojo.getName()); - str.append(" "); + // method modifiers int mod = method.getModifiers() & Modifier.methodModifiers(); if (mod != 0) @@ -357,6 +356,10 @@ public class ReflectUtils Type retType = method.getGenericReturnType(); appendTypeName(str,retType,false).append(' '); + // class name + str.append(pojo.getName()); + str.append("#"); + // method name str.append(method.getName());