google/physical-web

The resource was closed incorrectly

QiAnXinCodeSafe opened this issue · 0 comments

The code may throw an exception before the resource is closed,you should use try-catch-finally or try-with-resource to close resource

OutputStream os = urlConnection.getOutputStream();
os.write(mJsonObject.toString().getBytes("UTF-8"));
os.close();

GZIPInputStream gzis = new GZIPInputStream(new FileInputStream(src));
FileOutputStream out = new FileOutputStream(dest);
int len;
while ((len = gzis.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
gzis.close();
out.close();
} catch(IOException ex){

The resource is not closed
inputStream = new BufferedInputStream(urlConnection.getInputStream());
result = readInputStream(inputStream);
} catch (IOException e) {
ioException = e;
} finally {
if (urlConnection != null) {
urlConnection.disconnect();
}