-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
The outputStream may throw an exception before the resource is closed,you should use try-catch-finally or try-with-resource to close the resource.
Connection.getinputstream () and connection.geterrorstream () are not closed.
capillary/demo/server/src/main/java/com/google/capillary/demo/server/FcmSender.java
Lines 93 to 108 in 7dda356
| HttpURLConnection connection = getConnection(); | |
| connection.setDoOutput(true); | |
| DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream()); | |
| outputStream.writeBytes(requestJson.toString()); | |
| outputStream.flush(); | |
| outputStream.close(); | |
| int responseCode = connection.getResponseCode(); | |
| if (responseCode == 200) { | |
| String response = inputstreamToString(connection.getInputStream()); | |
| logger.info("Message sent to Firebase for delivery, response:"); | |
| logger.info(response); | |
| } else { | |
| logger.info("Unable to send message to Firebase:"); | |
| String response = inputstreamToString(connection.getErrorStream()); | |
| logger.info(response); |
Metadata
Metadata
Assignees
Labels
No labels