Skip to content

8305902: (cs) Resolve default Charset only once in StreamEncoder and StreamDecoder #13443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

stsypanov
Copy link
Contributor

@stsypanov stsypanov commented Apr 12, 2023

If charsetName passed into forOutputStreamWriter() method is null then Charset.forName() is redundant as we can use already resolved default Charset.


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

Issue

  • JDK-8305902: (cs) Resolve default Charset only once in StreamEncoder and StreamDecoder

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13443

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 12, 2023

👋 Welcome back stsypanov! 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 openjdk bot added the rfr Pull request is ready for review label Apr 12, 2023
@openjdk
Copy link

openjdk bot commented Apr 12, 2023

@stsypanov 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 nio nio-dev@openjdk.org label Apr 12, 2023
try {
return new StreamDecoder(in, lock, Charset.forName(csn));
return new StreamDecoder(in, lock, csn == null ? Charset.defaultCharset() : Charset.forName(csn));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check the callers, it may be that the mapping of null to the default CS can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The callers throw NPE in case of null csName, but both are Encoder and Decoder are public. Will it be safe to remove explicit null check?

Copy link
Contributor

Choose a reason for hiding this comment

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

sun.nio.cs is a JDK internal package. The only usages of StreamDecoder.forInputStreamReader and StreamEncoder.forOutputStreamWriter. You should be able to quickly check the usages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DOne

Copy link
Contributor

@AlanBateman AlanBateman Apr 12, 2023

Choose a reason for hiding this comment

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

Can you confirm that you've run test/jdk:tier2 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still running, NIO tests are ok

==============================
Test summary
==============================
   TEST                                              TOTAL  PASS  FAIL ERROR   
   jtreg:test/jdk:jdk_nio                              475   475     0     0   
==============================
TEST SUCCESS

Copy link
Contributor

Choose a reason for hiding this comment

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

The jdk_io test group will probably exercise this code the most, running test/jdk:tier2 is best for the case as it will run the jdk_io, jdk_nio and other tests that directly/indirectly make use of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As of jdk:tier2 there are 4 failed tests, I suspect this is due to networking issues as I run them on virtual env

==============================
Test summary
==============================
   TEST                                              TOTAL  PASS  FAIL ERROR   
>> jtreg:test/jdk:tier2                               4046  4032     4    10 <<
==============================
TEST FAILURE
JT Harness : Tests that failed
com/sun/jndi/ldap/LdapPoolTimeoutTest.java: Multi-threaded client timeout tests for ldap pool
java/net/InetAddress/IsReachableViaLoopbackTest.java: ensure we can't ping external hosts via loopback if
java/net/InetAddress/getOriginalHostName.java: test functionality of getOriginalHostName(InetAddress)
java/net/MulticastSocket/Promiscuous.java: Test for interference when two sockets are bound to the same port but joined to different multicast groups

@mlbridge
Copy link

mlbridge bot commented Apr 12, 2023

Webrevs

Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

I looked at the callers and none of them expect null to be mapped to the default charset so I think this change is good, assuming you've run tier2.

@openjdk
Copy link

openjdk bot commented Apr 12, 2023

@stsypanov This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8305902: (cs) Resolve default Charset only once in StreamEncoder and StreamDecoder

Reviewed-by: alanb, bpb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 36 new commits pushed to the master branch:

  • 76cda9f: 8255548: Missing coverage for javax.xml.crypto.dom.DOMCryptoContext
  • b60604e: 8305794: Unused interface sun.security.util.PermissionFactory can be removed
  • 92521b1: 8305875: Test TraceVirtualThreadLocals should be run with continuations only
  • 00eb348: 8305937: com/sun/jdi/SetLocalWhileThreadInNative.java fails with -XX:+TieredCompilation
  • 1385c3d: 8305966: ProblemList com/sun/jdi/JdbLastErrorTest.java on windows-x64
  • 90b4006: 8305847: Improve diagnosability and resilience of HttpClient::close tests
  • d7dc474: 8305712: [MacOS] Deprecated Cocoa-NSEvent names
  • e0620b8: 8296420: javac has long lines in its command-line help
  • 6b9b7d1: 8304350: Font.getStringBounds calculates wrong width for TextAttribute.TRACKING other than 0.0
  • 2060c8e: 8305688: jdk build --with-memory-size=1024 broken by JDK-8305100
  • ... and 26 more: https://git.openjdk.org/jdk/compare/cd7d53c88c27eedbe16020b88c2219708d170a1e...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@AlanBateman, @bplb) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 12, 2023
@stsypanov
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Apr 13, 2023
@openjdk
Copy link

openjdk bot commented Apr 13, 2023

@stsypanov
Your change (at version 859def4) is now ready to be sponsored by a Committer.

@AlanBateman
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Apr 14, 2023

Going to push as commit 287bb06.
Since your change was applied there have been 37 commits pushed to the master branch:

  • 8a1639d: 8305936: JavaThread::create_system_thread_object has unused is_visible argument
  • 76cda9f: 8255548: Missing coverage for javax.xml.crypto.dom.DOMCryptoContext
  • b60604e: 8305794: Unused interface sun.security.util.PermissionFactory can be removed
  • 92521b1: 8305875: Test TraceVirtualThreadLocals should be run with continuations only
  • 00eb348: 8305937: com/sun/jdi/SetLocalWhileThreadInNative.java fails with -XX:+TieredCompilation
  • 1385c3d: 8305966: ProblemList com/sun/jdi/JdbLastErrorTest.java on windows-x64
  • 90b4006: 8305847: Improve diagnosability and resilience of HttpClient::close tests
  • d7dc474: 8305712: [MacOS] Deprecated Cocoa-NSEvent names
  • e0620b8: 8296420: javac has long lines in its command-line help
  • 6b9b7d1: 8304350: Font.getStringBounds calculates wrong width for TextAttribute.TRACKING other than 0.0
  • ... and 27 more: https://git.openjdk.org/jdk/compare/cd7d53c88c27eedbe16020b88c2219708d170a1e...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 14, 2023
@openjdk openjdk bot closed this Apr 14, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Apr 14, 2023
@openjdk
Copy link

openjdk bot commented Apr 14, 2023

@AlanBateman @stsypanov Pushed as commit 287bb06.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@stsypanov stsypanov deleted the enc-dec branch April 14, 2023 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated nio nio-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants