This repository was archived by the owner on Dec 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 657
The resource was closed incorrectly #955
Copy link
Copy link
Open
Description
The code may throw an exception before the resource is closed,you should use try-catch-finally or try-with-resource to close resource
physical-web/java/libs/src/main/java/org/physical_web/collection/JsonObjectRequest.java
Lines 63 to 65 in 1260431
OutputStream os = urlConnection.getOutputStream(); | |
os.write(mJsonObject.toString().getBytes("UTF-8")); | |
os.close(); |
physical-web/android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/Utils.java
Lines 1169 to 1181 in 1260431
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
physical-web/java/libs/src/main/java/org/physical_web/collection/Request.java
Lines 81 to 88 in 1260431
inputStream = new BufferedInputStream(urlConnection.getInputStream()); | |
result = readInputStream(inputStream); | |
} catch (IOException e) { | |
ioException = e; | |
} finally { | |
if (urlConnection != null) { | |
urlConnection.disconnect(); | |
} |
Metadata
Metadata
Assignees
Labels
No labels