Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

The resource was closed incorrectly #955

@QiAnXinCodeSafe

Description

@QiAnXinCodeSafe

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions