Skip to content

Commit

Permalink
Fix flaky `testUploadWithPendingReadConcurrentServerCloseClosesStream…
Browse files Browse the repository at this point in the history
…()` (#11693)

* #11692 fix flaky testUploadWithPendingReadConcurrentServerCloseClosesStream()

Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban authored May 2, 2024
1 parent 45e474b commit cfee4fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
16 changes: 16 additions & 0 deletions jetty-core/jetty-tests/jetty-test-client-transports/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@
</plugins>
</build>
</profile>
<profile>
<id>enable-foreign</id>
<activation>
<jdk>[22,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} ${jetty.surefire.argLine} --enable-native-access=ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -1063,9 +1063,7 @@ public void close() throws IOException
@MethodSource("transports")
public void testUploadWithPendingReadConcurrentServerCloseClosesStream(Transport transport) throws Exception
{
CountDownLatch serverDemandLatch = new CountDownLatch(1);
CountDownLatch serverLatch = new CountDownLatch(1);
AtomicReference<Content.Chunk> lastChunk = new AtomicReference<>();
start(transport, new Handler.Abstract()
{
@Override
Expand All @@ -1076,16 +1074,14 @@ public boolean handle(Request request, org.eclipse.jetty.server.Response respons
@Override
public void run()
{
// With H2, once the connector is stopping, there is no guarantee that the demand will be serviced
// as the execution strategy is busy shutting down but is needed to run the dispatched thread that
// services the demand; so we cannot expect that a last chunk will be read here.
Content.Chunk chunk = request.read();
if (chunk != null)
chunk.release();
if (chunk == null || !chunk.isLast())
{
request.demand(this);
return;
}
lastChunk.set(chunk);
serverDemandLatch.countDown();
}
});
serverLatch.countDown();
Expand Down Expand Up @@ -1149,9 +1145,6 @@ public void close() throws IOException

assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
assertTrue(closeLatch.await(5, TimeUnit.SECONDS));
assertTrue(serverDemandLatch.await(5, TimeUnit.SECONDS));
assertTrue(Content.Chunk.isFailure(lastChunk.get(), true));
assertInstanceOf(IOException.class, lastChunk.get().getFailure());
}

@ParameterizedTest
Expand Down

0 comments on commit cfee4fe

Please sign in to comment.