diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java index 31c9ab39774..3c73808476b 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java @@ -246,7 +246,7 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont // synchronized (endpointClientMetadataCache) // { -// metadata = endpointClientMetadataCache.get(endpoint); +// // // if (metadata != null) // { @@ -282,7 +282,7 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont // endpointClientMetadataCache.put(endpoint,metadata); // return metadata; // } - return metadata; + return null; } public DecoderFactory getDecoderFactory() diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnCloseCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnCloseCallable.java index 9605b489ccd..b996376e425 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnCloseCallable.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnCloseCallable.java @@ -18,14 +18,17 @@ package org.eclipse.jetty.websocket.jsr356.annotations; -import javax.websocket.OnClose; - /** * Callable for {@link javax.websocket.OnClose} annotated methods */ @Deprecated public class OnCloseCallable extends JsrCallable { + @Override + public void setDecodingType(Class decodingType) + { + + } /*private int idxCloseReason = -1; public OnCloseCallable(Class pojo, Method method) diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnErrorCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnErrorCallable.java index b70f03faf01..827b504245e 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnErrorCallable.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnErrorCallable.java @@ -26,6 +26,11 @@ import javax.websocket.OnError; @Deprecated public class OnErrorCallable extends JsrCallable { + @Override + public void setDecodingType(Class decodingType) + { + + } /* private int idxThrowable = -1; public OnErrorCallable(Class pojo, Method method) 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 bacf689d803..378ebe7e2ec 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 @@ -21,6 +21,12 @@ package org.eclipse.jetty.websocket.jsr356.annotations; @Deprecated public class OnMessageCallable extends JsrCallable { + @Override + public void setDecodingType(Class decodingType) + { + + } + /* protected final Class returnType; protected Encoder returnEncoder; protected Class decodingType; diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnOpenCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnOpenCallable.java index 12c7cc04ecd..032accc720f 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnOpenCallable.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnOpenCallable.java @@ -18,14 +18,17 @@ package org.eclipse.jetty.websocket.jsr356.annotations; -import javax.websocket.OnOpen; - /** * Callable for {@link javax.websocket.OnOpen} annotated methods */ @Deprecated public class OnOpenCallable extends JsrCallable { + @Override + public void setDecodingType(Class decodingType) + { + + } /* private int idxEndpointConfig = -1; public OnOpenCallable(Class pojo, Method method) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/function/OnByteArrayFunction.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/function/OnByteArrayFunction.java index 1e8123e1311..e350512dc2d 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/function/OnByteArrayFunction.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/function/OnByteArrayFunction.java @@ -35,10 +35,10 @@ import org.eclipse.jetty.websocket.common.util.ReflectUtils; public class OnByteArrayFunction implements Function { private static final DynamicArgs.Builder ARGBUILDER; - private static final Arg ARG_SESSION = new Arg(1, Session.class); - private static final Arg ARG_BUFFER = new Arg(2, byte[].class).required(); - private static final Arg ARG_OFFSET = new Arg(3, int.class); - private static final Arg ARG_LENGTH = new Arg(4, int.class); + private static final Arg ARG_SESSION = new Arg(Session.class); + private static final Arg ARG_BUFFER = new Arg(byte[].class).required(); + private static final Arg ARG_OFFSET = new Arg(int.class); + private static final Arg ARG_LENGTH = new Arg(int.class); static { diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/reflect/Arg.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/reflect/Arg.java index 6f1d4f3a4d2..4f54a22b39f 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/reflect/Arg.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/reflect/Arg.java @@ -49,7 +49,16 @@ public class Arg this.index = idx; this.type = type; } - + + public Arg(Arg arg) + { + this.method = arg.method; + this.index = arg.index; + this.type = arg.type; + this.tag = arg.tag; + this.required = arg.required; + } + public T getAnnotation(Class annoClass) { if (method == null) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/reflect/UnorderedSignature.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/reflect/UnorderedSignature.java index 4eab7605658..c742357576e 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/reflect/UnorderedSignature.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/reflect/UnorderedSignature.java @@ -31,6 +31,26 @@ import org.eclipse.jetty.websocket.common.util.ReflectUtils; class UnorderedSignature implements Signature, Predicate { + private class SelectedArg extends Arg + { + private boolean selected = false; + + public SelectedArg(Arg arg) + { + super(arg); + } + + public boolean isSelected() + { + return selected; + } + + public void selected() + { + this.selected = true; + } + } + private final static Logger LOG = Log.getLogger(UnorderedSignature.class); private final Arg[] params; @@ -118,6 +138,13 @@ class UnorderedSignature implements Signature, Predicate methodArgs[pi] = argId.apply(methodArgs[pi]); } + // Selected Args + SelectedArg selectedArgs[] = new SelectedArg[callArgs.length]; + for (int ci = 0; ci < selectedArgs.length; ci++) + { + selectedArgs[ci] = new SelectedArg(callArgs[ci]); + } + // Iterate through mappings, looking for a callArg that fits it for (int ai = 0; ai < argMappingLength; ai++) { @@ -126,8 +153,9 @@ class UnorderedSignature implements Signature, Predicate // Find reference to argument in callArgs for (int ci = 0; ci < callArgsLen; ci++) { - if (methodArgs[ai].matches(callArgs[ci])) + if (!selectedArgs[ci].selected && methodArgs[ai].matches(selectedArgs[ci])) { + selectedArgs[ci].selected(); ref = ci; break; } @@ -171,32 +199,20 @@ class UnorderedSignature implements Signature, Predicate // Ensure that required arguments are present in the mapping for (int ci = 0; ci < callArgsLen; ci++) { - if (callArgs[ci].isRequired()) + if (selectedArgs[ci].isRequired() && !selectedArgs[ci].isSelected()) { - boolean found = false; - for (int ai = 0; ai < argMappingLength; ai++) + StringBuilder err = new StringBuilder(); + err.append("Unable to find required type ["); + err.append(callArgs[ci].getType()); + err.append("] in method "); + ReflectUtils.append(err, method); + + if (throwOnFailure) + throw new DynamicArgsException(err.toString()); + else { - if (argMapping[ai] == ci) - { - found = true; - break; - } - } - if (!found) - { - StringBuilder err = new StringBuilder(); - err.append("Unable to find required type ["); - err.append(callArgs[ci].getType()); - err.append("] in method "); - ReflectUtils.append(err, method); - - if (throwOnFailure) - throw new DynamicArgsException(err.toString()); - else - { - LOG.debug("{}", err.toString()); - return null; - } + LOG.debug("{}", err.toString()); + return null; } } } diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/reflect/DynamicArgsTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/reflect/DynamicArgsTest.java index 9a925318d6e..f660de40a8e 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/reflect/DynamicArgsTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/reflect/DynamicArgsTest.java @@ -217,13 +217,9 @@ public class DynamicArgsTest DynamicArgs.Builder dab = new DynamicArgs.Builder(); dab.addSignature(ARG_BYTEARRAY, ARG_OFFSET, ARG_LENGTH); - final Arg CALL_BYTEARRAY = new Arg(byte[].class); - final Arg CALL_OFFSET = new Arg(int.class).setTag("offset"); - final Arg CALL_LENGTH = new Arg(int.class).setTag("length"); - SampleSignatures ssigs = new SampleSignatures(); Method m = findMethodByName(ssigs, "sigByteArray"); - DynamicArgs dynamicArgs = dab.build(m, CALL_BYTEARRAY, CALL_OFFSET, CALL_LENGTH); + DynamicArgs dynamicArgs = dab.build(m, ARG_BYTEARRAY, ARG_OFFSET, ARG_LENGTH); assertThat("DynamicArgs", dynamicArgs, notNullValue()); // Test with potential args diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase1.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase1.java index 3fc99bfba72..5d79050585b 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase1.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase1.java @@ -32,6 +32,7 @@ import org.eclipse.jetty.websocket.common.test.Fuzzer; import org.eclipse.jetty.websocket.common.test.Fuzzer.SendMode; import org.junit.Test; +@SuppressWarnings("Duplicates") public class TestABCase1 extends AbstractABCase { /** diff --git a/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties b/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties index 924d0006cbb..7eca57d4ddb 100644 --- a/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties +++ b/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties @@ -2,7 +2,7 @@ org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog org.eclipse.jetty.LEVEL=WARN # org.eclipse.jetty.io.WriteFlusher.LEVEL=DEBUG -# org.eclipse.jetty.websocket.LEVEL=DEBUG +org.eclipse.jetty.websocket.LEVEL=DEBUG # org.eclipse.jetty.websocket.LEVEL=INFO # org.eclipse.jetty.websocket.common.io.LEVEL=DEBUG # org.eclipse.jetty.websocket.server.ab.LEVEL=DEBUG