You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/07/11 10:24:07 UTC

[1/2] git commit: CAMEL-5883 fixed the issue of dynamic done file name

Updated Branches:
  refs/heads/camel-2.10.x fbc3edbde -> 3a855011c


CAMEL-5883 fixed the issue of dynamic done file name


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9bca801e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9bca801e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9bca801e

Branch: refs/heads/camel-2.10.x
Commit: 9bca801eb7488d1ec44ff8d0e92a944ffafe053e
Parents: fbc3edb
Author: Willem Jiang <ni...@apache.org>
Authored: Thu Jul 11 14:40:01 2013 +0800
Committer: Willem Jiang <ni...@apache.org>
Committed: Thu Jul 11 16:18:37 2013 +0800

----------------------------------------------------------------------
 .../component/file/GenericFileOnCompletion.java | 22 ++++++------
 .../file/FileConsumeDoneFileIssueTest.java      | 35 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9bca801e/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOnCompletion.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOnCompletion.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOnCompletion.java
index bdbab97..c2ebb4e 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOnCompletion.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOnCompletion.java
@@ -112,20 +112,22 @@ public class GenericFileOnCompletion<T> implements Synchronization {
         // must be last in batch to delete the done file name
         // delete done file if used (and not noop=true)
         boolean complete = exchange.getProperty(Exchange.BATCH_COMPLETE, false, Boolean.class);
-        if (endpoint.getDoneFileName() != null && !endpoint.isNoop() && complete) {
+        if (endpoint.getDoneFileName() != null && !endpoint.isNoop()) {
             // done file must be in same path as the original input file
             String doneFileName = endpoint.createDoneFileName(absoluteFileName);
             ObjectHelper.notEmpty(doneFileName, "doneFileName", endpoint);
-
-            try {
-                // delete done file
-                boolean deleted = operations.deleteFile(doneFileName);
-                log.trace("Done file: {} was deleted: {}", doneFileName, deleted);
-                if (!deleted) {
-                    log.warn("Done file: " + doneFileName + " could not be deleted");
+            // we should delete the dynamic done file 
+            if (endpoint.getDoneFileName().indexOf("{file:name") > 0 || complete) { 
+                try {
+                    // delete done file
+                    boolean deleted = operations.deleteFile(doneFileName);
+                    log.trace("Done file: {} was deleted: {}", doneFileName, deleted);
+                    if (!deleted) {
+                        log.warn("Done file: " + doneFileName + " could not be deleted");
+                    }
+                } catch (Exception e) {
+                    handleException(e);
                 }
-            } catch (Exception e) {
-                handleException(e);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9bca801e/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDoneFileIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDoneFileIssueTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDoneFileIssueTest.java
index e26d281..d57781a 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDoneFileIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDoneFileIssueTest.java
@@ -59,6 +59,36 @@ public class FileConsumeDoneFileIssueTest extends ContextTestSupport {
         // the done file should be deleted
         assertFalse("Done file should be deleted", new File("target/done/foo.done").exists());
     }
+    
+    public void testFileConsumseDynamicDoneFileName() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();
+
+        template.sendBodyAndHeader("file:target/done2", "A", Exchange.FILE_NAME, "a.txt");
+        template.sendBodyAndHeader("file:target/done2", "B", Exchange.FILE_NAME, "b.txt");
+        template.sendBodyAndHeader("file:target/done2", "C", Exchange.FILE_NAME, "c.txt");
+        template.sendBodyAndHeader("file:target/done2", "a", Exchange.FILE_NAME, "a.txt.done");
+        template.sendBodyAndHeader("file:target/done2", "b", Exchange.FILE_NAME, "b.txt.done");
+        template.sendBodyAndHeader("file:target/done2", "c", Exchange.FILE_NAME, "c.txt.done");
+        
+        assertTrue("Done file should exists", new File("target/done2/a.txt.done").exists());
+        assertTrue("Done file should exists", new File("target/done2/b.txt.done").exists());
+        assertTrue("Done file should exists", new File("target/done2/c.txt.done").exists());
+
+        getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("A", "B", "C");
+
+        context.startRoute("bar");
+
+        assertMockEndpointsSatisfied();
+        assertTrue(notify.matchesMockWaitTime());
+
+        Thread.sleep(250);
+
+        // the done file should be deleted
+        assertFalse("Done file should be deleted", new File("target/done2/a.txt.done").exists());
+        assertFalse("Done file should be deleted", new File("target/done2/b.txt.done").exists());
+        assertFalse("Done file should be deleted", new File("target/done2/c.txt.done").exists());
+        
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -68,6 +98,11 @@ public class FileConsumeDoneFileIssueTest extends ContextTestSupport {
                 from("file:target/done?doneFileName=foo.done").routeId("foo").noAutoStartup()
                     .convertBodyTo(String.class)
                     .to("mock:result");
+                
+                from("file:target/done2?doneFileName=${file:name}.done")
+                    .routeId("bar").noAutoStartup()
+                    .convertBodyTo(String.class)
+                    .to("mock:result");
             }
         };
     }


[2/2] git commit: CAMEL-6521: Fixed the failed build when Java 6 is in use.

Posted by ni...@apache.org.
CAMEL-6521: Fixed the failed build when Java 6 is in use.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3a855011
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3a855011
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3a855011

Branch: refs/heads/camel-2.10.x
Commit: 3a855011c284ca0183e8776b81189869a984aebf
Parents: 9bca801
Author: Babak Vahdat <bv...@apache.org>
Authored: Tue Jul 9 15:49:34 2013 +0200
Committer: Willem Jiang <ni...@apache.org>
Committed: Thu Jul 11 16:22:25 2013 +0800

----------------------------------------------------------------------
 .../org/apache/camel/impl/ActiveMQUuidGenerator.java   | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3a855011/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java b/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
index 297860c..3afe604 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.impl;
 
+import java.io.IOException;
 import java.net.ServerSocket;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.camel.spi.UuidGenerator;
-import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.InetAddressUtil;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
@@ -78,7 +78,16 @@ public class ActiveMQUuidGenerator implements UuidGenerator {
                     LOG.warn("Cannot generate unique stub by using DNS and binding to local port: " + idGeneratorPort + " due " + ioe.getMessage());
                 }
             } finally {
-                IOHelper.close(ss);
+                try {
+                    // TODO: replace the following line with IOHelper.close(ss) when Java 6 support is dropped
+                    ss.close();
+                } catch (IOException ioe) {
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("Closing the server socket failed", ioe);
+                    } else {
+                        LOG.warn("Closing the server socket failed" + " due " + ioe.getMessage());
+                    }
+                }
             }
         }