cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From santhosheduku...@apache.org
Subject git commit: updated refs/heads/master to c2c63ff
Date Fri, 25 Jul 2014 11:43:48 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master cd67db395 -> c2c63ffd6


Fixed Coverity Issue


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

Branch: refs/heads/master
Commit: c2c63ffd613649a18df6703d4f46ccf8619aa8a1
Parents: cd67db3
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Fri Jul 25 17:12:46 2014 +0530
Committer: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Committed: Fri Jul 25 17:12:46 2014 +0530

----------------------------------------------------------------------
 .../bridge/io/S3FileSystemBucketAdapter.java    | 47 +++++++++++---------
 1 file changed, 25 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2c63ffd/awsapi/src/com/cloud/bridge/io/S3FileSystemBucketAdapter.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/io/S3FileSystemBucketAdapter.java b/awsapi/src/com/cloud/bridge/io/S3FileSystemBucketAdapter.java
index 85d1e0e..a0834c2 100644
--- a/awsapi/src/com/cloud/bridge/io/S3FileSystemBucketAdapter.java
+++ b/awsapi/src/com/cloud/bridge/io/S3FileSystemBucketAdapter.java
@@ -152,30 +152,33 @@ public class S3FileSystemBucketAdapter implements S3BucketAdapter {
             file.delete();
             file.createNewFile();
 
-            final FileOutputStream fos = new FileOutputStream(file);
-            byte[] buffer = new byte[4096];
-
-            // -> get the input stream for the next file part
-            for (int i = 0; i < parts.length; i++) {
-                DataHandler nextPart = loadObject(mountedRoot, sourceBucket, parts[i].getPath());
-                InputStream is = nextPart.getInputStream();
-
-                int len = 0;
-                while ((len = is.read(buffer)) > 0) {
-                    fos.write(buffer, 0, len);
-                    md5.update(buffer, 0, len);
-                    totalLength += len;
-                }
-                is.close();
-
-                // -> after each file write tell the client we are still here to keep
connection alive
-                if (null != client) {
-                    client.write(new String(" ").getBytes());
-                    client.flush();
+            try(final FileOutputStream fos = new FileOutputStream(file);) {
+                byte[] buffer = new byte[4096];
+
+                // -> get the input stream for the next file part
+                for (int i = 0; i < parts.length; i++) {
+                    DataHandler nextPart = loadObject(mountedRoot, sourceBucket, parts[i].getPath());
+                    InputStream is = nextPart.getInputStream();
+
+                    int len = 0;
+                    while ((len = is.read(buffer)) > 0) {
+                        fos.write(buffer, 0, len);
+                        md5.update(buffer, 0, len);
+                        totalLength += len;
+                    }
+                    is.close();
+
+                    // -> after each file write tell the client we are still here to keep
connection alive
+                    if (null != client) {
+                        client.write(new String(" ").getBytes());
+                        client.flush();
+                    }
                 }
+                return new OrderedPair<String, Long>(StringHelper.toHexString(md5.digest()),
new Long(totalLength));
+            }catch (IOException e) {
+                logger.error("concatentateObjects unexpected exception " + e.getMessage(),
e);
+                throw new OutOfStorageException(e);
             }
-            fos.close();
-            return new OrderedPair<String, Long>(StringHelper.toHexString(md5.digest()),
new Long(totalLength));
             //Create an ordered pair whose first element is the MD4 digest as a (lowercase)
hex String
         } catch (IOException e) {
             logger.error("concatentateObjects unexpected exception " + e.getMessage(), e);


Mime
View raw message