Cleanup unclosed streams plus formatting

- run FindBugs to find problems
This commit is contained in:
Connor Tumbleson 2016-02-14 20:34:06 -05:00
parent f3e21023ac
commit b29df52b87
4 changed files with 8 additions and 11 deletions

View File

@ -628,7 +628,7 @@ public class Androlib {
} }
ZipEntry newEntry = new ZipEntry(unknownFileInfo.getKey()); ZipEntry newEntry = new ZipEntry(unknownFileInfo.getKey());
int method = Integer.valueOf(unknownFileInfo.getValue()); int method = Integer.parseInt(unknownFileInfo.getValue());
LOGGER.fine(String.format("Copying unknown file %s with method %d", unknownFileInfo.getKey(), method)); LOGGER.fine(String.format("Copying unknown file %s with method %d", unknownFileInfo.getKey(), method));
if (method == ZipEntry.STORED) { if (method == ZipEntry.STORED) {
newEntry.setMethod(ZipEntry.STORED); newEntry.setMethod(ZipEntry.STORED);

View File

@ -62,8 +62,8 @@ public class ApktoolProperties {
try { try {
properties.load(templateStream); properties.load(templateStream);
version = properties.getProperty("application.version"); version = properties.getProperty("application.version");
} catch (IOException ignored) { templateStream.close();
} } catch (IOException ignored) { }
} }
sProps.put("baksmaliVersion", version); sProps.put("baksmaliVersion", version);
@ -80,14 +80,13 @@ public class ApktoolProperties {
try { try {
properties.load(templateStream); properties.load(templateStream);
version = properties.getProperty("application.version"); version = properties.getProperty("application.version");
} catch (IOException ignored) { templateStream.close();
} } catch (IOException ignored) { }
} }
sProps.put("smaliVersion", version); sProps.put("smaliVersion", version);
} }
private static Properties sProps; private static Properties sProps;
private static final Logger LOGGER = Logger private static final Logger LOGGER = Logger.getLogger(ApktoolProperties.class.getName());
.getLogger(ApktoolProperties.class.getName());
} }

View File

@ -106,7 +106,7 @@ public class ResFileDecoder {
} catch (AndrolibException ex) { } catch (AndrolibException ex) {
LOGGER.log(Level.SEVERE, String.format( LOGGER.log(Level.SEVERE, String.format(
"Could not decode file, replacing by FALSE value: %s", "Could not decode file, replacing by FALSE value: %s",
inFileName, outFileName), ex); inFileName), ex);
res.replace(new ResBoolValue(false, 0, null)); res.replace(new ResBoolValue(false, 0, null));
} }
} }

View File

@ -82,6 +82,7 @@ public class SmaliBuilder {
StringBuilder out = new StringBuilder(); StringBuilder out = new StringBuilder();
List<String> lines = IOUtils.readLines(inStream); List<String> lines = IOUtils.readLines(inStream);
inStream.close();
if (! mDebug) { if (! mDebug) {
final String[] linesArray = lines.toArray(new String[0]); final String[] linesArray = lines.toArray(new String[0]);
@ -107,9 +108,6 @@ public class SmaliBuilder {
out.append(line).append('\n'); out.append(line).append('\n');
} }
} }
inStream.close();
try { try {
if (!SmaliMod.assembleSmaliFile(out.toString(),dexBuilder, false, false, inFile)) { if (!SmaliMod.assembleSmaliFile(out.toString(),dexBuilder, false, false, inFile)) {
throw new AndrolibException("Could not smali file: " + fileName); throw new AndrolibException("Could not smali file: " + fileName);