Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2025, 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
Expand Down Expand Up @@ -30,6 +30,7 @@
import java.nio.channels.spi.AsynchronousChannelProvider;
import java.io.IOException;
import java.io.FileDescriptor;
import java.util.Objects;
import java.util.Queue;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -299,6 +300,7 @@ public final boolean awaitTermination(long timeout, TimeUnit unit)
*/
@Override
public final void execute(Runnable task) {
Objects.requireNonNull(task, "task");
executeOnPooledThread(task);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2025, 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
Expand All @@ -23,7 +23,7 @@

/*
* @test
* @bug 4607272
* @bug 4607272 8364761
* @summary tests tasks can be submitted to a channel group's thread pool.
* @run main AsExecutor
*/
Expand Down Expand Up @@ -51,6 +51,19 @@ public static void main(String[] args) throws Exception {
testSimpleTask(group1);
testSimpleTask(group2);
testSimpleTask(group3);

// check null tasks with all groups
Executor[] executors = new Executor[] {
(Executor)group1, (Executor)group2, (Executor)group3
};
for (Executor executor : executors) {
try {
executor.execute(null);
throw new RuntimeException("No NullPointerException");
} catch (NullPointerException npe) {
System.out.println("Expected NullPointerException " + npe);
}
}
} finally {
group1.shutdown();
group2.shutdown();
Expand Down