Skip to content

Commit

Permalink
fix #4885: addressing a potential hang with jdk streams
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins authored and manusa committed Feb 16, 2023
1 parent 90d8acc commit fb158cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Fix #4818: [java-generator] Escape `*/` in generated JavaDocs
* Fix #4823: (java-generator) handle special characters in field names
* Fix #4723: [java-generator] Fix a race in the use of JavaParser hitting large CRDs
* Fix #4885: addresses a potential hang in the jdk client with exec stream reading

#### Improvements
* Fix #3805: DeletionTimestamp and Finalizer support in Mock server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private ByteBuffer current() throws IOException {

currentBuffer = buffers.poll();

if (currentBuffer == null) {
if (currentBuffer == null && !complete) {
try {
buffers.wait();
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -85,4 +86,15 @@ void testConsume() throws IOException {
readFuture.join();
}

@Test
void testCompleteInlineWithRequestMore() throws IOException {
AtomicReference<ExecWatchInputStream> is = new AtomicReference<>();
ExecWatchInputStream execWatchInputStream = new ExecWatchInputStream(() -> is.get().onExit(0, null));
is.set(execWatchInputStream);
// the first consume is implicit
execWatchInputStream.consume(Collections.singletonList(ByteBuffer.allocate(1)));
is.get().read();
Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() -> execWatchInputStream.read() == -1);
}

}

0 comments on commit fb158cf

Please sign in to comment.