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

Coverity, Dereference null return value (PeriodicRotatingFileAuditEndpoint)

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 1.1.0.CR3
    • Component/s: None
    • Labels:
      None

      Description

      Coverity found potential dereference of null object , because file.getParentFile() can return null in some circumstances.

      PeriodicRotatingFileAuditEndpoint.java
       @Override
          protected void preWrite(Instant instant) {
              final long recordMillis = instant.toEpochMilli();
              if (recordMillis >= nextRollover) {
                  try {
                      final File file = getFile();
                      if (file == null) {
                          // no file is set; a direct output stream or writer was specified
                          return;
                      }
                      closeStreams(); // close the original file (some OSes won't let you move/rename a file that is open)
                      final Path target =  file.getParentFile().toPath().resolve(file.getName() + nextSuffix);
                      Files.move(file.toPath(), target, StandardCopyOption.REPLACE_EXISTING);
                      setFile(file);
                  } catch (IOException e) {
                      audit.unableToRotateLogFile(e);
                  }
                  calcNextRollover(recordMillis);
              }
          }
      

      https://scan7.coverity.com/reports.htm#v23632/p11778/fileInstanceId=25046999&defectInstanceId=5660941&mergedDefectId=1445725

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  yersan Yeray Borges
                  Reporter:
                  mchoma Martin Choma
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: