11/*
2- * Copyright (c) 2000, 2016 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2000, 2018 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -610,10 +610,7 @@ static synchronized void purge() {
610610 }
611611
612612 private static void registerWithClassLoader (Level customLevel ) {
613- PrivilegedAction <ClassLoader > pa =
614- () -> customLevel .getClass ().getClassLoader ();
615- PrivilegedAction <String > pn = customLevel .getClass ()::getName ;
616- final String name = AccessController .doPrivileged (pn );
613+ PrivilegedAction <ClassLoader > pa = customLevel .getClass ()::getClassLoader ;
617614 final ClassLoader cl = AccessController .doPrivileged (pa );
618615 CUSTOM_LEVEL_CLV .computeIfAbsent (cl , (c , v ) -> new ArrayList <>())
619616 .add (customLevel );
@@ -624,19 +621,10 @@ static synchronized void add(Level l) {
624621 // the mirroredLevel object is always added to the list
625622 // before the custom Level instance
626623 KnownLevel o = new KnownLevel (l );
627- List <KnownLevel > list = nameToLevels .get (l .name );
628- if (list == null ) {
629- list = new ArrayList <>();
630- nameToLevels .put (l .name , list );
631- }
632- list .add (o );
633-
634- list = intToLevels .get (l .value );
635- if (list == null ) {
636- list = new ArrayList <>();
637- intToLevels .put (l .value , list );
638- }
639- list .add (o );
624+ nameToLevels .computeIfAbsent (l .name , (k ) -> new ArrayList <>())
625+ .add (o );
626+ intToLevels .computeIfAbsent (l .value , (k ) -> new ArrayList <>())
627+ .add (o );
640628
641629 // keep the custom level reachable from its class loader
642630 // This will ensure that custom level values are not GC'ed
0 commit comments