8187073: The java.util.logging.Level.findLevel() will not correctly find a Level by it's int value

Reviewed-by: rriggs
This commit is contained in:
Daniel Fuchs 2017-12-08 17:40:57 +00:00
parent 82bf0799c6
commit eb62b5e51e
2 changed files with 35 additions and 9 deletions

View file

@ -389,14 +389,15 @@ public class Level implements java.io.Serializable {
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();
if (level.isPresent()) {
return level.get();
}
// 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.