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

commit 8a971cc4cd1849bae1edcd4752d7e77ac19bd3a4
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Fri Feb 5 16:33:34 2021 -0500

    Fix some compiler warnings.
---
 .../vfs2/provider/http4/Http4GetContentInfoTest.java   | 10 ++++++----
 .../vfs2/provider/http4/Http4ProviderTestCase.java     |  2 ++
 .../vfs2/provider/http4s/Http4sGetContentInfoTest.java | 11 ++++++-----
 .../vfs2/provider/http5/Http5GetContentInfoTest.java   | 18 ++++++++++--------
 4 files changed, 24 insertions(+), 17 deletions(-)

diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4GetContentInfoTest.java
 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4GetContentInfoTest.java
index 1fe6411..54ef50d 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4GetContentInfoTest.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4GetContentInfoTest.java
@@ -119,11 +119,13 @@ public class Http4GetContentInfoTest extends TestCase {
      */
     @Test
     public void testGetContentWithProxyAuthInfo() throws FileSystemException, 
MalformedURLException {
+        @SuppressWarnings("resource") // getManager() returns a global.
         final FileSystemManager fsManager = VFS.getManager();
         final String uri = "http4://www.apache.org/licenses/LICENSE-2.0.txt";
-        final FileObject fo = fsManager.resolveFile(uri, 
getOptionsWithProxyAuthentication());
-        final FileContent content = fo.getContent();
-        Assert.assertNotNull(content);
-        content.getContentInfo();
+        try (final FileObject fo = fsManager.resolveFile(uri, 
getOptionsWithProxyAuthentication());
+            final FileContent content = fo.getContent()) {
+            Assert.assertNotNull(content);
+            content.getContentInfo();
+        }
     }
 }
diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java
 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java
index 05c0f5e..ea65b56 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java
@@ -138,6 +138,7 @@ public class Http4ProviderTestCase extends 
AbstractProviderTestConfig {
         VFS.getManager().getFilesCache().close();
         final FileSystemOptions opts = new FileSystemOptions();
         Http4FileSystemConfigBuilder.getInstance().setFollowRedirect(opts, 
followRedirect);
+        @SuppressWarnings("resource") // getManager() returns a global.
         final FileObject file = VFS.getManager().resolveFile(uri, opts);
         try {
             checkReadTestsFolder(file);
@@ -164,6 +165,7 @@ public class Http4ProviderTestCase extends 
AbstractProviderTestConfig {
 
     // Test no longer passing 2016/04/28
     public void ignoreTestHttp405() throws FileSystemException {
+        @SuppressWarnings("resource") // getManager() returns a global.
         final FileObject fileObject = VFS.getManager()
                 
.resolveFile("http4://www.w3schools.com/webservices/tempconvert.asmx?action=WSDL");
         assert !fileObject.getContent().isEmpty();
diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4s/Http4sGetContentInfoTest.java
 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4s/Http4sGetContentInfoTest.java
index b6dd1ef..f717ad7 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4s/Http4sGetContentInfoTest.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4s/Http4sGetContentInfoTest.java
@@ -46,11 +46,12 @@ public class Http4sGetContentInfoTest extends TestCase {
     public void testGetContentInfo() throws FileSystemException, 
MalformedURLException {
         final FileSystemManager fsManager = VFS.getManager();
         final String uri = "http4://www.apache.org/licenses/LICENSE-2.0.txt";
-        final FileObject fo = fsManager.resolveFile(uri, 
getOptionsWithProxy());
-        final FileContent content = fo.getContent();
-        Assert.assertNotNull(content);
-        // Used to NPE before fix:
-        content.getContentInfo();
+        try (final FileObject fo = fsManager.resolveFile(uri, 
getOptionsWithProxy())) {
+            final FileContent content = fo.getContent();
+            Assert.assertNotNull(content);
+            // Used to NPE before fix:
+            content.getContentInfo();
+        }
     }
 
     FileSystemOptions getOptionsWithProxy() throws MalformedURLException {
diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5GetContentInfoTest.java
 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5GetContentInfoTest.java
index ff560a7..0530e42 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5GetContentInfoTest.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5GetContentInfoTest.java
@@ -104,10 +104,11 @@ public class Http5GetContentInfoTest extends TestCase {
         final FileSystemManager fsManager = VFS.getManager();
         final String uri = "http5://www.apache.org/licenses/LICENSE-2.0.txt";
         final FileObject fo = fsManager.resolveFile(uri, 
getOptionsWithProxy());
-        final FileContent content = fo.getContent();
-        Assert.assertNotNull(content);
-        // Used to NPE before fix:
-        content.getContentInfo();
+        try (final FileContent content = fo.getContent()) {
+            Assert.assertNotNull(content);
+            // Used to NPE before fix:
+            content.getContentInfo();
+        }
     }
 
     /**
@@ -119,9 +120,10 @@ public class Http5GetContentInfoTest extends TestCase {
     public void testGetContentWithProxyAuthInfo() throws FileSystemException, 
MalformedURLException {
         final FileSystemManager fsManager = VFS.getManager();
         final String uri = "http4://www.apache.org/licenses/LICENSE-2.0.txt";
-        final FileObject fo = fsManager.resolveFile(uri, 
getOptionsWithProxyAuthentication());
-        final FileContent content = fo.getContent();
-        Assert.assertNotNull(content);
-        content.getContentInfo();
+        try (final FileObject fo = fsManager.resolveFile(uri, 
getOptionsWithProxyAuthentication())) {
+            final FileContent content = fo.getContent();
+            Assert.assertNotNull(content);
+            content.getContentInfo();
+        }
     }
 }

Reply via email to