You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/02/01 02:30:07 UTC

[commons-vfs] branch master updated: Use try-with-resources.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git


The following commit(s) were added to refs/heads/master by this push:
     new ba112d0  Use try-with-resources.
ba112d0 is described below

commit ba112d08abcdc0900af61f429336ad24e827ff21
Author: Gary Gregory <gg...@rocketsoftware.com>
AuthorDate: Thu Jan 31 21:30:51 2019 -0500

    Use try-with-resources.
---
 .../https/test/GetContentInfoFunctionalTest.java         | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/https/test/GetContentInfoFunctionalTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/https/test/GetContentInfoFunctionalTest.java
index febb832..9dd10c7 100644
--- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/https/test/GetContentInfoFunctionalTest.java
+++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/https/test/GetContentInfoFunctionalTest.java
@@ -39,8 +39,9 @@ public class GetContentInfoFunctionalTest {
     /**
      * Tests VFS-427 NPE on HttpFileObject.getContent().getContentInfo().
      *
-     * @throws FileSystemException thrown when the getContentInfo API fails.
-     * @throws MalformedURLException thrown when the System environment contains an invalid URL for an HTTPS proxy.
+     * @throws FileSystemException   thrown when the getContentInfo API fails.
+     * @throws MalformedURLException thrown when the System environment contains an
+     *                               invalid URL for an HTTPS proxy.
      */
     @Test
     public void testGetContentInfo() throws FileSystemException, MalformedURLException {
@@ -65,10 +66,11 @@ public class GetContentInfoFunctionalTest {
         }
 
         final FileSystemManager fsManager = VFS.getManager();
-        final FileObject fo = fsManager.resolveFile("http://www.apache.org/licenses/LICENSE-2.0.txt", opts);
-        final FileContent content = fo.getContent();
-        Assert.assertNotNull(content);
-        // Used to NPE before fix:
-        content.getContentInfo();
+        try (final FileObject fo = fsManager.resolveFile("http://www.apache.org/licenses/LICENSE-2.0.txt", opts);
+             final FileContent content = fo.getContent();) {
+            Assert.assertNotNull(content);
+            // Used to NPE before fix:
+            content.getContentInfo();
+        }
     }
 }