-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: 7u51, 9
-
Component/s: core-libs
A DESCRIPTION OF THE PROBLEM :
In the second code example of <code>Collections.synchronizedSortedMap</code> is the variable <code>s</code> and not <code>s2</code> used.
That's not really a problem. :-) But I hope I can make the documentation better.
Greetings
Markus Wolf
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
synchronizedSortedMap
...
Set s2 = m2.keySet(); // Needn't be in synchronized block
...
synchronized (m) { // Synchronizing on m, not m2 or s2!
Iterator i = s2.iterator(); // Must be in synchronized block
...
ACTUAL -
synchronizedSortedMap
...
Set s2 = m2.keySet(); // Needn't be in synchronized block
...
synchronized (m) { // Synchronizing on m, not m2 or s2!
Iterator i = s.iterator(); // Must be in synchronized block
...
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedSortedMap%28java.util.SortedMap%29
In the second code example of <code>Collections.synchronizedSortedMap</code> is the variable <code>s</code> and not <code>s2</code> used.
That's not really a problem. :-) But I hope I can make the documentation better.
Greetings
Markus Wolf
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
synchronizedSortedMap
...
Set s2 = m2.keySet(); // Needn't be in synchronized block
...
synchronized (m) { // Synchronizing on m, not m2 or s2!
Iterator i = s2.iterator(); // Must be in synchronized block
...
ACTUAL -
synchronizedSortedMap
...
Set s2 = m2.keySet(); // Needn't be in synchronized block
...
synchronized (m) { // Synchronizing on m, not m2 or s2!
Iterator i = s.iterator(); // Must be in synchronized block
...
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedSortedMap%28java.util.SortedMap%29