Skip to content

Commit

Permalink
FastInfosetTest.fastInfoset fails intemittently, fix #1636
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Jan 30, 2025
1 parent 670a26e commit fca9d3e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ public int read() throws IOException {

@Override
public int read(byte b[], final int off, int len) throws IOException {
// Log.infof("Ready to read up to %d bytes", len);
// log.tracef("Ready to read up to %d bytes", len);
Buffer rb = takeBuffer(true);
if (rb == null) {
// log.trace("Nothing more to read");
Expand Down Expand Up @@ -1633,7 +1633,7 @@ private void freeReadBufferIfNeeded() {
public void close() {
// log.trace("Closing reader");
// log.tracef("Closing reader: got %d bytes in %d reads", bytesRead, readCounter);
readBuffer = null;
freeReadBufferIfNeeded();
// assert queueEmpty() : "Queue still has " + queue.size() + " items";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,26 @@ void twoBuffers() throws IOException {
}
}

@Test
void readAfterClose() throws IOException {
ContextInternal ctx = (ContextInternal) Vertx.vertx().getOrCreateContext();
InputStreamWriteStream ws = new InputStreamWriteStream(ctx, 2);
final String INPUT1 = "abcd";
final String INPUT2 = "efgh";
final String INPUT3 = "ijkl";
ws.write(Buffer.buffer(INPUT1));
ws.write(Buffer.buffer(INPUT2));
ws.write(Buffer.buffer(INPUT3));
ws.end();
byte[] arr = new byte[12];
Assertions.assertThat(ws.read(arr)).isEqualTo(12);
Assertions.assertThat(arr).isEqualTo((INPUT1 + INPUT2 + INPUT3).getBytes(StandardCharsets.UTF_8));
Assertions.assertThat(ws.read(arr)).isEqualTo(-1);
ws.close();
Assertions.assertThat(ws.read(arr)).isEqualTo(-1);
ws.close();
}

@Test
void threeBuffers() throws IOException {

Expand Down

0 comments on commit fca9d3e

Please sign in to comment.