@Override public FrameTooLongException copy() { return new FrameTooLongException(streamId, this); } }
@Override protected Object decode(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception { // Capture current index in case we need to get the stream id. // If a TooLongFrameException is thrown the readerIndex will advance to the end of // the buffer (or past the frame) so we need the position as we entered this method. int curIndex = buffer.readerIndex(); try { ByteBuf frame = (ByteBuf) super.decode(ctx, buffer); if (frame == null) { return null; } // Do not deallocate `frame` just yet, because it is stored as Frame.body and will be used // in Message.ProtocolDecoder or Frame.Decompressor if compression is enabled (we // deallocate // it there). Frame theFrame = Frame.create(frame); // Validate the opcode (this will throw if it's not a response) Message.Response.Type.fromOpcode(theFrame.header.opcode); return theFrame; } catch (CorruptedFrameException e) { throw new DriverInternalError(e); } catch (TooLongFrameException e) { int streamId = protocolVersion > 2 ? buffer.getShort(curIndex + 2) : buffer.getByte(curIndex + 2); throw new FrameTooLongException(streamId); } } }
@Override public FrameTooLongException copy() { return new FrameTooLongException(streamId, this); } }
@Override public FrameTooLongException copy() { return new FrameTooLongException(streamId, this); } }
@Override public FrameTooLongException copy() { return new FrameTooLongException(streamId, this); } }
final long then = System.currentTimeMillis(); render(); // surely it's more than this but you get the idea final long now = System.currentTimeMillis(); final long actualDuration = now - then; final long sleepDuration = frameDuration - actualDuration; if(sleepDuration > 0) { sleep(sleepDuration); } else { throw new FrameTooLongException(); }
@Override protected Object decode(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception { // Capture current index in case we need to get the stream id. // If a TooLongFrameException is thrown the readerIndex will advance to the end of // the buffer (or past the frame) so we need the position as we entered this method. int curIndex = buffer.readerIndex(); try { ByteBuf frame = (ByteBuf) super.decode(ctx, buffer); if (frame == null) { return null; } // Do not deallocate `frame` just yet, because it is stored as Frame.body and will be used // in Message.ProtocolDecoder or Frame.Decompressor if compression is enabled (we deallocate // it there). Frame theFrame = Frame.create(frame); // Validate the opcode (this will throw if it's not a response) Message.Response.Type.fromOpcode(theFrame.header.opcode); return theFrame; } catch (CorruptedFrameException e) { throw new DriverInternalError(e); } catch (TooLongFrameException e) { int streamId = protocolVersion > 2 ? buffer.getShort(curIndex + 2) : buffer.getByte(curIndex + 2); throw new FrameTooLongException(streamId); } } }
@Override protected Object decode(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception { // Capture current index in case we need to get the stream id. // If a TooLongFrameException is thrown the readerIndex will advance to the end of // the buffer (or past the frame) so we need the position as we entered this method. int curIndex = buffer.readerIndex(); try { ByteBuf frame = (ByteBuf) super.decode(ctx, buffer); if (frame == null) { return null; } // Do not deallocate `frame` just yet, because it is stored as Frame.body and will be used // in Message.ProtocolDecoder or Frame.Decompressor if compression is enabled (we deallocate // it there). Frame theFrame = Frame.create(frame); // Validate the opcode (this will throw if it's not a response) Message.Response.Type.fromOpcode(theFrame.header.opcode); return theFrame; } catch (CorruptedFrameException e) { throw new DriverInternalError(e); } catch (TooLongFrameException e) { int streamId = protocolVersion > 2 ? buffer.getShort(curIndex + 2) : buffer.getByte(curIndex + 2); throw new FrameTooLongException(streamId); } } }
@Override protected Object decode(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception { // Capture current index in case we need to get the stream id. // If a TooLongFrameException is thrown the readerIndex will advance to the end of // the buffer (or past the frame) so we need the position as we entered this method. int curIndex = buffer.readerIndex(); try { ByteBuf frame = (ByteBuf) super.decode(ctx, buffer); if (frame == null) { return null; } // Do not deallocate `frame` just yet, because it is stored as Frame.body and will be used // in Message.ProtocolDecoder or Frame.Decompressor if compression is enabled (we deallocate // it there). Frame theFrame = Frame.create(frame); // Validate the opcode (this will throw if it's not a response) Message.Response.Type.fromOpcode(theFrame.header.opcode); return theFrame; } catch (CorruptedFrameException e) { throw new DriverInternalError(e); } catch (TooLongFrameException e) { int streamId = protocolVersion > 2 ? buffer.getShort(curIndex + 2) : buffer.getByte(curIndex + 2); throw new FrameTooLongException(streamId); } } }