-
Bug
-
Resolution: Fixed
-
P3
-
21
-
b06
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8312903 | 21.0.1 | Alan Bateman | P3 | Resolved | Fixed | b04 |
JDK-8311916 | 21 | Alan Bateman | P3 | Resolved | Fixed | b32 |
Java SE 21 & JDK 21
DRAFT 21-ea+28-LTS-2377
Many method's specs in j.l.ScopedValue+Carrier contain the following assertion
"Once closed, StructureViolationException is thrown."
e.g. https://download.java.net/java/early_access/jdk21/docs/api/java.base/java/lang/ScopedValue.Carrier.html#call(java.util.concurrent.Callable)
As experiments show it seems the spec should mention IllegalStateException instead of StructureViolationException
UPD: this original note above is based on reading of the following block that is repeated 6 times in the specs for j.l.ScopedValue+Carrier methods
========
Scoped values are intended to be used in a structured manner. If op creates a StructuredTaskScope but does not close it, then exiting op causes the underlying construct of each StructuredTaskScope created in the dynamic scope to be closed. This may require blocking until all child threads have completed their sub-tasks. The closing is done in the reverse order that they were created. Once closed, StructureViolationException is thrown.
========
The last sentence could give an impression that it's the scope instance which is throwing StructureViolationException when we are calling, say, StructuredTaskScope::fork after the scope is closed, - while it's throwing IllegalStateException.
Actually the carrier's methods are expected to throw StructureViolationException if STS was not properly closed by the op.
DRAFT 21-ea+28-LTS-2377
Many method's specs in j.l.ScopedValue+Carrier contain the following assertion
"Once closed, StructureViolationException is thrown."
e.g. https://download.java.net/java/early_access/jdk21/docs/api/java.base/java/lang/ScopedValue.Carrier.html#call(java.util.concurrent.Callable)
As experiments show it seems the spec should mention IllegalStateException instead of StructureViolationException
UPD: this original note above is based on reading of the following block that is repeated 6 times in the specs for j.l.ScopedValue+Carrier methods
========
Scoped values are intended to be used in a structured manner. If op creates a StructuredTaskScope but does not close it, then exiting op causes the underlying construct of each StructuredTaskScope created in the dynamic scope to be closed. This may require blocking until all child threads have completed their sub-tasks. The closing is done in the reverse order that they were created. Once closed, StructureViolationException is thrown.
========
The last sentence could give an impression that it's the scope instance which is throwing StructureViolationException when we are calling, say, StructuredTaskScope::fork after the scope is closed, - while it's throwing IllegalStateException.
Actually the carrier's methods are expected to throw StructureViolationException if STS was not properly closed by the op.
- backported by
-
JDK-8311916 ScopedValue throwing StructureViolationException should be clearer
-
- Resolved
-
-
JDK-8312903 ScopedValue throwing StructureViolationException should be clearer
-
- Resolved
-
- csr for
-
JDK-8311024 ScopedValue throwing StructureViolationException should be clearer
-
- Closed
-
- links to
-
Commit openjdk/jdk21/3bb37508
-
Commit openjdk/jdk/623cfcd0
-
Review openjdk/jdk21/113
-
Review openjdk/jdk/14679
(2 links to)