Skip to content

Commit bace78e

Browse files
committed
bug fix and NEXT_COMPLETE support.
1 parent 114c86b commit bace78e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/main/java/io/reactivesocket/FrameFlyweight.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,17 @@ public FrameType frameType(final ByteBuffer byteBuffer)
142142
{
143143
frameBuffer.wrap(byteBuffer);
144144
FrameType result = FrameType.from(frameBuffer.getShort(TYPE_FIELD_OFFSET, ByteOrder.BIG_ENDIAN));
145+
final int dataLength = dataLength(byteBuffer, 0);
145146

146147
if (FrameType.RESPONSE == result)
147148
{
148149
final int flags = flags(byteBuffer);
149150

150-
if (FLAGS_C == (flags & FLAGS_C))
151+
if (FLAGS_C == (flags & FLAGS_C) && 0 < dataLength)
152+
{
153+
result = FrameType.NEXT_COMPLETE;
154+
}
155+
else if (FLAGS_C == (flags & FLAGS_C))
151156
{
152157
result = FrameType.COMPLETE;
153158
}
@@ -202,7 +207,7 @@ public static ByteBuffer slice(final ByteBuffer byteBuffer, final int position,
202207
final ByteBuffer result = byteBuffer.slice();
203208

204209
byteBuffer.limit(savedLimit).position(savedPosition);
205-
return byteBuffer.slice();
210+
return result;
206211
}
207212

208213
private void ensureByteArrayCapacity(final int length)

src/main/java/io/reactivesocket/FrameType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public enum FrameType
3333
ERROR(0x21),
3434
// synthetic types from Responder for use by the rest of the machinery
3535
NEXT(0x22),
36-
COMPLETE(0x23);
36+
COMPLETE(0x23),
37+
NEXT_COMPLETE(0x24);
3738

3839
private static FrameType[] typesById;
3940

src/test/java/io/reactivesocket/FrameTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void testWrapMessage() {
4545

4646
f.wrap(2, FrameType.COMPLETE, "done");
4747
assertEquals("done", f.getData());
48-
assertEquals(FrameType.COMPLETE, f.getType());
48+
assertEquals(FrameType.NEXT_COMPLETE, f.getType());
4949
assertEquals(2, f.getStreamId());
5050
}
5151

@@ -58,7 +58,7 @@ public void testWrapBytes() {
5858
f.wrap(b);
5959

6060
assertEquals("another", f.getData());
61-
assertEquals(FrameType.COMPLETE, f.getType());
61+
assertEquals(FrameType.NEXT_COMPLETE, f.getType());
6262
assertEquals(20, f.getStreamId());
6363
}
6464
}

0 commit comments

Comments
 (0)