You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ha...@apache.org on 2008/02/28 16:22:12 UTC

svn commit: r632001 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/processor/ components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/

Author: hadrian
Date: Thu Feb 28 07:22:03 2008
New Revision: 632001

URL: http://svn.apache.org/viewvc?rev=632001&view=rev
Log:
CAMEL315.  Patches applied with thanks!

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnmarshalProcessor.java
    activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpProducer.java
    activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpProducer.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnmarshalProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnmarshalProcessor.java?rev=632001&r1=632000&r2=632001&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnmarshalProcessor.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnmarshalProcessor.java Thu Feb 28 07:22:03 2008
@@ -40,13 +40,20 @@
 
     public void process(Exchange exchange) throws Exception {
         InputStream stream = ExchangeHelper.getMandatoryInBody(exchange, InputStream.class);
+        try {
 
-        // lets setup the out message before we invoke the dataFormat
-        // so that it can mutate it if necessary
-        Message out = exchange.getOut(true);
-        out.copyFrom(exchange.getIn());
-
-        Object result = dataFormat.unmarshal(exchange, stream);
-        out.setBody(result);
+            // lets setup the out message before we invoke the dataFormat
+            // so that it can mutate it if necessary
+            Message out = exchange.getOut(true);
+            out.copyFrom(exchange.getIn());
+    
+            Object result = dataFormat.unmarshal(exchange, stream);
+            out.setBody(result);
+        }
+        finally {
+            if (null != stream) {
+                stream.close();
+            }
+        }
     }
 }

Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpProducer.java?rev=632001&r1=632000&r2=632001&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpProducer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpProducer.java Thu Feb 28 07:22:03 2008
@@ -78,24 +78,31 @@
 
     public void process(RemoteFileExchange exchange) throws Exception {
         InputStream payload = exchange.getIn().getBody(InputStream.class);
-        String fileName = createFileName(exchange.getIn(), endpoint.getConfiguration());
-        
-        int lastPathIndex = fileName.lastIndexOf('/');
-        if (lastPathIndex != -1)
-        {
-            String directory = fileName.substring(0, lastPathIndex);
-            if (!buildDirectory(client, directory)) {
-                LOG.warn("Couldn't buildDirectory: " + directory + " (either permissions deny it, or it already exists)");
+        try {
+            String fileName = createFileName(exchange.getIn(), endpoint.getConfiguration());
+            
+            int lastPathIndex = fileName.lastIndexOf('/');
+            if (lastPathIndex != -1)
+            {
+                String directory = fileName.substring(0, lastPathIndex);
+                if (!buildDirectory(client, directory)) {
+                    LOG.warn("Couldn't buildDirectory: " + directory + " (either permissions deny it, or it already exists)");
+                }
             }
+            
+            final boolean success = client.storeFile(fileName, payload);
+            if (!success) {
+                throw new RuntimeCamelException("error sending file");
+            }
+            
+            RemoteFileConfiguration config = endpoint.getConfiguration();
+            LOG.info("Sent: " + fileName + " to " + config.toString().substring(0, config.toString().indexOf(config.getFile())));
         }
-        
-        final boolean success = client.storeFile(fileName, payload);
-        if (!success) {
-            throw new RuntimeCamelException("error sending file");
+        finally {
+            if (null != payload) {
+                payload.close();
+            }
         }
-        
-        RemoteFileConfiguration config = endpoint.getConfiguration();
-        LOG.info("Sent: " + fileName + " to " + config.toString().substring(0, config.toString().indexOf(config.getFile())));
     }
 
     @Override

Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpProducer.java?rev=632001&r1=632000&r2=632001&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpProducer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpProducer.java Thu Feb 28 07:22:03 2008
@@ -95,20 +95,26 @@
 
     public void process(RemoteFileExchange exchange) throws Exception {
         InputStream payload = exchange.getIn().getBody(InputStream.class);
-        
-        String fileName = createFileName(exchange.getIn(), endpoint.getConfiguration());
-        
-        int lastPathIndex = fileName.lastIndexOf('/');
-        if (lastPathIndex != -1)
-        {
-            boolean success = buildDirectory(channel, fileName.substring(0, lastPathIndex));
-            if (!success) {
-                LOG.warn("Couldn't buildDirectory: " + fileName.substring(0, lastPathIndex) + " (either permissions deny it, or it already exists)");
+        try {
+            String fileName = createFileName(exchange.getIn(), endpoint.getConfiguration());
+            
+            int lastPathIndex = fileName.lastIndexOf('/');
+            if (lastPathIndex != -1)
+            {
+                boolean success = buildDirectory(channel, fileName.substring(0, lastPathIndex));
+                if (!success) {
+                    LOG.warn("Couldn't buildDirectory: " + fileName.substring(0, lastPathIndex) + " (either permissions deny it, or it already exists)");
+                }
+            }
+            
+            channel.put(payload, fileName);
+            LOG.info("Sent: " + fileName + " to " + endpoint.getConfiguration());
+        }
+        finally {
+            if (null != payload) {
+                payload.close();
             }
         }
-        
-        channel.put(payload, fileName);
-        LOG.info("Sent: " + fileName + " to " + endpoint.getConfiguration());
     }
 
     @Override