-
Bug
-
Resolution: Fixed
-
P4
-
11, 12
-
b04
-
generic
-
generic
-
Not verified
A DESCRIPTION OF THE PROBLEM :
public boolean renameTo(File dest) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
security.checkWrite(dest.path);
}
if (dest == null) {
throw new NullPointerException();
}
if (this.isInvalid() || dest.isInvalid()) {
return false;
}
return fs.rename(this, dest);
}
if a SecurityManager is exists, and dest is null, then execute security.checkWrite(dest.path) will throw nullpoint exception, and if (dest == null) is no meaning.
the first step should be test if dest is null.
public boolean renameTo(File dest) {
if (dest == null) {
throw new NullPointerException();
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
security.checkWrite(dest.path);
}
if (this.isInvalid() || dest.isInvalid()) {
return false;
}
return fs.rename(this, dest);
}
FREQUENCY : always
public boolean renameTo(File dest) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
security.checkWrite(dest.path);
}
if (dest == null) {
throw new NullPointerException();
}
if (this.isInvalid() || dest.isInvalid()) {
return false;
}
return fs.rename(this, dest);
}
if a SecurityManager is exists, and dest is null, then execute security.checkWrite(dest.path) will throw nullpoint exception, and if (dest == null) is no meaning.
the first step should be test if dest is null.
public boolean renameTo(File dest) {
if (dest == null) {
throw new NullPointerException();
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
security.checkWrite(dest.path);
}
if (this.isInvalid() || dest.isInvalid()) {
return false;
}
return fs.rename(this, dest);
}
FREQUENCY : always
- duplicates
-
JDK-8230840 java.io.File.renameTo checks for null argument too late
- Closed
- links to