diff options
Diffstat (limited to 'sdk_common/src/com/android/ide/common/resources')
3 files changed, 12 insertions, 3 deletions
diff --git a/sdk_common/src/com/android/ide/common/resources/FrameworkResources.java b/sdk_common/src/com/android/ide/common/resources/FrameworkResources.java index 0e7e58a..fe8e197 100755 --- a/sdk_common/src/com/android/ide/common/resources/FrameworkResources.java +++ b/sdk_common/src/com/android/ide/common/resources/FrameworkResources.java @@ -24,6 +24,7 @@ import com.android.io.IAbstractFile; import com.android.io.IAbstractFolder; import com.android.resources.ResourceType; import com.android.utils.ILogger; +import com.google.common.base.Charsets; import org.kxml2.io.KXmlParser; import org.xmlpull.v1.XmlPullParser; @@ -113,7 +114,7 @@ public class FrameworkResources extends ResourceRepository { Reader reader = null; try { reader = new BufferedReader(new InputStreamReader(publicXmlFile.getContents(), - "UTF-8")); //$NON-NLS-1$ + Charsets.UTF_8)); KXmlParser parser = new KXmlParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(reader); diff --git a/sdk_common/src/com/android/ide/common/resources/IdResourceParser.java b/sdk_common/src/com/android/ide/common/resources/IdResourceParser.java index 66a72ce..60c1725 100644 --- a/sdk_common/src/com/android/ide/common/resources/IdResourceParser.java +++ b/sdk_common/src/com/android/ide/common/resources/IdResourceParser.java @@ -20,6 +20,7 @@ import com.android.annotations.NonNull; import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.common.resources.ValueResourceParser.IValueResourceRepository; import com.android.resources.ResourceType; +import com.google.common.io.Closeables; import org.kxml2.io.KXmlParser; import org.xmlpull.v1.XmlPullParser; @@ -64,7 +65,7 @@ public class IdResourceParser { * * @param type the type of resource being scanned * @param path the full OS path to the file being parsed - * @param input the input stream of the XML to be parsed + * @param input the input stream of the XML to be parsed (will be closed by this method) * @return true if parsing succeeds and false if it fails * @throws IOException if reading the contents fails */ @@ -104,6 +105,8 @@ public class IdResourceParser { path, parser.getLineNumber(), message); mContext.addError(error); return false; + } finally { + Closeables.closeQuietly(input); } } diff --git a/sdk_common/src/com/android/ide/common/resources/ValidatingResourceParser.java b/sdk_common/src/com/android/ide/common/resources/ValidatingResourceParser.java index c1e45a8..b477b8f 100644 --- a/sdk_common/src/com/android/ide/common/resources/ValidatingResourceParser.java +++ b/sdk_common/src/com/android/ide/common/resources/ValidatingResourceParser.java @@ -17,6 +17,7 @@ package com.android.ide.common.resources; import com.android.annotations.NonNull; +import com.google.common.io.Closeables; import org.kxml2.io.KXmlParser; import org.xmlpull.v1.XmlPullParser; @@ -55,7 +56,7 @@ public class ValidatingResourceParser { * the context is already tagged as needing a full aapt run. * * @param path the full OS path to the file being parsed - * @param input the input stream of the XML to be parsed + * @param input the input stream of the XML to be parsed (will be closed by this method) * @return true if parsing succeeds and false if it fails * @throws IOException if reading the contents fails */ @@ -63,9 +64,11 @@ public class ValidatingResourceParser { throws IOException { // No need to validate framework files if (mIsFramework) { + Closeables.closeQuietly(input); return true; } if (mContext.needsFullAapt()) { + Closeables.closeQuietly(input); return false; } @@ -103,6 +106,8 @@ public class ValidatingResourceParser { path, parser.getLineNumber(), message); mContext.addError(error); return false; + } finally { + Closeables.closeQuietly(input); } } |