diff options
author | Tor Norbye <tnorbye@google.com> | 2012-06-18 10:53:52 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-06-18 10:53:52 -0700 |
commit | 0c3b994c5bbbc980f7872649e2ccb0ba3f0840c7 (patch) | |
tree | 4d0934909b11a069c2726f49cfd57051259c6e69 | |
parent | d6215b7fcc4e732e7cfd297c8260a1bead9a6bc7 (diff) | |
download | sdk-0c3b994c5bbbc980f7872649e2ccb0ba3f0840c7.zip sdk-0c3b994c5bbbc980f7872649e2ccb0ba3f0840c7.tar.gz sdk-0c3b994c5bbbc980f7872649e2ccb0ba3f0840c7.tar.bz2 |
Workaround for Eclipse resource detection.
Plus close a potentially unclosed resource.
Change-Id: I4eb69c28dc120ab3eb5fe5724149b749ed9fe335
3 files changed, 22 insertions, 11 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java index 55021a3..328204c 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java @@ -267,7 +267,8 @@ public class AddonsListFetcher { InputStream xml = cache.openCachedUrl(urlString, monitor);
if (xml != null) {
xml.mark(500000);
- xml = new NonClosingInputStream(xml).setCloseBehavior(CloseBehavior.RESET);
+ xml = new NonClosingInputStream(xml);
+ ((NonClosingInputStream) xml).setCloseBehavior(CloseBehavior.RESET);
}
return xml;
} catch (Exception e) {
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkStats.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkStats.java index 60bb89d..83c9c3a 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkStats.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkStats.java @@ -252,7 +252,8 @@ public class SdkStats { InputStream xml = cache.openCachedUrl(urlString, monitor);
if (xml != null) {
xml.mark(500000);
- xml = new NonClosingInputStream(xml).setCloseBehavior(CloseBehavior.RESET);
+ xml = new NonClosingInputStream(xml);
+ ((NonClosingInputStream) xml).setCloseBehavior(CloseBehavior.RESET);
}
return xml;
} catch (Exception e) {
@@ -446,18 +447,26 @@ public class SdkStats { */
private Validator getValidator(int version) throws SAXException {
InputStream xsdStream = SdkStatsConstants.getXsdStream(version);
- SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ try {
+ SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- if (factory == null) {
- return null;
- }
+ if (factory == null) {
+ return null;
+ }
- // This may throw a SAX Exception if the schema itself is not a valid XSD
- Schema schema = factory.newSchema(new StreamSource(xsdStream));
+ // This may throw a SAX Exception if the schema itself is not a valid XSD
+ Schema schema = factory.newSchema(new StreamSource(xsdStream));
- Validator validator = schema == null ? null : schema.newValidator();
+ Validator validator = schema == null ? null : schema.newValidator();
- return validator;
+ return validator;
+ } finally {
+ if (xsdStream != null) {
+ try {
+ xsdStream.close();
+ } catch (IOException ignore) {}
+ }
+ }
}
/**
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java index a0d515a..ee3b0af 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java @@ -631,7 +631,8 @@ public abstract class SdkSource implements IDescription, Comparable<SdkSource> { InputStream xml = cache.openCachedUrl(urlString, monitor);
if (xml != null) {
xml.mark(500000);
- xml = new NonClosingInputStream(xml).setCloseBehavior(CloseBehavior.RESET);
+ xml = new NonClosingInputStream(xml);
+ ((NonClosingInputStream) xml).setCloseBehavior(CloseBehavior.RESET);
}
return xml;
} catch (Exception e) {
|