Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-2331: fix Windows file deletion failure due to a lock held by an unclosed anonymous input stream created for the purpose of debug printing; also, wrap the debug printing in an 'if (VERBOSE) { }' block so that it doesn't get ordinarily get invoked.

Steven Rowe28dab8437f4b
diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java b/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
index 975aa200f84..bf3c1687162 100644
--- a/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
+++ b/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
@@ -202,8 +202,15 @@ public class TestSolrProperties extends LuceneTestCase {
assertTrue("should have more recent time: " + after + "," + before, after > before);
mcr = CoreAdminRequest.persist("solr-persist.xml", coreadmin);
-
- System.out.println(IOUtils.toString(new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"))));
+
+ if (VERBOSE) {
+ FileInputStream fis = new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"));
+ try {
+ System.out.println(IOUtils.toString(fis));
+ } finally {
+ fis.close();
+ }
+ }
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
FileInputStream fis = new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"));
try {