Author: dkulp Date: Wed Jul 11 14:30:33 2012 New Revision: 1360196 URL: http://svn.apache.org/viewvc?rev=1360196&view=rev Log: 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.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java cxf/branches/2.5.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java Modified: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java?rev=1360196&r1=1360195&r2=1360196&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java (original) +++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java Wed Jul 11 14:30:33 2012 @@ -435,9 +435,11 @@ public class AutomaticWorkQueueImpl impl execute(work); } catch (RejectedExecutionException ree) { try { - getExecutor().getQueue().offer(work, timeout, TimeUnit.MILLISECONDS); + if (!getExecutor().getQueue().offer(work, timeout, TimeUnit.MILLISECONDS)) { + throw ree; + } } catch (InterruptedException ie) { - throw new RejectedExecutionException(ie); + throw ree; } } } Modified: cxf/branches/2.5.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java?rev=1360196&r1=1360195&r2=1360196&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java (original) +++ cxf/branches/2.5.x-fixes/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java Wed Jul 11 14:30:33 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,
