Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Resources are closed incorrectly #14

@QiAnXinCodeSafe

Description

@QiAnXinCodeSafe

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.

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions