RFR: 8234131: Miscellaneous changes imported from jsr166 CVS 2020-12 [v3]

Pavel Rappo prappo at openjdk.java.net
Wed Dec 9 18:43:36 UTC 2020


On Tue, 8 Dec 2020 21:15:48 GMT, Martin Buchholz <martin at openjdk.org> wrote:

>> 8234131: Miscellaneous changes imported from jsr166 CVS 2020-12
>
> Martin Buchholz has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains one commit:
> 
>   JDK-8234131

The changes to doc comments look good.

Thanks for incorporating my earlier code snippet suggestions published on [concurrency-interest](http://cs.oswego.edu/pipermail/concurrency-interest/2020-November/017264.html)!

src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java line 2102:

> 2100:      *        dropped.cancel(false); // also consider logging the failure
> 2101:      *     e.execute(r);             // retry
> 2102:      * }}}</pre>

I tried to reify that code snippet:

$ cat MySnippet.java 
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

public class MySnippet {
    public static void main(String[] args) {
        new RejectedExecutionHandler() {
            public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
                Future<?> dropped = e.getQueue().poll();
                if (dropped != null)
                    dropped.cancel(false); // also consider logging the failure
                e.execute(r);              // retry
            }
        };
    }
}
$ javac MySnippet.java 
MySnippet.java:9: error: incompatible types: Runnable cannot be converted to Future<?>
                Future<?> dropped = e.getQueue().poll();
                                                     ^
1 error
$ 
Separately, it seems that the `if` statement uses a 3-space indent which is surprising to see in the JSR 166 code base.

-------------

Marked as reviewed by prappo (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/1647


More information about the core-libs-dev mailing list