Bug 1356693 - infer: fix RESOURCE_LEAK's in stumbler r=walkingice

MozReview-Commit-ID: 8bMGr6v9DKn

--HG--
extra : rebase_source : 0a53d3f694df3a631cc7b5ee2345e2ca1a6b6ec1
This commit is contained in:
Andrzej Hunt 2017-04-17 16:33:57 -07:00
Родитель 135c35d919
Коммит f798a0402b
1 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -30,17 +30,27 @@ public class Zipper {
public static String unzipData(byte[] data) throws IOException {
StringBuilder result = new StringBuilder();
final ByteArrayInputStream bs = new ByteArrayInputStream(data);
GZIPInputStream gstream = new GZIPInputStream(bs);
BufferedReader in = null;
try {
InputStreamReader reader = new InputStreamReader(gstream, StringUtils.UTF_8);
BufferedReader in = new BufferedReader(reader);
in = new BufferedReader(new InputStreamReader(new GZIPInputStream(bs), StringUtils.UTF_8));
String read;
while ((read = in.readLine()) != null) {
result.append(read);
}
} finally {
gstream.close();
// We usually use IOUtils.safeStreamClose(), however stumbler is completely independent
// of the rest of fennec, and hence we can't use it here:
if (in != null) {
try {
in.close();
} catch (IOException e) {
// eat it - nothing we can do
}
}
// Is always non-null
bs.close();
}
return result.toString();