You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/07/11 16:33:06 UTC
svn commit: r1360201 - in /cxf/branches/2.4.x-fixes/rt/core/src:
main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
Author: dkulp
Date: Wed Jul 11 14:33:05 2012
New Revision: 1360201
URL: http://svn.apache.org/viewvc?rev=1360201&view=rev
Log:
Merged revisions 1360196 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes
........
r1360196 | dkulp | 2012-07-11 10:30:33 -0400 (Wed, 11 Jul 2012) | 19 lines
Merged revisions 1360193 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes
........
r1360193 | dkulp | 2012-07-11 10:29:13 -0400 (Wed, 11 Jul 2012) | 11 lines
Merged revisions 1360188 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1360188 | dkulp | 2012-07-11 10:25:36 -0400 (Wed, 11 Jul 2012) | 3 lines
[CXF-4417] Fix problem of not throwing rejectedexecutionexception if
runnable was not enqueued.
........
........
........
Modified:
cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java?rev=1360201&r1=1360200&r2=1360201&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java (original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java Wed Jul 11 14:33:05 2012
@@ -391,9 +391,11 @@ public class AutomaticWorkQueueImpl exte
execute(work);
} catch (RejectedExecutionException ree) {
try {
- getQueue().offer(work, timeout, TimeUnit.MILLISECONDS);
+ if (!getQueue().offer(work, timeout, TimeUnit.MILLISECONDS)) {
+ throw ree;
+ }
} catch (InterruptedException ie) {
- throw new RejectedExecutionException(ie);
+ throw ree;
}
}
}
Modified: cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java?rev=1360201&r1=1360200&r2=1360201&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java (original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java Wed Jul 11 14:33:05 2012
@@ -77,6 +77,35 @@ public class AutomaticWorkQueueTest exte
assertEquals(DEFAULT_LOW_WATER_MARK, workqueue.getLowWaterMark());
}
+
+ @Test
+ public void testEnqueueWithTimeout() throws Exception {
+ workqueue = new AutomaticWorkQueueImpl(2, 2,
+ 2,
+ 2,
+ DEFAULT_DEQUEUE_TIMEOUT);
+
+ final Object lock = new Object();
+ int x = 0;
+ try {
+ synchronized (lock) {
+ for (x = 0; x < 6; x++) {
+ workqueue.execute(new Runnable() {
+ public void run() {
+ synchronized (lock) {
+ //just need to wait until all the runnables are created and enqueued and such.
+ }
+ }
+ }, 50);
+ }
+ }
+ fail("Should have failed with a RejectedExecutionException as 5th should not be queuable");
+ } catch (RejectedExecutionException rex) {
+ assertEquals(x, 4);
+ }
+ }
+
+
@Test
public void testEnqueue() {
workqueue = new AutomaticWorkQueueImpl(DEFAULT_MAX_QUEUE_SIZE, INITIAL_SIZE,