Unnatural bugs
Example 1: Wrong initialization value bug
if (isTerminated()) {
// Before (entropy = 5.96485):
- terminationFuture.@\Red{setSuccess}@(null);
// After (entropy = 1.33915):
+ terminationFuture.@\dkgreen{trySuccess}@(null);
}
Example 2: Wrong method call bug
if (newState.isClosed()) {
// Before (entropy = 6.07042):
- this.tokenInfo = @\Red{null}@;
// After (entropy = 1.95014):
+ this.tokenInfo = @\dkgreen{AccessToken.createEmptyToken}@
@\dkgreen{(Collections.emptyList())}@;
}
...
Example 3: Unhandled exception bug
if (!directory.exists())
// Before (entropy = 9.213675):
- @\Red{directory.mkdir();}@
// After (entropy = 5.33941):
+ @\dkgreen{if (!directory.mkdir())}@
+ @\dkgreen{throw new IOException}@
@\dkgreen{("Cannot create directory: " + directory)}@;
...
Natural bugs
Example 1: NBF could not detect the bug as entropy increased after the fix
if (maxHeaderSize <= 0) {
throw new IllegalArgumentException(
// Before (entropy = 2.696275):
- "maxHeaderSize must be a positive integer: "
+ @\Red{maxChunkSize)}@;
// After (entropy = 8.447305):
+ "maxHeaderSize must be a positive integer: "
+ @\dkgreen{maxHeaderSize)}@;
}
Example 2: NBF detected this line incorrectly as buggy due to high entropy value
// Entropy = 9.892635
Logger logger = new Logger(LoggingBehaviors.REQUESTS, "Request");
...