camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1022687 - /camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
Date Thu, 14 Oct 2010 20:08:21 GMT
Author: davsclaus
Date: Thu Oct 14 20:08:20 2010
New Revision: 1022687

URL: http://svn.apache.org/viewvc?rev=1022687&view=rev
Log:
CAMEL-3223: Removed unnessasary convert to input stream when writing a file.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java?rev=1022687&r1=1022686&r2=1022687&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
Thu Oct 14 20:08:20 2010
@@ -197,40 +197,33 @@ public class GenericFileProducer<T> exte
     }
 
     public void writeFile(Exchange exchange, String fileName) throws GenericFileOperationFailedException
{
-        InputStream payload = exchange.getIn().getBody(InputStream.class);
-        try {
-            // build directory if auto create is enabled
-            if (endpoint.isAutoCreate()) {
-                // use java.io.File to compute the file path
-                File file = new File(fileName);
-                String directory = file.getParent();
-                boolean absolute = FileUtil.isAbsolute(file);
-                if (directory != null) {
-                    if (!operations.buildDirectory(directory, absolute)) {
-                        if (log.isDebugEnabled()) {
-                            log.debug("Cannot build directory [" + directory + "] (could
be because of denied permissions)");
-                        }
+        // build directory if auto create is enabled
+        if (endpoint.isAutoCreate()) {
+            // use java.io.File to compute the file path
+            File file = new File(fileName);
+            String directory = file.getParent();
+            boolean absolute = FileUtil.isAbsolute(file);
+            if (directory != null) {
+                if (!operations.buildDirectory(directory, absolute)) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Cannot build directory [" + directory + "] (could be because
of denied permissions)");
                     }
                 }
             }
+        }
 
-            // upload
-            if (log.isTraceEnabled()) {
-                log.trace("About to write [" + fileName + "] to [" + getEndpoint() + "] from
exchange [" + exchange + "]");
-            }
-
-            boolean success = operations.storeFile(fileName, exchange);
-            if (!success) {
-                throw new GenericFileOperationFailedException("Error writing file [" + fileName
+ "]");
-            }
-            if (log.isDebugEnabled()) {
-                log.debug("Wrote [" + fileName + "] to [" + getEndpoint() + "]");
-            }
-
-        } finally {
-            IOHelper.close(payload, "Closing payload", log);
+        // upload
+        if (log.isTraceEnabled()) {
+            log.trace("About to write [" + fileName + "] to [" + getEndpoint() + "] from
exchange [" + exchange + "]");
         }
 
+        boolean success = operations.storeFile(fileName, exchange);
+        if (!success) {
+            throw new GenericFileOperationFailedException("Error writing file [" + fileName
+ "]");
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("Wrote [" + fileName + "] to [" + getEndpoint() + "]");
+        }
     }
 
     public String createFileName(Exchange exchange) {



Mime
View raw message