[
https://issues.jboss.org/browse/ELY-1263?page=com.atlassian.jira.plugin.s...
]
Martin Choma updated ELY-1263:
------------------------------
Description:
Coverity found potential dereference of null object , because {{file.getParentFile()}} can
return null in some circumstances.
{code:java|title=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);
}
}
{code}
https://scan7.coverity.com/reports.htm#v23632/p11778/fileInstanceId=25046...
was:
Coverity found potential dereference of null object , because {{file.getParentFile()}} can
return null in some circumstances.
{code}
@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);
}
}
{code}
Coverity found
https://scan7.coverity.com/reports.htm#v23632/p11778/fileInstanceId=25046...
Coverity, Dereference null return value
(PeriodicRotatingFileAuditEndpoint)
---------------------------------------------------------------------------
Key: ELY-1263
URL:
https://issues.jboss.org/browse/ELY-1263
Project: WildFly Elytron
Issue Type: Bug
Reporter: Martin Choma
Assignee: Darran Lofthouse
Coverity found potential dereference of null object , because {{file.getParentFile()}}
can return null in some circumstances.
{code:java|title=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);
}
}
{code}
https://scan7.coverity.com/reports.htm#v23632/p11778/fileInstanceId=25046...
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)