private void handleMissingResponseProcessor(int streamId, FrameType type, Frame frame) { if (!streamIdSupplier.isBeforeOrCurrent(streamId)) { if (type == FrameType.ERROR) { // message for stream that has never existed, we have a problem with // the overall connection and must tear down String errorMessage = frame.getDataUtf8(); throw new IllegalStateException( "Client received error for non-existent stream: " + streamId + " Message: " + errorMessage); } else { throw new IllegalStateException( "Client received message for non-existent stream: " + streamId + ", frame type: " + type); } } // receiving a frame after a given stream has been cancelled/completed, // so ignore (cancellation is async so there is a race condition) }
@Test public void testServerIsValid() { StreamIdSupplier s = StreamIdSupplier.serverSupplier(); assertFalse(s.isBeforeOrCurrent(2)); assertFalse(s.isBeforeOrCurrent(4)); s.nextStreamId(); assertTrue(s.isBeforeOrCurrent(2)); assertFalse(s.isBeforeOrCurrent(4)); s.nextStreamId(); assertTrue(s.isBeforeOrCurrent(4)); // negative assertFalse(s.isBeforeOrCurrent(-2)); // connection assertFalse(s.isBeforeOrCurrent(0)); // client also accepted (checked externally) assertTrue(s.isBeforeOrCurrent(1)); } }
@Test public void testClientIsValid() { StreamIdSupplier s = StreamIdSupplier.clientSupplier(); assertFalse(s.isBeforeOrCurrent(1)); assertFalse(s.isBeforeOrCurrent(3)); s.nextStreamId(); assertTrue(s.isBeforeOrCurrent(1)); assertFalse(s.isBeforeOrCurrent(3)); s.nextStreamId(); assertTrue(s.isBeforeOrCurrent(3)); // negative assertFalse(s.isBeforeOrCurrent(-1)); // connection assertFalse(s.isBeforeOrCurrent(0)); // server also accepted (checked externally) assertTrue(s.isBeforeOrCurrent(2)); }
private void handleMissingResponseProcessor(int streamId, FrameType type, Frame frame) { if (!streamIdSupplier.isBeforeOrCurrent(streamId)) { if (type == FrameType.ERROR) { // message for stream that has never existed, we have a problem with // the overall connection and must tear down String errorMessage = frame.getDataUtf8(); throw new IllegalStateException( "Client received error for non-existent stream: " + streamId + " Message: " + errorMessage); } else { throw new IllegalStateException( "Client received message for non-existent stream: " + streamId + ", frame type: " + type); } } // receiving a frame after a given stream has been cancelled/completed, // so ignore (cancellation is async so there is a race condition) }