camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject svn commit: r1465099 - in /camel/trunk/components/camel-aws/src: main/java/org/apache/camel/component/aws/s3/S3Producer.java test/java/org/apache/camel/component/aws/s3/S3ComponentFileTest.java
Date Fri, 05 Apr 2013 19:07:32 GMT
Author: bvahdat
Date: Fri Apr  5 19:07:32 2013
New Revision: 1465099

URL: http://svn.apache.org/r1465099
Log:
Close the InputStream properly in case the DeleteAfterWrite option is enabled. This fixes
the failed S3ComponentFileTest on Windows as well.

Modified:
    camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
    camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentFileTest.java

Modified: camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java?rev=1465099&r1=1465098&r2=1465099&view=diff
==============================================================================
--- camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
(original)
+++ camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
Fri Apr  5 19:07:32 2013
@@ -33,6 +33,7 @@ import org.apache.camel.InvalidPayloadEx
 import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.URISupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -132,6 +133,7 @@ public class S3Producer extends DefaultP
         }
 
         if (getConfiguration().isDeleteAfterWrite() && filePayload != null) {
+            IOHelper.close(putObjectRequest.getInputStream());
             FileUtil.deleteFile(filePayload);
         }
     }

Modified: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentFileTest.java?rev=1465099&r1=1465098&r2=1465099&view=diff
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentFileTest.java
(original)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentFileTest.java
Fri Apr  5 19:07:32 2013
@@ -118,7 +118,12 @@ public class S3ComponentFileTest extends
 
     private void assertResultExchange(Exchange resultExchange) {
         assertIsInstanceOf(InputStream.class, resultExchange.getIn().getBody());
-        assertEquals("This is my bucket content.", resultExchange.getIn().getBody(String.class));
+
+        if (!"sendFileAndDelete".equals(getTestMethodName())) {
+            // as we delete the file using the "deleteAfterWrite=true" option here we can
not assert on it's content anymore
+            assertEquals("This is my bucket content.", resultExchange.getIn().getBody(String.class));
+        }
+
         assertEquals("mycamelbucket", resultExchange.getIn().getHeader(S3Constants.BUCKET_NAME));
         assertEquals("CamelUnitTest", resultExchange.getIn().getHeader(S3Constants.KEY));
         assertNull(resultExchange.getIn().getHeader(S3Constants.VERSION_ID)); // not enabled
on this bucket



Mime
View raw message