Uploaded image for project: 'WildFly Elytron'
  1. WildFly Elytron
  2. ELY-1593

Coverity static analysis, Resource leak on the exceptional path of setFile in FileAuditEndpoint

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: 1.3.2.Final
    • Fix Version/s: None
    • Component/s: Audit
    • Labels:
      None

      Description

      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.

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

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                ivassile Ilia Vassilev
                Reporter:
                ivassile Ilia Vassilev
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: