Skip to content
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

8282723: Add constructors taking a cause to JSSE exceptions #7722

Closed
wants to merge 6 commits into from

Conversation

XueleiFan
Copy link
Member

@XueleiFan XueleiFan commented Mar 7, 2022

Please review this small API enhancement to add the usual constructors taking a cause to javax.net.ssl exceptions. The use of initCause in the JSSE implementation code is updated to use the new constructors accordingly.

Please review the CSR: https://bugs.openjdk.java.net/browse/JDK-8282724


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed
  • Change requires a CSR request to be approved

Issues

  • JDK-8282723: Add constructors taking a cause to JSSE exceptions
  • JDK-8282724: Add constructors taking a cause to JSSE exceptions (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7722/head:pull/7722
$ git checkout pull/7722

Update a local copy of the PR:
$ git checkout pull/7722
$ git pull https://git.openjdk.java.net/jdk pull/7722/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7722

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7722.diff

@XueleiFan
Copy link
Member Author

/csr

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 7, 2022

👋 Welcome back xuelei! 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 csr Pull request needs approved CSR before integration rfr Pull request is ready for review labels Mar 7, 2022
@openjdk
Copy link

openjdk bot commented Mar 7, 2022

@XueleiFan an approved CSR request is already required for this pull request.

@openjdk
Copy link

openjdk bot commented Mar 7, 2022

@XueleiFan The following labels will be automatically applied to this pull request:

  • net
  • security

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

@openjdk openjdk bot added security security-dev@openjdk.org net net-dev@openjdk.org labels Mar 7, 2022
@mlbridge
Copy link

mlbridge bot commented Mar 7, 2022

Webrevs

@dfuch
Copy link
Member

dfuch commented Mar 7, 2022

LGTM. Someone from security-dev should probably review this too.

@@ -48,8 +46,7 @@
*
* @param reason describes the problem.
*/
public SSLException(String reason)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for changing the style. I've always hated the extra vertical space. :)

@rhalade
Copy link
Member

rhalade commented Mar 7, 2022

Please consider adding simple tests to cover new APIs, similar to https://github.com/openjdk/jdk/pull/7705/files#diff-28e1041be519b6266b3b92aea29c5d8917c279880da7e5e9823a518196e96ea5

@rhalade
Copy link
Member

rhalade commented Mar 7, 2022

throw (SSLHandshakeException)(new SSLHandshakeException(
"Could not generate secret").initCause(gse));
throw new SSLHandshakeException(
"Could not generate secret", gse);
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't quite tell given the coloring, but did this get changed into a tab?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I added 4 more whitespaces in line 158.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, missed that. Good to be consistent.

throw (SSLHandshakeException) new SSLHandshakeException(
"Could not generate ECPublicKey").initCause(e);
throw new SSLHandshakeException(
"Could not generate ECPublicKey", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think combining these lines would be < 80 chars

Copy link
Member Author

Choose a reason for hiding this comment

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

The exception name is too long to have in one line. There are 83 characters in total if combining line 203 and 204. 3 characters exceeding 80 chars per line limit is not easy to tell with eyes.

Copy link
Contributor

Choose a reason for hiding this comment

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

The 80 character recommendation isn't a hard limit, I favor readability in the 80-100 char range.

@@ -263,8 +263,7 @@ void setDeliverStream(OutputStream outputStream) {
} catch (BadPaddingException bpe) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the copyright need to get updated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, I missed this file.

Copy link
Contributor

@bradfordwetmore bradfordwetmore left a comment

Choose a reason for hiding this comment

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

Didn't see any unit tests for the new methods. Can approve after they are included.

@XueleiFan
Copy link
Member Author

@XueleiFan XueleiFan closed this Mar 7, 2022
@XueleiFan
Copy link
Member Author

Update following for SSLPeerUnverifiedException -

https://github.com/openjdk/jdk/blob/master/src/java.naming/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java#L439

Hm, I will check more usage out of the JSSE implementation code. Thank you!

@XueleiFan
Copy link
Member Author

Please consider adding simple tests to cover new APIs, similar to https://github.com/openjdk/jdk/pull/7705/files#diff-28e1041be519b6266b3b92aea29c5d8917c279880da7e5e9823a518196e96ea5

Thank you for the reference. I will add some test cases.

@XueleiFan XueleiFan reopened this Mar 7, 2022
@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Mar 7, 2022
@XueleiFan
Copy link
Member Author

ping ...

@@ -484,7 +484,7 @@ SSLContext getSSLContext(String keyFilename, String trustFilename)
*/
if ((local != null) && (remote != null)) {
// If both failed, return the curthread's exception.
local.initCause(remote);
local.addSuppressed(remote);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright 2016->2022.

@@ -480,7 +480,7 @@ SSLContext getSSLContext(String keyFilename, String trustFilename)
*/
if ((local != null) && (remote != null)) {
// If both failed, return the curthread's exception.
local.initCause(remote);
local.addSuppressed(remote);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright 2016->2022.

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

I am unsure about the third-party copyrights on these files. They are probably ok, but you should get approval by someone more familiar.

Secondly, in the Oracle environment, we generally use a trailing , comma after the date. e.g.

Copyright (C) 2022,

Copy link
Member

Choose a reason for hiding this comment

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

The location of the copyright is fine. No need to enforce Oracle date formatting.

import javax.net.ssl.SSLHandshakeException;
import java.util.Objects;

public class CheckSSLHandshakeException {
Copy link
Contributor

Choose a reason for hiding this comment

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

My personal preference would have been to combine all of these into a single testfile to minimize clutter in the logs and directories, but no strong objection.

Copy link
Member Author

Choose a reason for hiding this comment

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

I understand. I would like to have them in separated test cases so that it is easier to monitor the regressions in the future.

@@ -349,13 +349,13 @@ private void runTest(boolean direct) throws Exception {
} finally {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright update

@@ -544,7 +544,7 @@ private void bootup() throws Exception {
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright update

Copy link
Contributor

@bradfordwetmore bradfordwetmore left a comment

Choose a reason for hiding this comment

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

Please see latest comments and let's verify the copyright is correct, but otherwise looks good.

@openjdk
Copy link

openjdk bot commented Mar 18, 2022

@XueleiFan 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:

8282723: Add constructors taking a cause to JSSE exceptions

Reviewed-by: wetmore, iris

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 122 new commits pushed to the master branch:

  • 8384ac4: 8283057: Update GCC to version 11.2 for Oracle builds on Linux
  • d8893fa: 8283059: Uninitialized warning in check_code.c with GCC 11.2
  • ff0b092: 8278794: Infinite loop in DeflaterOutputStream.finish()
  • b2aa085: 8283378: JFR: Checkpoint classes not renamed properly
  • 85cc6f1: 8283315: jrt-fs.jar not always deterministically built
  • c72bcfc: 8283289: JFR: Rename CheckPoint
  • 4b5079b: 8283202: Potential off-read when checking JFR's status in awaitFinished
  • b96cb04: 8283353: compiler/c2/cr6865031/Test.java and compiler/runtime/Test6826736.java fails on x86_32
  • cab4ff6: 8283225: ClassLoader.c produces incorrect OutOfMemory Exception when length is 0 (aix)
  • d83cee9: 8282407: Missing ')' in MacResources.properties
  • ... and 112 more: https://git.openjdk.java.net/jdk/compare/974ef5542fe52f9cb8ffd8751df8a020bca503c9...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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 18, 2022
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

The location of the copyright is fine. No need to enforce Oracle date formatting.

@bradfordwetmore
Copy link
Contributor

Thanks, @irisclark!

@XueleiFan
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Mar 20, 2022

Going to push as commit 4df6742.
Since your change was applied there have been 128 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 20, 2022
@openjdk openjdk bot closed this Mar 20, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 20, 2022
@openjdk
Copy link

openjdk bot commented Mar 20, 2022

@XueleiFan Pushed as commit 4df6742.

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

@XueleiFan XueleiFan deleted the JDK-8282723 branch March 20, 2022 06:49
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 net net-dev@openjdk.org security security-dev@openjdk.org
6 participants