ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaiki...@apache.org
Subject [1/2] ant-ivy git commit: refactoring and suppressed warnings fixes
Date Thu, 31 Aug 2017 12:43:04 GMT
Repository: ant-ivy
Updated Branches:
  refs/heads/master 37f70ab67 -> cc7509b75


refactoring and suppressed warnings fixes

Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/08fc7320
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/08fc7320
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/08fc7320

Branch: refs/heads/master
Commit: 08fc7320de07cc41318fc7505a2f3ccc2a6b04d4
Parents: 37f70ab
Author: twogee <g.grigelionis@gmail.com>
Authored: Mon Aug 7 18:13:23 2017 +0200
Committer: Jaikiran Pai <jaikiran@apache.org>
Committed: Thu Aug 31 18:09:18 2017 +0530

----------------------------------------------------------------------
 src/java/org/apache/ivy/osgi/core/ManifestParser.java |  2 +-
 .../org/apache/ivy/plugins/repository/ssh/Scp.java    | 12 +-----------
 .../java/org/apache/ivy/osgi/obr/OBRResolverTest.java | 14 ++++++++------
 3 files changed, 10 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/08fc7320/src/java/org/apache/ivy/osgi/core/ManifestParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/core/ManifestParser.java b/src/java/org/apache/ivy/osgi/core/ManifestParser.java
index c07596f..8125a66 100644
--- a/src/java/org/apache/ivy/osgi/core/ManifestParser.java
+++ b/src/java/org/apache/ivy/osgi/core/ManifestParser.java
@@ -75,9 +75,9 @@ public class ManifestParser {
 
     public static BundleInfo parseJarManifest(InputStream jarStream) throws IOException,
             ParseException {
-    @SuppressWarnings("resource")
         JarInputStream jis = new JarInputStream(jarStream);
         Manifest manifest = jis.getManifest();
+        jis.close();
         if (manifest == null) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/08fc7320/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java b/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
index 0723e25..cd278fe 100644
--- a/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
+++ b/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
@@ -275,7 +275,6 @@ public class Scp {
         fileInfo.setLastModified(modtime);
     }
 
-    @SuppressWarnings("resource")
     private void sendFile(Channel channel, String localFile, String remoteName, String mode)
             throws IOException, RemoteScpException {
         byte[] buffer = new byte[BUFFER_SIZE];
@@ -310,11 +309,7 @@ public class Scp {
 
         readResponse(is);
 
-        FileInputStream fis = null;
-
-        try {
-            fis = new FileInputStream(f);
-
+        try (FileInputStream fis = new FileInputStream(f)) {
             while (remain > 0) {
                 int trans;
                 if (remain > buffer.length) {
@@ -332,11 +327,6 @@ public class Scp {
             }
 
             fis.close();
-        } catch (IOException e) {
-            if (fis != null) {
-                fis.close();
-            }
-            throw (e);
         }
 
         os.write(0);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/08fc7320/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java b/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
index e18cd61..3dc994b 100644
--- a/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
+++ b/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
@@ -313,11 +313,12 @@ public class OBRResolverTest {
         genericTestResolve(jarName, conf, expectedMrids, null);
     }
 
-    @SuppressWarnings("resource")
     private void genericTestResolve(String jarName, String conf, ModuleRevisionId[] expectedMrids,
             ModuleRevisionId[] expected2Mrids) throws Exception {
-        Manifest manifest = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
-                + jarName)).getManifest();
+        JarInputStream jis = new JarInputStream(
+                new FileInputStream("test/test-repo/bundlerepo/" + jarName));
+        Manifest manifest = jis.getManifest();
+        jis.close();
         BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
         bundleInfo.addArtifact(new BundleArtifact(false, new File("test/test-repo/bundlerepo/"
                 + jarName).toURI(), null));
@@ -346,10 +347,11 @@ public class OBRResolverTest {
         assertEquals(expected, actual);
     }
 
-    @SuppressWarnings("resource")
     private void genericTestFailingResolve(String jarName, String conf) throws Exception
{
-        Manifest manifest = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
-                + jarName)).getManifest();
+        JarInputStream jis = new JarInputStream(
+                new FileInputStream("test/test-repo/bundlerepo/" + jarName));
+        Manifest manifest = jis.getManifest();
+        jis.close();
         BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
         bundleInfo.addArtifact(new BundleArtifact(false, new File("test/test-repo/bundlerepo/"
                 + jarName).toURI(), null));


Mime
View raw message