[jboss-jira] [JBoss JIRA] (ELY-1593) Coverity static analysis, Resource leak on the exceptional path of setFile in FileAuditEndpoint
Ilia Vassilev (JIRA)
issues at jboss.org
Fri May 25 13:22:00 EDT 2018
[ https://issues.jboss.org/browse/ELY-1593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13582507#comment-13582507 ]
Ilia Vassilev edited comment on ELY-1593 at 5/25/18 1:21 PM:
-------------------------------------------------------------
Not a bug. When {{fos.getFD()}} throws an exception, {{ok}} flag is false and we close the resources in the {{finally}} blocks.
was (Author: ivassile):
Not a bug. When {{fos.getFD()}} throws an exception, ok flag is false and we close the resources in the {{finally}} blocks.
> Coverity static analysis, Resource leak on the exceptional path of setFile in FileAuditEndpoint
> -----------------------------------------------------------------------------------------------
>
> Key: ELY-1593
> URL: https://issues.jboss.org/browse/ELY-1593
> Project: WildFly Elytron
> Issue Type: Bug
> Components: Audit
> Affects Versions: 1.3.2.Final
> Reporter: Ilia Vassilev
> Assignee: Ilia Vassilev
>
> Coverity static analysis found possible occurrence of resource leak.
> https://scan7.coverity.com/reports.htm#v20225/p11778/fileInstanceId=53592668&defectInstanceId=11119606&mergedDefectId=1429222
> When {{fos.getFD()}} will throw exception {{FileOutputStream fos}} won't be closed.
> {code:java|title=FileAuditEndpoint.java}
> void setFile(final File file) throws IOException {
> boolean ok = false;
> final FileOutputStream fos = new FileOutputStream(file, true);
> try {
> final OutputStream bos = new BufferedOutputStream(fos);
> try {
> this.fileDescriptor = fos.getFD();
> this.outputStream = bos;
> this.file = file;
> ok = true;
> } finally {
> if (! ok) {
> safeClose(bos);
> }
> }
> } finally {
> if (! ok) {
> safeClose(fos);
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
More information about the jboss-jira
mailing list