On Fri, 22 Apr 2022 02:26:50 GMT, ExE Boss <d...@openjdk.java.net> wrote:
>> Alan Bateman has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Refresh > > src/java.base/share/classes/java/lang/ThreadLocal.java line 179: > >> 177: private T get(Thread t) { >> 178: ThreadLocalMap map = getMap(t); >> 179: if (map != null && map != ThreadLocalMap.NOT_SUPPORTED) { > > Due to the way `setInitialValue` is implemented, `getMap(t)` will currently > be called twice when `ThreadLocal`s are disabled. > > -------------------------------------------------------------------------------- > > This method should probably be changed so that when `map == > ThreadLocalMap.NOT_SUPPORTED`, it simply does: > > return initialValue(); > > > -------------------------------------------------------------------------------- > > Suggestion: > > if (map != null) { > if (map == ThreadLocalMap.NOT_SUPPORTED) { > return initialValue(); > } It's benign but what you suggest may be clearer - thanks! > src/java.base/share/classes/java/lang/ThreadLocal.java line 423: > >> 421: * Construct a new map without a table. >> 422: */ >> 423: ThreadLocalMap() { > > It might be possible for this to be `private`: > Suggestion: > > private ThreadLocalMap() { Yes, this can be private. ------------- PR: https://git.openjdk.java.net/jdk/pull/8166