lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [1/3] lucene-solr:master: SOLR-10809: Get precommit lint warnings out of Solr core
Date Mon, 26 Feb 2018 06:13:52 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 6f2d99e57 -> 616464388


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/61646438/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java b/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java
index 8ecc29c..58996e4 100644
--- a/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java
+++ b/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java
@@ -45,14 +45,16 @@ public class ContentStreamTest extends SolrTestCaseJ4
 
   public void testFileStream() throws IOException 
   {
-    InputStream is = new SolrResourceLoader().openResource( "solrj/README" );
-    assertNotNull( is );
-    File file = new File(createTempDir().toFile(), "README");
-    FileOutputStream os = new FileOutputStream(file);
-    IOUtils.copy(is, os);
-    os.close();
-    is.close();
-    
+    File file = null;
+    try (SolrResourceLoader loader = new SolrResourceLoader();
+         InputStream is = loader.openResource( "solrj/README" )) {
+      assertNotNull(is);
+      file = new File(createTempDir().toFile(), "README");
+      try (FileOutputStream os = new FileOutputStream(file)) {
+        IOUtils.copy(is, os);
+      }
+    }
+
     ContentStreamBase stream = new ContentStreamBase.FileStream(file);
     InputStream s = stream.getStream();
     FileInputStream fis = new FileInputStream(file);
@@ -74,13 +76,18 @@ public class ContentStreamTest extends SolrTestCaseJ4
 
   public void testURLStream() throws IOException 
   {
-    InputStream is = new SolrResourceLoader().openResource( "solrj/README" );
-    assertNotNull( is );
-    File file = new File(createTempDir().toFile(), "README");
-    FileOutputStream os = new FileOutputStream(file);
-    IOUtils.copy(is, os);
-    os.close();
-    is.close();
+    File file = null;
+    FileOutputStream os = null;
+
+    try (SolrResourceLoader loader = new SolrResourceLoader();
+         InputStream is = loader.openResource( "solrj/README" )) {
+      assertNotNull(is);
+      file = new File(createTempDir().toFile(), "README");
+      os = new FileOutputStream(file);
+      IOUtils.copy(is, os);
+      os.close();
+      is.close();
+    }
     
     ContentStreamBase stream = new ContentStreamBase.URLStream(new URL(file
         .toURI().toASCIIString()));


Mime
View raw message