FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
Linux 4.12.8-300.fc26.x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The java.util.logging.Level.findLevel() internal method will attempt to find a level by name, if not found it will attempt to find it by an int value then finally by localized method name. However when finding the level by it's int value the value will never be returned. It will always fall through to the KnownLevel.findByLocalizedLevelName().
try {
int x = Integer.parseInt(name);
level = KnownLevel.findByValue(x, KnownLevel::mirrored);
if (!level.isPresent()) {
// add new Level
Level levelObject = new Level(name, x);
// There's no need to use a reachability fence here because
// KnownLevel keeps a strong reference on the level when
// level.getClass() == Level.class.
return KnownLevel.findByValue(x, KnownLevel::mirrored).get();
}
} catch (NumberFormatException ex) {
// Not an integer.
// Drop through.
}
level = KnownLevel.findByLocalizedLevelName(name,
KnownLevel::mirrored);
if (level.isPresent()) {
return level.get();
}
return null;
In the above snippet it only checks if the optional value is not found when looking up by int value. This should return the value if it's found.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply invoke java.util.logging.Level.findLevel("400"). You should get a null value.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In the steps above this should result in Level.TRACE being returned.
ACTUAL -
A null value is returned.
REPRODUCIBILITY :
This bug can be reproduced always.