Alon Bar-Lev has uploaded a new change for review.

Change subject: utils: cleanup: TarTest: File.getParent() may return null
......................................................................

utils: cleanup: TarTest: File.getParent() may return null

unlikely in this context, but make coverity happy.

Change-Id: Id4b0c1a9b5a8a7ab024c8065cbdf237b964bde9d
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M 
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/archivers/tar/TarTest.java
1 file changed, 6 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/19241/1

diff --git 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/archivers/tar/TarTest.java
 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/archivers/tar/TarTest.java
index da965c1..5e53dbd 100644
--- 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/archivers/tar/TarTest.java
+++ 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/archivers/tar/TarTest.java
@@ -22,22 +22,14 @@
 public class TarTest {
 
     private void _writeFile(File file, String content, boolean executable) 
throws IOException {
-        OutputStream os = null;
-        try {
-            file.getParentFile().mkdirs();
-            os = new FileOutputStream(file);
+        File f = file.getParentFile();
+        if (f == null) {
+            throw new IOException("File not found " + f);
+        }
+        f.mkdirs();
+        try (OutputStream os = new FileOutputStream(file)) {
             os.write(content.getBytes("UTF-8"));
             file.setExecutable(executable);
-        }
-        finally {
-            if (os != null) {
-                try {
-                    os.close();
-                }
-                catch (IOException e) {
-                    // ignore
-                }
-            }
         }
     }
 


-- 
To view, visit http://gerrit.ovirt.org/19241
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id4b0c1a9b5a8a7ab024c8065cbdf237b964bde9d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to