brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [2/3] brooklyn-server git commit: Sync before close
Date Mon, 11 Sep 2017 08:21:01 GMT
Sync before close


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

Branch: refs/heads/master
Commit: c5cbc0843d9635072d09379ed053968a2e670387
Parents: 9fe0179
Author: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Authored: Fri Sep 8 10:21:25 2017 +0100
Committer: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Committed: Fri Sep 8 10:21:25 2017 +0100

----------------------------------------------------------------------
 .../core/mgmt/persist/FileBasedStoreObjectAccessor.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5cbc084/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessor.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessor.java
index 6a3de10..9387fe3 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessor.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessor.java
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.FileDescriptor;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.SyncFailedException;
 import java.util.Date;
 
@@ -90,8 +91,15 @@ public class FileBasedStoreObjectAccessor implements PersistenceObjectStore.Stor
         try {
             FileUtil.setFilePermissionsTo600(tmpFile);
             final FileOutputStream tempStream = new FileOutputStream(tmpFile);
-            Streams.copyClose(bytes.openStream(), tempStream);
-            syncFileSystem(tempStream.getFD());
+            final InputStream byteStream = bytes.openStream();
+            try {
+                Streams.copy(byteStream, tempStream);
+                syncFileSystem(tempStream.getFD());
+            } finally {
+                Streams.closeQuietly(byteStream);
+                Streams.closeQuietly(tempStream);
+            }
+
             FileBasedObjectStore.moveFile(tmpFile, file);
         } catch (IOException e) {
             throw Exceptions.propagateAnnotated("Problem writing data to file "+file+" (via
temporary file "+tmpFile+")", e);


Mime
View raw message