mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8259622: TreeMap.computeIfAbsent deviates from spec
Reviewed-by: smarks
This commit is contained in:
parent
d701babb06
commit
2c8e337dff
2 changed files with 26 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, 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
|
||||
|
@ -575,8 +575,12 @@ public class TreeMap<K,V>
|
|||
t = t.left;
|
||||
else if (cmp > 0)
|
||||
t = t.right;
|
||||
else
|
||||
else {
|
||||
if (t.value == null) {
|
||||
t.value = callMappingFunctionWithCheck(key, mappingFunction);
|
||||
}
|
||||
return t.value;
|
||||
}
|
||||
} while (t != null);
|
||||
} else {
|
||||
Objects.requireNonNull(key);
|
||||
|
@ -589,8 +593,12 @@ public class TreeMap<K,V>
|
|||
t = t.left;
|
||||
else if (cmp > 0)
|
||||
t = t.right;
|
||||
else
|
||||
else {
|
||||
if (t.value == null) {
|
||||
t.value = callMappingFunctionWithCheck(key, mappingFunction);
|
||||
}
|
||||
return t.value;
|
||||
}
|
||||
} while (t != null);
|
||||
}
|
||||
newValue = callMappingFunctionWithCheck(key, mappingFunction);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue