Author: sergeyb
Date: Mon Nov 12 14:03:53 2012
New Revision: 1408293
URL: http://svn.apache.org/viewvc?rev=1408293&view=rev
Log:
Fixing time unit conversion bug reported by gpasquiers in AsyncResponseImpl,
updating TimeoutHandler test to do multiple timeouts
Modified:
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
Modified:
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java?rev=1408293&r1=1408292&r2=1408293&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
(original)
+++
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
Mon Nov 12 14:03:53 2012
@@ -124,7 +124,7 @@ public class AsyncResponseImpl implement
checkCancelled();
checkSuspended();
inMessage.getExchange().put(AsyncResponse.class, this);
- timeout = unit.convert(time, TimeUnit.MILLISECONDS);
+ timeout = TimeUnit.MILLISECONDS.convert(time, unit);
newTimeoutRequested = true;
cont.resume();
}
Modified:
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java?rev=1408293&r1=1408292&r2=1408293&view=diff
==============================================================================
---
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
(original)
+++
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
Mon Nov 12 14:03:53 2012
@@ -26,6 +26,7 @@ import java.util.concurrent.ArrayBlockin
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -106,6 +107,7 @@ public class BookContinuationStore {
private class TimeoutHandlerImpl implements TimeoutHandler {
private String id;
+ private AtomicInteger timeoutExtendedCounter = new AtomicInteger();
public TimeoutHandlerImpl(String id) {
this.id = id;
@@ -113,7 +115,11 @@ public class BookContinuationStore {
@Override
public void handleTimeout(AsyncResponse asyncResponse) {
- asyncResponse.resume(books.get(id));
+ if (timeoutExtendedCounter.addAndGet(1) < 2) {
+ asyncResponse.setTimeout(1, TimeUnit.SECONDS);
+ } else {
+ asyncResponse.resume(books.get(id));
+ }
}
}