From 464dd0667a01df6d315eecddcb351ca4887f5149 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 14 Sep 2016 16:57:11 +0200 Subject: [PATCH] Issue #922 - Implements methods Connection.getBytes[In|Out](). Using int rather than long as return value for generated bytes. --- .../main/java/org/eclipse/jetty/http2/HTTP2Session.java | 4 ++-- .../org/eclipse/jetty/http2/generator/DataGenerator.java | 8 ++++---- .../jetty/http2/generator/DisconnectGenerator.java | 2 +- .../org/eclipse/jetty/http2/generator/FrameGenerator.java | 2 +- .../java/org/eclipse/jetty/http2/generator/Generator.java | 4 ++-- .../eclipse/jetty/http2/generator/GoAwayGenerator.java | 4 ++-- .../eclipse/jetty/http2/generator/HeadersGenerator.java | 4 ++-- .../org/eclipse/jetty/http2/generator/PingGenerator.java | 4 ++-- .../eclipse/jetty/http2/generator/PrefaceGenerator.java | 2 +- .../eclipse/jetty/http2/generator/PriorityGenerator.java | 4 ++-- .../jetty/http2/generator/PushPromiseGenerator.java | 4 ++-- .../org/eclipse/jetty/http2/generator/ResetGenerator.java | 4 ++-- .../eclipse/jetty/http2/generator/SettingsGenerator.java | 4 ++-- .../jetty/http2/generator/WindowUpdateGenerator.java | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java index 8c597ba3780..200b51ffb8f 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java @@ -1108,7 +1108,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio private class ControlEntry extends HTTP2Flusher.Entry { - private long bytes; + private int bytes; private ControlEntry(Frame frame, IStream stream, Callback callback) { @@ -1224,7 +1224,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio private class DataEntry extends HTTP2Flusher.Entry { private int length; - private long bytes; + private int bytes; private DataEntry(DataFrame frame, IStream stream, Callback callback) { diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DataGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DataGenerator.java index d1017b0e2ae..84822565eeb 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DataGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DataGenerator.java @@ -36,12 +36,12 @@ public class DataGenerator this.headerGenerator = headerGenerator; } - public long generate(ByteBufferPool.Lease lease, DataFrame frame, int maxLength) + public int generate(ByteBufferPool.Lease lease, DataFrame frame, int maxLength) { return generateData(lease, frame.getStreamId(), frame.getData(), frame.isEndStream(), maxLength); } - public long generateData(ByteBufferPool.Lease lease, int streamId, ByteBuffer data, boolean last, int maxLength) + public int generateData(ByteBufferPool.Lease lease, int streamId, ByteBuffer data, boolean last, int maxLength) { if (streamId < 0) throw new IllegalArgumentException("Invalid stream id: " + streamId); @@ -61,7 +61,7 @@ public class DataGenerator if (frames * maxFrameSize != length) ++frames; - long totalLength = 0; + int totalLength = 0; int begin = data.position(); int end = data.limit(); for (int i = 1; i <= frames; ++i) @@ -77,7 +77,7 @@ public class DataGenerator return totalLength; } - private long generateFrame(ByteBufferPool.Lease lease, int streamId, ByteBuffer data, boolean last) + private int generateFrame(ByteBufferPool.Lease lease, int streamId, ByteBuffer data, boolean last) { int length = data.remaining(); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DisconnectGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DisconnectGenerator.java index c37c499bad3..93037799d65 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DisconnectGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DisconnectGenerator.java @@ -29,7 +29,7 @@ public class DisconnectGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { return 0; } diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/FrameGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/FrameGenerator.java index 575b9593cf1..30f2c980e71 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/FrameGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/FrameGenerator.java @@ -33,7 +33,7 @@ public abstract class FrameGenerator this.headerGenerator = headerGenerator; } - public abstract long generate(ByteBufferPool.Lease lease, Frame frame); + public abstract int generate(ByteBufferPool.Lease lease, Frame frame); protected ByteBuffer generateHeader(ByteBufferPool.Lease lease, FrameType frameType, int length, int flags, int streamId) { diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java index 7a232811fd9..bd873c47b5e 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java @@ -75,12 +75,12 @@ public class Generator headerGenerator.setMaxFrameSize(maxFrameSize); } - public long control(ByteBufferPool.Lease lease, Frame frame) + public int control(ByteBufferPool.Lease lease, Frame frame) { return generators[frame.getType().getType()].generate(lease, frame); } - public long data(ByteBufferPool.Lease lease, DataFrame frame, int maxLength) + public int data(ByteBufferPool.Lease lease, DataFrame frame, int maxLength) { return dataGenerator.generate(lease, frame, maxLength); } diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/GoAwayGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/GoAwayGenerator.java index 468dccfe2a6..697d158570e 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/GoAwayGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/GoAwayGenerator.java @@ -36,13 +36,13 @@ public class GoAwayGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { GoAwayFrame goAwayFrame = (GoAwayFrame)frame; return generateGoAway(lease, goAwayFrame.getLastStreamId(), goAwayFrame.getError(), goAwayFrame.getPayload()); } - public long generateGoAway(ByteBufferPool.Lease lease, int lastStreamId, int error, byte[] payload) + public int generateGoAway(ByteBufferPool.Lease lease, int lastStreamId, int error, byte[] payload) { if (lastStreamId < 0) throw new IllegalArgumentException("Invalid last stream id: " + lastStreamId); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/HeadersGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/HeadersGenerator.java index 0f6d94321b3..2db5c5de601 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/HeadersGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/HeadersGenerator.java @@ -50,13 +50,13 @@ public class HeadersGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { HeadersFrame headersFrame = (HeadersFrame)frame; return generateHeaders(lease, headersFrame.getStreamId(), headersFrame.getMetaData(), headersFrame.getPriority(), headersFrame.isEndStream()); } - public long generateHeaders(ByteBufferPool.Lease lease, int streamId, MetaData metaData, PriorityFrame priority, boolean endStream) + public int generateHeaders(ByteBufferPool.Lease lease, int streamId, MetaData metaData, PriorityFrame priority, boolean endStream) { if (streamId < 0) throw new IllegalArgumentException("Invalid stream id: " + streamId); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PingGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PingGenerator.java index a9452bea74e..8015bf11c01 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PingGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PingGenerator.java @@ -35,13 +35,13 @@ public class PingGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { PingFrame pingFrame = (PingFrame)frame; return generatePing(lease, pingFrame.getPayload(), pingFrame.isReply()); } - public long generatePing(ByteBufferPool.Lease lease, byte[] payload, boolean reply) + public int generatePing(ByteBufferPool.Lease lease, byte[] payload, boolean reply) { if (payload.length != PingFrame.PING_LENGTH) throw new IllegalArgumentException("Invalid payload length: " + payload.length); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PrefaceGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PrefaceGenerator.java index 9e01152ee7c..1e1490d202e 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PrefaceGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PrefaceGenerator.java @@ -32,7 +32,7 @@ public class PrefaceGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { lease.append(ByteBuffer.wrap(PrefaceFrame.PREFACE_BYTES), false); return PrefaceFrame.PREFACE_BYTES.length; diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PriorityGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PriorityGenerator.java index 23dfca7ca02..e7a53eb538e 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PriorityGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PriorityGenerator.java @@ -35,13 +35,13 @@ public class PriorityGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { PriorityFrame priorityFrame = (PriorityFrame)frame; return generatePriority(lease, priorityFrame.getStreamId(), priorityFrame.getParentStreamId(), priorityFrame.getWeight(), priorityFrame.isExclusive()); } - public long generatePriority(ByteBufferPool.Lease lease, int streamId, int parentStreamId, int weight, boolean exclusive) + public int generatePriority(ByteBufferPool.Lease lease, int streamId, int parentStreamId, int weight, boolean exclusive) { ByteBuffer header = generateHeader(lease, FrameType.PRIORITY, PriorityFrame.PRIORITY_LENGTH, Flags.NONE, streamId); generatePriorityBody(header, streamId, parentStreamId, weight, exclusive); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PushPromiseGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PushPromiseGenerator.java index 4063a15b074..5566fdd5df0 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PushPromiseGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/PushPromiseGenerator.java @@ -40,13 +40,13 @@ public class PushPromiseGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { PushPromiseFrame pushPromiseFrame = (PushPromiseFrame)frame; return generatePushPromise(lease, pushPromiseFrame.getStreamId(), pushPromiseFrame.getPromisedStreamId(), pushPromiseFrame.getMetaData()); } - public long generatePushPromise(ByteBufferPool.Lease lease, int streamId, int promisedStreamId, MetaData metaData) + public int generatePushPromise(ByteBufferPool.Lease lease, int streamId, int promisedStreamId, MetaData metaData) { if (streamId < 0) throw new IllegalArgumentException("Invalid stream id: " + streamId); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/ResetGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/ResetGenerator.java index c533c3bde39..0fcb05e2494 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/ResetGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/ResetGenerator.java @@ -35,13 +35,13 @@ public class ResetGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { ResetFrame resetFrame = (ResetFrame)frame; return generateReset(lease, resetFrame.getStreamId(), resetFrame.getError()); } - public long generateReset(ByteBufferPool.Lease lease, int streamId, int error) + public int generateReset(ByteBufferPool.Lease lease, int streamId, int error) { if (streamId < 0) throw new IllegalArgumentException("Invalid stream id: " + streamId); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/SettingsGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/SettingsGenerator.java index f0e3921f7c2..4dcd3dff359 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/SettingsGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/SettingsGenerator.java @@ -36,13 +36,13 @@ public class SettingsGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { SettingsFrame settingsFrame = (SettingsFrame)frame; return generateSettings(lease, settingsFrame.getSettings(), settingsFrame.isReply()); } - public long generateSettings(ByteBufferPool.Lease lease, Map settings, boolean reply) + public int generateSettings(ByteBufferPool.Lease lease, Map settings, boolean reply) { // Two bytes for the identifier, four bytes for the value. int entryLength = 2 + 4; diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/WindowUpdateGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/WindowUpdateGenerator.java index 1a7ec7fad3c..f9acca0f994 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/WindowUpdateGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/WindowUpdateGenerator.java @@ -35,13 +35,13 @@ public class WindowUpdateGenerator extends FrameGenerator } @Override - public long generate(ByteBufferPool.Lease lease, Frame frame) + public int generate(ByteBufferPool.Lease lease, Frame frame) { WindowUpdateFrame windowUpdateFrame = (WindowUpdateFrame)frame; return generateWindowUpdate(lease, windowUpdateFrame.getStreamId(), windowUpdateFrame.getWindowDelta()); } - public long generateWindowUpdate(ByteBufferPool.Lease lease, int streamId, int windowUpdate) + public int generateWindowUpdate(ByteBufferPool.Lease lease, int streamId, int windowUpdate) { if (windowUpdate < 0) throw new IllegalArgumentException("Invalid window update: " + windowUpdate);