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

Change subject: utils: ssh: move transfer test to try with resources
......................................................................

utils: ssh: move transfer test to try with resources

Change-Id: If11e822c8cdc17791062d4d0bec318e4c7452cb9
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M 
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ssh/TransferTest.java
1 file changed, 7 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/40/19240/1

diff --git 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ssh/TransferTest.java
 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ssh/TransferTest.java
index d7672b9..272a29f 100644
--- 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ssh/TransferTest.java
+++ 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ssh/TransferTest.java
@@ -38,21 +38,11 @@
         catch(NoSuchAlgorithmException e) {
             throw new RuntimeException(e);
         }
-        InputStream is = null;
-        try {
-            is = new FileInputStream(file);
+        try (InputStream is =  new FileInputStream(file)) {
             byte buffer[] = new byte[1024];
             int n;
             while ((n = is.read(buffer)) != -1) {
                 digest.update(buffer, 0, n);
-            }
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException e) {
-                    // ignore
-                }
             }
         }
         return digest.digest();
@@ -72,13 +62,13 @@
         catch(NoSuchAlgorithmException e) {
             throw new RuntimeException(e);
         }
-        OutputStream os = new FileOutputStream(local1);
-        byte buffer[] = new byte[1000];
-        for (long i=0;i<TestCommon.largeTestFileSize / buffer.length;i++) {
-            random.nextBytes(buffer);
-            os.write(buffer);
+        try (OutputStream os = new FileOutputStream(local1)) {
+            byte buffer[] = new byte[1000];
+            for (long i=0;i<TestCommon.largeTestFileSize / buffer.length;i++) {
+                random.nextBytes(buffer);
+                os.write(buffer);
+            }
         }
-        os.close();
     }
 
     @AfterClass


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If11e822c8cdc17791062d4d0bec318e4c7452cb9
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