cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1360193 - in /cxf/branches/2.6.x-fixes/api/src: main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
Date Wed, 11 Jul 2012 14:29:13 GMT
Author: dkulp
Date: Wed Jul 11 14:29:13 2012
New Revision: 1360193

URL: http://svn.apache.org/viewvc?rev=1360193&view=rev
Log:
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.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
    cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java?rev=1360193&r1=1360192&r2=1360193&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
Wed Jul 11 14:29:13 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.6.x-fixes/api/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java?rev=1360193&r1=1360192&r2=1360193&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
Wed Jul 11 14:29:13 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,



Mime
View raw message