diff options
Diffstat (limited to 'sdkmanager/libs')
5 files changed, 18 insertions, 20 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java index f5abe9e..d499feb 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java @@ -538,6 +538,7 @@ public final class ApkBuilder implements IArchiveBuilder { // ask the builder to add the content of the file. FileInputStream fis = new FileInputStream(zipFile); mBuilder.writeZip(fis, mNullFilter); + fis.close(); } catch (DuplicateFileException e) { mBuilder.cleanUp(); throw e; @@ -573,6 +574,7 @@ public final class ApkBuilder implements IArchiveBuilder { // the java resources. FileInputStream fis = new FileInputStream(jarFile); mBuilder.writeZip(fis, mFilter); + fis.close(); // check if native libraries were found in the external library. This should // constitutes an error or warning depending on if they are in lib/ diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SignedJarBuilder.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SignedJarBuilder.java index 48f1b91..e676520 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SignedJarBuilder.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SignedJarBuilder.java @@ -260,7 +260,9 @@ public class SignedJarBuilder { Signature signature = Signature.getInstance("SHA1with" + mKey.getAlgorithm()); signature.initSign(mKey); mOutputJar.putNextEntry(new JarEntry("META-INF/CERT.SF")); - writeSignatureFile(new SignatureOutputStream(mOutputJar, signature)); + SignatureOutputStream out = new SignatureOutputStream(mOutputJar, signature); + writeSignatureFile(out); + out.close(); // CERT.* mOutputJar.putNextEntry(new JarEntry("META-INF/CERT." + mKey.getAlgorithm())); diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java index 57e6190..301fb29 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java @@ -24,6 +24,7 @@ import com.android.io.IAbstractFile; import com.android.io.IAbstractFolder; import com.android.io.StreamException; import com.android.utils.ILogger; +import com.google.common.io.Closeables; import java.io.BufferedReader; import java.io.FileNotFoundException; @@ -469,13 +470,7 @@ public class ProjectProperties implements IPropertySource { e.getMessage()); } } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - // pass - } - } + Closeables.closeQuietly(reader); } return null; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectPropertiesWorkingCopy.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectPropertiesWorkingCopy.java index 21dcc36..0bb9bd6 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectPropertiesWorkingCopy.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectPropertiesWorkingCopy.java @@ -21,6 +21,7 @@ import com.android.annotations.NonNull; import com.android.io.IAbstractFile; import com.android.io.IAbstractFolder; import com.android.io.StreamException; +import com.google.common.io.Closeables; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; @@ -32,6 +33,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.regex.Matcher; /** @@ -140,7 +142,7 @@ public class ProjectPropertiesWorkingCopy extends ProjectProperties { // since we're reading the existing file and replacing values with new ones, or skipping // removed values, we need to record what properties have been visited, so that // we can figure later what new properties need to be added at the end of the file. - HashSet<String> visitedProps = new HashSet<String>(); + Set<String> visitedProps = new HashSet<String>(); String line = null; while ((line = reader.readLine()) != null) { @@ -193,6 +195,8 @@ public class ProjectPropertiesWorkingCopy extends ProjectProperties { } } + Closeables.closeQuietly(reader); + } else { // new file, just write it all @@ -216,6 +220,7 @@ public class ProjectPropertiesWorkingCopy extends ProjectProperties { OutputStream filestream = toSave.getOutputStream(); filestream.write(baos.toByteArray()); filestream.flush(); + filestream.close(); } private void writeValue(OutputStreamWriter writer, String key, String value, diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/io/FileOp.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/io/FileOp.java index 7bbe54f..f9793cc 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/io/FileOp.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/io/FileOp.java @@ -18,6 +18,7 @@ package com.android.sdklib.io; import com.android.SdkConstants; import com.android.annotations.NonNull; +import com.google.common.io.Closeables; import java.io.File; import java.io.FileInputStream; @@ -346,6 +347,7 @@ public class FileOp implements IFileOp { return new FileOutputStream(file); } + @SuppressWarnings("resource") // Eclipse doesn't understand Closeables.closeQuietly @Override public @NonNull Properties loadProperties(@NonNull File file) { Properties props = new Properties(); @@ -355,15 +357,12 @@ public class FileOp implements IFileOp { props.load(fis); } catch (IOException ignore) { } finally { - if (fis != null) { - try { - fis.close(); - } catch (Exception ignore) {} - } + Closeables.closeQuietly(fis); } return props; } + @SuppressWarnings("resource") // Eclipse doesn't understand Closeables.closeQuietly @Override public boolean saveProperties(@NonNull File file, @NonNull Properties props, @NonNull String comments) { @@ -375,12 +374,7 @@ public class FileOp implements IFileOp { return true; } catch (IOException ignore) { } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - } - } + Closeables.closeQuietly(fos); } return false; |