Skip to content

Conversation

@shruacha1234
Copy link
Contributor

@shruacha1234 shruacha1234 commented Dec 26, 2025

Fall back to the default SelectorProvider by logging an error when an invalid provider is specified via the java.nio.channels.spi.SelectorProvider system property.
The bug report for the same: https://bugs.openjdk.org/browse/JDK-8374368


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Integration blocker

 ⚠️ Title mismatch between PR and JBS for issue JDK-8374368

Issue

  • JDK-8374368: SelectorProvider.provider() throws CNFE if system property java.nio.channels.spi.SelectorProvider set to bad value (Bug - P4) ⚠️ Title mismatch between PR and JBS.

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28998/head:pull/28998
$ git checkout pull/28998

Update a local copy of the PR:
$ git checkout pull/28998
$ git pull https://git.openjdk.org/jdk.git pull/28998/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28998

View PR using the GUI difftool:
$ git pr show -t 28998

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28998.diff

Using Webrev

Link to Webrev Comment

… in ClassNotFoundException instead of falling back to default provider

Signed-off-by: Shruthi <[email protected]>
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 26, 2025

👋 Welcome back sacharya! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Dec 26, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Dec 26, 2025

@shruacha1234 The following label will be automatically applied to this pull request:

  • nio

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 26, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 26, 2025

Webrevs

@shruacha1234
Copy link
Contributor Author

Validated the fix with the personal build

SelectorTypeCheck.java

import java.nio.channels.Selector;
public class SelectorTypeCheck {
    public static void main(String[] args) throws Exception {
        try (Selector selector = Selector.open()) {
            System.out.println("Selector provider: " + selector.provider());
            System.out.println("Selector implementation class: " + selector.getClass().getName());
        }
    }
}
jdk/bin/java SelectorTypeCheck
Selector provider: sun.nio.ch.EPollSelectorProvider@68968cd4
Selector implementation class: sun.nio.ch.EPollSelectorImpl

jdk/bin/java -Djava.nio.channels.spi.SelectorProvider=abc SelectorTypeCheck

Invalid SelectorProvider specified: abc. Falling back to default provider.
Selector provider: sun.nio.ch.EPollSelectorProvider@7f1338e3
Selector implementation class: sun.nio.ch.EPollSelectorImpl

jdk/bin/java -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider SelectorTypeCheck

Selector provider: sun.nio.ch.PollSelectorProvider@b3462c23
Selector implementation class: sun.nio.ch.PollSelectorImpl

Also I have triggred java_nio, java_io and jdk_net tests. All of them are passing

20:55:05  TEST TARGETS SUMMARY
20:55:05  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20:55:05  PASSED test targets:
20:55:05  	jdk_io_0 - Test results: passed: 395 
20:55:05  	jdk_io_1 - Test results: passed: 395 
20:55:05  	jdk_nio_0 - Test results: passed: 445 
20:55:05  	jdk_nio_1 - Test results: passed: 445 

@AlanBateman
Copy link
Contributor

This is not a bug, the lookup is specified to fall if there is a configuration error.

InvocationTargetException |
InstantiationException x) {
throw new ServiceConfigurationError(null, x);
} catch (Throwable t) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix should have a regression test, based on the provided reproducer.
If it can't be implemented, then bug should have 'noreg-' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nio [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants