diff options
author | Tor Norbye <tnorbye@google.com> | 2012-10-23 14:59:04 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-10-25 15:22:21 -0700 |
commit | c7df8d23830cc48f5741d44e2a978fc9ca52b003 (patch) | |
tree | 35e364ecc8978613267b1fcb0a08f7f7ac8e805e /eclipse | |
parent | 152af2d57d5e2a6874e14fa1557566c6df7f9dad (diff) | |
download | sdk-c7df8d23830cc48f5741d44e2a978fc9ca52b003.zip sdk-c7df8d23830cc48f5741d44e2a978fc9ca52b003.tar.gz sdk-c7df8d23830cc48f5741d44e2a978fc9ca52b003.tar.bz2 |
Close file streams used by parsers (and add guava to sdkcommon)
Plus some nullness annotations.
Change-Id: Ia75c6ffa5d6296c991fc86fec050f285b9143429
Diffstat (limited to 'eclipse')
3 files changed, 42 insertions, 33 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java index 170e27d..0669f9e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java @@ -113,7 +113,9 @@ public class RenderService { Configuration config = chooser.getConfiguration(); FolderConfiguration folderConfig = config.getFullConfig(); - mHardwareConfigHelper = new HardwareConfigHelper(config.getDevice()); + Device device = config.getDevice(); + assert device != null; // Should only attempt render with configuration that has device + mHardwareConfigHelper = new HardwareConfigHelper(device); mHardwareConfigHelper.setOrientation( folderConfig.getScreenOrientationQualifier().getValue()); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepository.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepository.java index 9768f51..5f2659e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepository.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepository.java @@ -199,6 +199,7 @@ public class ViewMetadataRepository { } /** Returns an ordered list of categories and views, parsed from a metadata file */ + @SuppressWarnings("resource") // streams passed to parser InputSource closed by parser private List<CategoryData> getCategories() { if (mCategories == null) { mCategories = new ArrayList<CategoryData>(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidJarLoader.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidJarLoader.java index 161d567..c4eb37f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidJarLoader.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/AndroidJarLoader.java @@ -17,6 +17,7 @@ package com.android.ide.eclipse.adt.internal.sdk; import com.android.SdkConstants; +import com.google.common.io.Closeables; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubMonitor; @@ -205,6 +206,7 @@ public class AndroidJarLoader extends ClassLoader implements IAndroidClassLoader * @throws InvalidAttributeValueException * @throws ClassFormatError */ + @SuppressWarnings("resource") // Eclipse doesn't understand Closeables.closeQuietly @Override public HashMap<String, ArrayList<IClassDescriptor>> findClassesDerivingFrom( String packageFilter, @@ -223,43 +225,47 @@ public class AndroidJarLoader extends ClassLoader implements IAndroidClassLoader // create streams to read the intermediary archive FileInputStream fis = new FileInputStream(mOsFrameworkLocation); ZipInputStream zis = new ZipInputStream(fis); - ZipEntry entry; - while ((entry = zis.getNextEntry()) != null) { - // get the name of the entry and convert to a class binary name - String entryPath = entry.getName(); - if (!entryPath.endsWith(SdkConstants.DOT_CLASS)) { - // only accept class files - continue; - } - if (packageFilter.length() > 0 && !entryPath.startsWith(packageFilter)) { - // only accept stuff from the requested root package. - continue; - } - String className = entryPathToClassName(entryPath); - - Class<?> loaded_class = mClassCache.get(className); - if (loaded_class == null) { - byte[] data = mEntryCache.get(className); - if (data == null) { - // Get the class and cache it - long entrySize = entry.getSize(); - if (entrySize > Integer.MAX_VALUE) { - throw new InvalidAttributeValueException(); + try { + ZipEntry entry; + while ((entry = zis.getNextEntry()) != null) { + // get the name of the entry and convert to a class binary name + String entryPath = entry.getName(); + if (!entryPath.endsWith(SdkConstants.DOT_CLASS)) { + // only accept class files + continue; + } + if (packageFilter.length() > 0 && !entryPath.startsWith(packageFilter)) { + // only accept stuff from the requested root package. + continue; + } + String className = entryPathToClassName(entryPath); + + Class<?> loaded_class = mClassCache.get(className); + if (loaded_class == null) { + byte[] data = mEntryCache.get(className); + if (data == null) { + // Get the class and cache it + long entrySize = entry.getSize(); + if (entrySize > Integer.MAX_VALUE) { + throw new InvalidAttributeValueException(); + } + data = readZipData(zis, (int)entrySize); } - data = readZipData(zis, (int)entrySize); + loaded_class = defineAndCacheClass(className, data); } - loaded_class = defineAndCacheClass(className, data); - } - for (Class<?> superClass = loaded_class.getSuperclass(); - superClass != null; - superClass = superClass.getSuperclass()) { - String superName = superClass.getCanonicalName(); - if (mClassesFound.containsKey(superName)) { - mClassesFound.get(superName).add(new ClassWrapper(loaded_class)); - break; + for (Class<?> superClass = loaded_class.getSuperclass(); + superClass != null; + superClass = superClass.getSuperclass()) { + String superName = superClass.getCanonicalName(); + if (mClassesFound.containsKey(superName)) { + mClassesFound.get(superName).add(new ClassWrapper(loaded_class)); + break; + } } } + } finally { + Closeables.closeQuietly(zis); } return mClassesFound; |