diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java index 956010735ce..ab4c12b607a 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java @@ -89,7 +89,7 @@ public class ServerReadThread extends Thread conn.getParser().parse(buf); } - Queue frames = conn.getIncomingFrames().getFrames(); + Queue frames = conn.getParserCapture().getFrames(); WebSocketFrame frame; while ((frame = frames.poll()) != null) { diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/CloseInfo.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/CloseInfo.java index a7ca1a56acd..c8749c524df 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/CloseInfo.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/CloseInfo.java @@ -82,19 +82,17 @@ public class CloseInfo data.get(reasonBytes,0,len); // Spec Requirement : throw BadPayloadException on invalid UTF8 - if(validate) + try { - try - { - Utf8StringBuilder utf = new Utf8StringBuilder(); - // if this throws, we know we have bad UTF8 - utf.append(reasonBytes,0,reasonBytes.length); - this.reason = utf.toString(); - } - catch (NotUtf8Exception e) - { + Utf8StringBuilder utf = new Utf8StringBuilder(); + // if this throws, we know we have bad UTF8 + utf.append(reasonBytes,0,reasonBytes.length); + this.reason = utf.toString(); + } + catch (NotUtf8Exception e) + { + if(validate) throw new BadPayloadException("Invalid Close Reason",e); - } } } } @@ -141,25 +139,28 @@ public class CloseInfo // codes that are not allowed to be used in endpoint. return null; } - + int len = 2; // status code - byte reasonBytes[]; - byte[] utf8Bytes = reason.getBytes(StandardCharsets.UTF_8); - if (utf8Bytes.length > CloseStatus.MAX_REASON_PHRASE) - { - reasonBytes = new byte[CloseStatus.MAX_REASON_PHRASE]; - System.arraycopy(utf8Bytes, 0, reasonBytes, 0, CloseStatus.MAX_REASON_PHRASE); - } - else - { - reasonBytes = utf8Bytes; - } + byte reasonBytes[] = null; - boolean hasReason = (reasonBytes != null) && (reasonBytes.length > 0); - if (hasReason) + if (reason != null) { - len += reasonBytes.length; + byte[] utf8Bytes = reason.getBytes(StandardCharsets.UTF_8); + if (utf8Bytes.length > CloseStatus.MAX_REASON_PHRASE) + { + reasonBytes = new byte[CloseStatus.MAX_REASON_PHRASE]; + System.arraycopy(utf8Bytes, 0, reasonBytes, 0, CloseStatus.MAX_REASON_PHRASE); + } + else + { + reasonBytes = utf8Bytes; + } + + if ((reasonBytes != null) && (reasonBytes.length > 0)) + { + len += reasonBytes.length; + } } ByteBuffer buf = BufferUtil.allocate(len); @@ -167,7 +168,7 @@ public class CloseInfo buf.put((byte) ((statusCode >>> 8) & 0xFF)); buf.put((byte) ((statusCode >>> 0) & 0xFF)); - if (hasReason) + if ((reasonBytes != null) && (reasonBytes.length > 0)) { buf.put(reasonBytes, 0, reasonBytes.length); } diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ClosePayloadParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ClosePayloadParserTest.java index 1a36207d991..86c51c75e9f 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ClosePayloadParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ClosePayloadParserTest.java @@ -26,7 +26,7 @@ import java.nio.charset.StandardCharsets; import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.api.WebSocketBehavior; import org.eclipse.jetty.websocket.api.WebSocketPolicy; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.eclipse.jetty.websocket.common.util.MaskedByteBuffer; import org.junit.Assert; @@ -43,17 +43,17 @@ public class ClosePayloadParserTest ByteBuffer payload = ByteBuffer.allocate(utf.length + 2); payload.putChar((char)StatusCode.NORMAL); payload.put(utf,0,utf.length); - payload.flip(); + payload.flip(); // to read ByteBuffer buf = ByteBuffer.allocate(24); buf.put((byte)(0x80 | OpCode.CLOSE)); // fin + close buf.put((byte)(0x80 | payload.remaining())); MaskedByteBuffer.putMask(buf); MaskedByteBuffer.putPayload(buf,payload); - buf.flip(); + buf.flip(); // to read WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); parser.parse(buf); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java index f7b539dbbf7..f39678b328d 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.common.frames.TextFrame; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule; import org.junit.Assert; import org.junit.Rule; @@ -42,7 +42,7 @@ public class GeneratorParserRoundtripTest { WebSocketPolicy policy = WebSocketPolicy.newClientPolicy(); Generator gen = new Generator(policy,bufferPool); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new Parser(policy,bufferPool,capture); String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; @@ -78,7 +78,7 @@ public class GeneratorParserRoundtripTest public void testParserAndGeneratorMasked() throws Exception { Generator gen = new Generator(WebSocketPolicy.newClientPolicy(),bufferPool); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new Parser(WebSocketPolicy.newServerPolicy(),bufferPool,capture); String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java index af6ac3b814d..d61a5913ce4 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java @@ -34,7 +34,7 @@ import org.eclipse.jetty.websocket.common.frames.BinaryFrame; import org.eclipse.jetty.websocket.common.frames.CloseFrame; import org.eclipse.jetty.websocket.common.frames.PingFrame; import org.eclipse.jetty.websocket.common.frames.TextFrame; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitGenerator; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.eclipse.jetty.websocket.common.util.Hex; @@ -297,7 +297,7 @@ public class GeneratorTest // Parse complete buffer. WebSocketPolicy policy = WebSocketPolicy.newServerPolicy(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); parser.parse(completeBuffer); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java index c28ebff4c2c..27c6905973b 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java @@ -36,7 +36,7 @@ import org.eclipse.jetty.websocket.common.frames.DataFrame; import org.eclipse.jetty.websocket.common.frames.PingFrame; import org.eclipse.jetty.websocket.common.frames.PongFrame; import org.eclipse.jetty.websocket.common.frames.TextFrame; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitGenerator; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.eclipse.jetty.websocket.common.util.Hex; @@ -63,7 +63,7 @@ public class ParserTest send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(WebSocketPolicy.newServerPolicy(),capture); expectedException.expect(ProtocolException.class); @@ -85,7 +85,7 @@ public class ParserTest send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(WebSocketPolicy.newServerPolicy(),capture); expectedException.expect(ProtocolException.class); @@ -111,7 +111,7 @@ public class ParserTest send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(WebSocketPolicy.newServerPolicy(),capture); parser.parse(completeBuf); @@ -133,7 +133,7 @@ public class ParserTest send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(WebSocketPolicy.newServerPolicy(),capture); parser.parse(completeBuf); @@ -181,7 +181,7 @@ public class ParserTest send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(WebSocketPolicy.newServerPolicy(),capture); parser.parse(completeBuf); @@ -198,7 +198,7 @@ public class ParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); parser.parse(buf); @@ -225,7 +225,7 @@ public class ParserTest // Parse, in 4096 sized windows WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); while (networkBytes.remaining() > 0) diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/PingPayloadParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/PingPayloadParserTest.java index 4f7ca06c7dd..c289eaa2f54 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/PingPayloadParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/PingPayloadParserTest.java @@ -26,7 +26,7 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.api.WebSocketBehavior; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.common.frames.PingFrame; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.junit.Assert; import org.junit.Test; @@ -43,7 +43,7 @@ public class PingPayloadParserTest BufferUtil.flipToFlush(buf,0); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); parser.parse(buf); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesParserTest.java index c22c51420b3..7d3dbc9c51f 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesParserTest.java @@ -27,7 +27,7 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.api.WebSocketBehavior; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.api.extensions.Frame; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.junit.Test; @@ -40,7 +40,7 @@ public class RFC6455ExamplesParserTest public void testFragmentedUnmaskedTextMessage() { WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); ByteBuffer buf = ByteBuffer.allocate(16); @@ -86,7 +86,7 @@ public class RFC6455ExamplesParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); parser.parse(buf); @@ -108,7 +108,7 @@ public class RFC6455ExamplesParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); parser.parse(buf); @@ -137,7 +137,7 @@ public class RFC6455ExamplesParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); parser.parse(buf); @@ -174,7 +174,7 @@ public class RFC6455ExamplesParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); assertThat(parser.parse(buf), is(true)); @@ -203,7 +203,7 @@ public class RFC6455ExamplesParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); parser.parse(buf); @@ -225,7 +225,7 @@ public class RFC6455ExamplesParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); parser.parse(buf); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/TextPayloadParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/TextPayloadParserTest.java index d407ca91378..a34979107ac 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/TextPayloadParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/TextPayloadParserTest.java @@ -30,7 +30,7 @@ import java.util.Arrays; import org.eclipse.jetty.websocket.api.MessageTooLargeException; import org.eclipse.jetty.websocket.api.WebSocketBehavior; import org.eclipse.jetty.websocket.api.WebSocketPolicy; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.eclipse.jetty.websocket.common.util.MaskedByteBuffer; import org.junit.Assert; @@ -64,7 +64,7 @@ public class TextPayloadParserTest MaskedByteBuffer.putPayload(buf,utf); buf.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); expectedException.expect(MessageTooLargeException.class); @@ -98,7 +98,7 @@ public class TextPayloadParserTest WebSocketPolicy policy = WebSocketPolicy.newServerPolicy(); policy.setMaxTextMessageSize(100000); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(buf); @@ -131,7 +131,7 @@ public class TextPayloadParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(buf); @@ -166,7 +166,7 @@ public class TextPayloadParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(buf); @@ -192,7 +192,7 @@ public class TextPayloadParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(buf); @@ -216,7 +216,7 @@ public class TextPayloadParserTest buf.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(buf); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java index 791484513f5..a234eef173b 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java @@ -33,7 +33,7 @@ import org.eclipse.jetty.websocket.common.Parser; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.common.test.ByteBufferAssert; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitGenerator; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.junit.Assert; @@ -305,7 +305,7 @@ public class TestABCase1_1 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -337,7 +337,7 @@ public class TestABCase1_1 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -369,7 +369,7 @@ public class TestABCase1_1 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -401,7 +401,7 @@ public class TestABCase1_1 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -435,7 +435,7 @@ public class TestABCase1_1 expected.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); policy.setMaxTextMessageSize(length); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -470,7 +470,7 @@ public class TestABCase1_1 WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); policy.setMaxTextMessageSize(length); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -491,7 +491,7 @@ public class TestABCase1_1 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java index d51d4aed6b3..4fe7c7ac003 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java @@ -32,7 +32,7 @@ import org.eclipse.jetty.websocket.common.Parser; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.eclipse.jetty.websocket.common.frames.BinaryFrame; import org.eclipse.jetty.websocket.common.test.ByteBufferAssert; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitGenerator; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.junit.Assert; @@ -324,7 +324,7 @@ public class TestABCase1_2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -356,7 +356,7 @@ public class TestABCase1_2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -388,7 +388,7 @@ public class TestABCase1_2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -420,7 +420,7 @@ public class TestABCase1_2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -452,7 +452,7 @@ public class TestABCase1_2 expected.flip(); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); policy.setMaxBinaryMessageSize(length); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -485,7 +485,7 @@ public class TestABCase1_2 WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT); policy.setMaxBinaryMessageSize(length); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -506,7 +506,7 @@ public class TestABCase1_2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java index f0b749f31c9..85e9595e893 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java @@ -35,7 +35,7 @@ import org.eclipse.jetty.websocket.common.Parser; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.eclipse.jetty.websocket.common.frames.PingFrame; import org.eclipse.jetty.websocket.common.test.ByteBufferAssert; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitGenerator; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.junit.Assert; @@ -190,7 +190,7 @@ public class TestABCase2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -218,7 +218,7 @@ public class TestABCase2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -239,7 +239,7 @@ public class TestABCase2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -268,7 +268,7 @@ public class TestABCase2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -309,7 +309,7 @@ public class TestABCase2 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); expectedException.expect(ProtocolException.class); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase4.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase4.java index 96a400c84b8..04e7914c251 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase4.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase4.java @@ -26,7 +26,7 @@ import org.eclipse.jetty.websocket.api.ProtocolException; import org.eclipse.jetty.websocket.api.WebSocketBehavior; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.common.Parser; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.junit.Rule; import org.junit.Test; @@ -48,7 +48,7 @@ public class TestABCase4 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); expectedException.expect(ProtocolException.class); @@ -65,7 +65,7 @@ public class TestABCase4 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy, capture); expectedException.expect(ProtocolException.class); @@ -82,7 +82,7 @@ public class TestABCase4 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy, capture); expectedException.expect(ProtocolException.class); @@ -99,7 +99,7 @@ public class TestABCase4 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); expectedException.expect(ProtocolException.class); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase7_3.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase7_3.java index f0ab84a0471..61d3be87153 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase7_3.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase7_3.java @@ -34,7 +34,7 @@ import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.Parser; import org.eclipse.jetty.websocket.common.frames.CloseFrame; import org.eclipse.jetty.websocket.common.test.ByteBufferAssert; -import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture; +import org.eclipse.jetty.websocket.common.test.ParserCapture; import org.eclipse.jetty.websocket.common.test.UnitGenerator; import org.eclipse.jetty.websocket.common.test.UnitParser; import org.eclipse.jetty.websocket.common.util.Hex; @@ -78,7 +78,7 @@ public class TestABCase7_3 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -102,7 +102,7 @@ public class TestABCase7_3 { ByteBuffer expected = Hex.asByteBuffer("880100"); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); expectedException.expect(ProtocolException.class); @@ -137,7 +137,7 @@ public class TestABCase7_3 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -190,7 +190,7 @@ public class TestABCase7_3 expected.put(messageBytes); expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -256,7 +256,7 @@ public class TestABCase7_3 expected.put(messageBytes); expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); Parser parser = new UnitParser(policy,capture); parser.parse(expected); @@ -322,7 +322,7 @@ public class TestABCase7_3 expected.flip(); - IncomingFramesCapture capture = new IncomingFramesCapture(); + ParserCapture capture = new ParserCapture(); UnitParser parser = new UnitParser(policy,capture); expectedException.expect(ProtocolException.class); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/AbstractFrameCapture.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/AbstractFrameCapture.java new file mode 100644 index 00000000000..fa5fd8a314c --- /dev/null +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/AbstractFrameCapture.java @@ -0,0 +1,110 @@ +// +// ======================================================================== +// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.websocket.common.test; + +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.is; + +import java.util.Queue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingDeque; + +import org.eclipse.jetty.util.BufferUtil; +import org.eclipse.jetty.websocket.api.extensions.Frame; +import org.eclipse.jetty.websocket.common.OpCode; +import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.junit.Assert; + +public abstract class AbstractFrameCapture +{ + public BlockingQueue frames = new LinkedBlockingDeque<>(); + + public void assertFrameCount(int expectedCount) + { + if (frames.size() != expectedCount) + { + // dump details + System.err.printf("Expected %d frame(s)%n",expectedCount); + System.err.printf("But actually captured %d frame(s)%n",frames.size()); + int i = 0; + for (Frame frame : frames) + { + System.err.printf(" [%d] Frame[%s] - %s%n", i++, + OpCode.name(frame.getOpCode()), + BufferUtil.toDetailString(frame.getPayload())); + } + } + Assert.assertThat("Captured frame count",frames.size(),is(expectedCount)); + } + + public void assertHasFrame(byte op) + { + Assert.assertThat(OpCode.name(op),getFrameCount(op),greaterThanOrEqualTo(1)); + } + + public void assertHasFrame(byte op, int expectedCount) + { + String msg = String.format("%s frame count",OpCode.name(op)); + Assert.assertThat(msg,getFrameCount(op),is(expectedCount)); + } + + public void assertHasNoFrames() + { + Assert.assertThat("Frame count",frames.size(),is(0)); + } + + public void clear() + { + frames.clear(); + } + + public void dump() + { + System.err.printf("Captured %d incoming frames%n",frames.size()); + int i = 0; + for (Frame frame : frames) + { + System.err.printf("[%3d] %s%n",i++,frame); + System.err.printf(" payload: %s%n",BufferUtil.toDetailString(frame.getPayload())); + } + } + + public int getFrameCount(byte op) + { + int count = 0; + for (WebSocketFrame frame : frames) + { + if (frame.getOpCode() == op) + { + count++; + } + } + return count; + } + + public Queue getFrames() + { + return frames; + } + + public int size() + { + return frames.size(); + } +} diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadServerConnection.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadServerConnection.java index 69de6d78964..50d335af327 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadServerConnection.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadServerConnection.java @@ -41,7 +41,7 @@ public interface IBlockheadServerConnection public void disconnect(); - public IncomingFramesCapture readFrames(int expectedCount, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException; + public ParserCapture readFrames(int expectedCount, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException; public void write(ByteBuffer buf) throws IOException; public List readRequestLines() throws IOException; public String parseWebSocketKey(List requestLines); @@ -53,7 +53,7 @@ public interface IBlockheadServerConnection public ByteBufferPool getBufferPool(); public int read(ByteBuffer buf) throws IOException; public Parser getParser(); - public IncomingFramesCapture getIncomingFrames(); + public ParserCapture getParserCapture(); public void flush() throws IOException; public void write(int b) throws IOException; public void startEcho(); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IncomingFramesCapture.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IncomingFramesCapture.java index 1b9e341dcd3..0a96fc54fc8 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IncomingFramesCapture.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IncomingFramesCapture.java @@ -18,109 +18,18 @@ package org.eclipse.jetty.websocket.common.test; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.is; - -import java.util.Queue; - -import org.eclipse.jetty.toolchain.test.EventQueue; -import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.api.FrameCallback; import org.eclipse.jetty.websocket.api.extensions.Frame; import org.eclipse.jetty.websocket.api.extensions.IncomingFrames; -import org.eclipse.jetty.websocket.common.OpCode; -import org.eclipse.jetty.websocket.common.Parser; import org.eclipse.jetty.websocket.common.WebSocketFrame; -import org.junit.Assert; -public class IncomingFramesCapture implements Parser.Handler, IncomingFrames +public class IncomingFramesCapture extends AbstractFrameCapture implements IncomingFrames { - private EventQueue frames = new EventQueue<>(); - - public void assertFrameCount(int expectedCount) - { - if (frames.size() != expectedCount) - { - // dump details - System.err.printf("Expected %d frame(s)%n",expectedCount); - System.err.printf("But actually captured %d frame(s)%n",frames.size()); - int i = 0; - for (Frame frame : frames) - { - System.err.printf(" [%d] Frame[%s] - %s%n", i++, - OpCode.name(frame.getOpCode()), - BufferUtil.toDetailString(frame.getPayload())); - } - } - Assert.assertThat("Captured frame count",frames.size(),is(expectedCount)); - } - - public void assertHasFrame(byte op) - { - Assert.assertThat(OpCode.name(op),getFrameCount(op),greaterThanOrEqualTo(1)); - } - - public void assertHasFrame(byte op, int expectedCount) - { - String msg = String.format("%s frame count",OpCode.name(op)); - Assert.assertThat(msg,getFrameCount(op),is(expectedCount)); - } - - public void assertHasNoFrames() - { - Assert.assertThat("Frame count",frames.size(),is(0)); - } - - public void clear() - { - frames.clear(); - } - - public void dump() - { - System.err.printf("Captured %d incoming frames%n",frames.size()); - int i = 0; - for (Frame frame : frames) - { - System.err.printf("[%3d] %s%n",i++,frame); - System.err.printf(" payload: %s%n",BufferUtil.toDetailString(frame.getPayload())); - } - } - - public int getFrameCount(byte op) - { - int count = 0; - for (WebSocketFrame frame : frames) - { - if (frame.getOpCode() == op) - { - count++; - } - } - return count; - } - - public Queue getFrames() - { - return frames; - } - @Override public void incomingFrame(Frame frame, FrameCallback callback) - { - onFrame(frame); - } - - @Override - public boolean onFrame(Frame frame) { WebSocketFrame copy = WebSocketFrame.copy(frame); frames.add(copy); - return true; - } - - public int size() - { - return frames.size(); + callback.succeed(); } } diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/ParserCapture.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/ParserCapture.java new file mode 100644 index 00000000000..63ded5bda61 --- /dev/null +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/ParserCapture.java @@ -0,0 +1,34 @@ +// +// ======================================================================== +// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.websocket.common.test; + +import org.eclipse.jetty.websocket.api.extensions.Frame; +import org.eclipse.jetty.websocket.common.Parser; +import org.eclipse.jetty.websocket.common.WebSocketFrame; + +public class ParserCapture extends AbstractFrameCapture implements Parser.Handler +{ + @Override + public boolean onFrame(Frame frame) + { + WebSocketFrame copy = WebSocketFrame.copy(frame); + frames.add(copy); + return true; + } +} diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/XBlockheadServerConnection.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/XBlockheadServerConnection.java index 5a39574f623..b0a28299399 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/XBlockheadServerConnection.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/XBlockheadServerConnection.java @@ -74,7 +74,7 @@ public class XBlockheadServerConnection implements IncomingFrames, OutgoingFrame private final Socket socket; private final ByteBufferPool bufferPool; private final WebSocketPolicy policy; - private final IncomingFramesCapture incomingFrames; + private final ParserCapture parserCapture; private final Parser parser; private final Generator generator; private final AtomicInteger parseCount; @@ -94,7 +94,7 @@ public class XBlockheadServerConnection implements IncomingFrames, OutgoingFrame public XBlockheadServerConnection(Socket socket) { this.socket = socket; - this.incomingFrames = new IncomingFramesCapture(); + this.parserCapture = new ParserCapture(); this.policy = WebSocketPolicy.newServerPolicy(); this.policy.setMaxBinaryMessageSize(100000); this.policy.setMaxTextMessageSize(100000); @@ -162,7 +162,7 @@ public class XBlockheadServerConnection implements IncomingFrames, OutgoingFrame public void echoMessage(int expectedFrames, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException { LOG.debug("Echo Frames [expecting {}]",expectedFrames); - IncomingFramesCapture cap = readFrames(expectedFrames,timeoutDuration,timeoutUnit); + ParserCapture cap = readFrames(expectedFrames,timeoutDuration,timeoutUnit); // now echo them back. for (Frame frame : cap.getFrames()) { @@ -180,9 +180,9 @@ public class XBlockheadServerConnection implements IncomingFrames, OutgoingFrame return bufferPool; } - public IncomingFramesCapture getIncomingFrames() + public ParserCapture getParserCapture() { - return incomingFrames; + return parserCapture; } public InputStream getInputStream() throws IOException @@ -222,7 +222,9 @@ public class XBlockheadServerConnection implements IncomingFrames, OutgoingFrame { LOG.info("Server parsed {} frames",count); } - incomingFrames.incomingFrame(WebSocketFrame.copy(frame), callback); + + parserCapture.onFrame(frame); + callback.succeed(); if (frame.getOpCode() == OpCode.CLOSE) { @@ -319,10 +321,10 @@ public class XBlockheadServerConnection implements IncomingFrames, OutgoingFrame return len; } - public IncomingFramesCapture readFrames(int expectedCount, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException + public ParserCapture readFrames(int expectedCount, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException { LOG.debug("Read: waiting for {} frame(s) from client",expectedCount); - int startCount = incomingFrames.size(); + int startCount = parserCapture.size(); ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); BufferUtil.clearToFill(buf); @@ -334,7 +336,7 @@ public class XBlockheadServerConnection implements IncomingFrames, OutgoingFrame LOG.debug("Now: {} - expireOn: {} ({} ms)",now,expireOn,msDur); int len = 0; - while (incomingFrames.size() < (startCount + expectedCount)) + while (parserCapture.size() < (startCount + expectedCount)) { BufferUtil.clearToFill(buf); len = read(buf); @@ -354,9 +356,9 @@ public class XBlockheadServerConnection implements IncomingFrames, OutgoingFrame } if (!debug && (System.currentTimeMillis() > expireOn)) { - incomingFrames.dump(); + parserCapture.dump(); throw new TimeoutException(String.format("Timeout reading all %d expected frames. (managed to only read %d frame(s))",expectedCount, - incomingFrames.size())); + parserCapture.size())); } } } @@ -365,7 +367,7 @@ public class XBlockheadServerConnection implements IncomingFrames, OutgoingFrame bufferPool.release(buf); } - return incomingFrames; + return parserCapture; } public String readRequest() throws IOException