changeset 52275:5f40be158613

8209987: Minor cleanup in Level.java Reviewed-by: dfuchs Contributed-by: Bernd Eckenfels <ecki@zusammenkunft.net>
author dfuchs
date Mon, 27 Aug 2018 12:33:03 +0100
parents 948c62200f8c
children 839667fe21ef
files src/java.logging/share/classes/java/util/logging/Level.java
diffstat 1 files changed, 6 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.logging/share/classes/java/util/logging/Level.java	Mon Aug 27 10:25:13 2018 +0530
+++ b/src/java.logging/share/classes/java/util/logging/Level.java	Mon Aug 27 12:33:03 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -610,10 +610,7 @@
         }
 
         private static void registerWithClassLoader(Level customLevel) {
-            PrivilegedAction<ClassLoader> pa =
-                  () -> customLevel.getClass().getClassLoader();
-            PrivilegedAction<String> pn =  customLevel.getClass()::getName;
-            final String name = AccessController.doPrivileged(pn);
+            PrivilegedAction<ClassLoader> pa = customLevel.getClass()::getClassLoader;
             final ClassLoader cl = AccessController.doPrivileged(pa);
             CUSTOM_LEVEL_CLV.computeIfAbsent(cl, (c, v) -> new ArrayList<>())
                 .add(customLevel);
@@ -624,19 +621,10 @@
             // the mirroredLevel object is always added to the list
             // before the custom Level instance
             KnownLevel o = new KnownLevel(l);
-            List<KnownLevel> list = nameToLevels.get(l.name);
-            if (list == null) {
-                list = new ArrayList<>();
-                nameToLevels.put(l.name, list);
-            }
-            list.add(o);
-
-            list = intToLevels.get(l.value);
-            if (list == null) {
-                list = new ArrayList<>();
-                intToLevels.put(l.value, list);
-            }
-            list.add(o);
+            nameToLevels.computeIfAbsent(l.name, (k) -> new ArrayList<>())
+                .add(o);
+            intToLevels.computeIfAbsent(l.value, (k) -> new ArrayList<>())
+                .add(o);
 
             // keep the custom level reachable from its class loader
             // This will ensure that custom level values are not GC'ed