Author: sradia
Date: Tue Jul 3 00:28:19 2012
New Revision: 1356530
URL: http://svn.apache.org/viewvc?rev=1356530&view=rev
Log:
HADOOP-8534 Some tests leave a config file open causing failure on windows
(Ivan Mitic via Sanjay Radia)
Modified:
hadoop/common/branches/branch-1-win/CHANGES.txt
hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/conf/Configuration.java
Modified: hadoop/common/branches/branch-1-win/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.txt?rev=1356530&r1=1356529&r2=1356530&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.txt Tue Jul 3 00:28:19 2012
@@ -46,6 +46,8 @@ branch-hadoop-1-win - unreleased
HADOOP-8486 Resource leak ... SequenceFile (Fix with
HADOOP-8486-branch-1-win-(5).patch) (Kanna Karanam via Sanjay)
+ HADOOP-8534 Some tests leave a config file open causing failure on windows
(Ivan Mitic via Sanjay Radia)
+
Release 1.1.0 - unreleased
NEW FEATURES
Modified:
hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/conf/Configuration.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/conf/Configuration.java?rev=1356530&r1=1356529&r2=1356530&view=diff
==============================================================================
---
hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/conf/Configuration.java
(original)
+++
hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/conf/Configuration.java
Tue Jul 3 00:28:19 2012
@@ -1157,7 +1157,14 @@ public class Configuration implements It
if (!quiet) {
LOG.info("parsing " + url);
}
- doc = builder.parse(url.toString());
+ // Do not pass url directly to DocumentBuilder.parse() since it
+ // will keep the file open after SAXException
+ InputStream in = new BufferedInputStream(url.openStream());
+ try {
+ doc = builder.parse(in);
+ } finally {
+ in.close();
+ }
}
} else if (name instanceof String) { // a CLASSPATH resource
URL url = getResource((String)name);
@@ -1165,7 +1172,12 @@ public class Configuration implements It
if (!quiet) {
LOG.info("parsing " + url);
}
- doc = builder.parse(url.toString());
+ InputStream in = new BufferedInputStream(url.openStream());
+ try {
+ doc = builder.parse(in);
+ } finally {
+ in.close();
+ }
}
} else if (name instanceof Path) { // a file resource
// Can't use FileSystem API or we get an infinite loop