Skip to content
Permalink
Browse files
CXF-8650: Fix org.apache.cxf.systest.jaxrs.JAXRSContinuationsServlet3…
…Test.testSuspendSetTimeout (#897)
  • Loading branch information
reta committed Feb 1, 2022
1 parent 71e7c2b commit 452623776ba494624a0cf0031ca40ad195e898e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
@@ -19,15 +19,17 @@
package org.apache.cxf.systest.jaxrs;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

import javax.ws.rs.GET;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.Path;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;

@Path("resource2")
public class AsyncResource2 {
static AsyncResponse asyncResponse;
private volatile AsyncResponse asyncResponse;

@GET
@Path("/suspend")
@@ -38,7 +40,15 @@ public void getSuspendResponse(@Suspended AsyncResponse async) {
@GET
@Path("/setTimeOut")
public boolean setTimeOut() {
int i = 0;
while (asyncResponse == null && ++i < 20) {
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
}

if (asyncResponse == null) {
throw new InternalServerErrorException("Unable to retrieve the AsyncResponse, was it suspended?");
}

return asyncResponse.setTimeout(2L, TimeUnit.SECONDS);
}

}
@@ -87,7 +87,6 @@ public void testLostThrowFromSuspendedCall() throws Exception {
}

@Test
// FIXME: standalone test run failed, eg -Dtest=JAXRSContinuationsServlet3Test#testSuspendSetTimeout
public void testSuspendSetTimeout() throws Exception {
final String base = "http://localhost:" + getPort() + "/async/resource2/";
Future<Response> suspend = invokeRequest(base + "suspend");

0 comments on commit 4526237

Please sign in to comment.