Skip to content

Conversation

@jhuttana
Copy link
Contributor

@jhuttana jhuttana commented Jun 28, 2022

Could you please review the changes?
This is to address the issue: https://bugs.openjdk.org/browse/JDK-8283082?jql=labels%20%3D%20starter-bug


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-8283082: sun.security.x509.X509CertImpl.delete("x509.info.validity") nulls out info field

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9306

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 28, 2022

👋 Welcome back jhuttana! 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 changed the title 8283082: sun.security.x509.X509CertImpl.delete("x509.info.validity") … 8283082: sun.security.x509.X509CertImpl.delete("x509.info.validity") nulls out info field Jun 28, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 28, 2022
@openjdk
Copy link

openjdk bot commented Jun 28, 2022

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

  • security

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 security security-dev@openjdk.org label Jun 28, 2022
@mlbridge
Copy link

mlbridge bot commented Jun 28, 2022

Webrevs


if (id.equalsIgnoreCase(INFO)) {
if (attr.getSuffix() != null) {
if (!(attr.getSuffix() != null)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can simply update the != to ==.

Also, please add a regression test. Since this is about testing an internal method, you are free to add @modules java.base/sun.security.x509 to access it.

Copy link
Contributor

@wangweij wangweij Jun 28, 2022

Choose a reason for hiding this comment

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

The test can be much simpler than the program included in the bug report. Something like this:

  1. Create an empty X509CertImpl
  2. Add "x509.info"
  3. Add "x509.info.issuer"
  4. Remove "x509.info.issuer"
  5. Add "x509.info.issuer" again

Without the fix, step 4 removes the whole info and step 5 would fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for taking a look at the PR.
Sure I will address these comments.

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 test can be much simpler than the program included in the bug report. Something like this:

1. Create an empty `X509CertImpl`

2. Add "x509.info"

3. Add "x509.info.issuer"

4. Remove "x509.info.issuer"

5. Add "x509.info.issuer" again

Without the fix, step 4 removes the whole info and step 5 would fail.
I am not a getting a clear idea about how to add issuer and delete etc.
Could you please point me to some example?

Copy link
Contributor

Choose a reason for hiding this comment

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

import sun.security.x509.X500Name;
import sun.security.x509.X509CertImpl;
import sun.security.x509.X509CertInfo;

public class A {
    public static void main(String[] args) throws Exception {
        var c = new X509CertImpl();
        c.set("x509.info", new X509CertInfo());
        c.set("x509.info.issuer", new X500Name("CN=one"));
        c.delete("x509.info.issuer");
        c.set("x509.info.issuer", new X500Name("CN=two"));
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for providing this!


if (id.equalsIgnoreCase(INFO)) {
if (attr.getSuffix() != null) {
if ((attr.getSuffix() == null)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove the parentheses that were added last time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I will do that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wangweij I have added the test case under: test/jdk/sun/security/x509/X509CertImpl/JDK8283082.java
As this is the first I am adding regression test so I am not sure whether the naming convention for the test case is right or not.

Copy link
Contributor

@wangweij wangweij Jul 7, 2022

Choose a reason for hiding this comment

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

Thanks for adding the test. It looks fine. The name is good.

Please add a copyright header and a @test block comment. You can find a nearby existing test file and see what they look like. Since the new test references internal classes, a @modules java.base/sun.security.x509 is necessary. Please run the test with the jtreg command to ensure everything is correct. Before your fix, the test should fail; and after it, it should succeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for adding the test. It looks fine. The name is good.

Please add a copyright header and a @test block comment. You can find a nearby existing test file and see what they look like. Since the new test references internal classes, a @modules java.base/sun.security.x509 is necessary. Please run the test with the jtreg command to ensure everything is correct. Before your fix, the test should fail; and after it, it should succeed.

Ok Sure :) Thanks for suggesting this.

@jhuttana
Copy link
Contributor Author

jhuttana commented Jul 7, 2022

I tried to look at what is cause for the failure and not able to locate the detail !!
I navigated till here: https://github.com/jhuttana/jdk/runs/7116877356?check_suite_focus=true but nothing was useful to find the details.
Could you please guide me where I should look at the details?

@wangweij
Copy link
Contributor

wangweij commented Jul 7, 2022

You can expand the "Run Tests" task and see the failed one (it's very long). It's a linux-x86 test and it mentions "thread". I've heard that thread-related tests could fail on linux-x86 because loom support was only added to linux-x64. Unless you heard from someone else that it's a real issue, I think you can ignore it.

@jhuttana
Copy link
Contributor Author

jhuttana commented Jul 7, 2022

You can expand the "Run Tests" task and see the failed one (it's very long). It's a linux-x86 test and it mentions "thread". I've heard that thread-related tests could fail on linux-x86 because loom support was only added to linux-x64. Unless you heard from someone else that it's a real issue, I think you can ignore it.

Sure I will check and confirm that. Thank you!

- Verified the newly added test case before and after the patch.
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jul 8, 2022
@jhuttana
Copy link
Contributor Author

jhuttana commented Jul 8, 2022

I made the suggested changes to the test case and verified before and after the patch with jtreg.
Steps followed are as below:

export JTREG_JAVA=/usr/bin/java

Before Patch:

jtreg/bin/jtreg -jdk:/root/jdk/build.master/linux-x86_64-server-release/images/jdk/ test/jdk/sun/security/x509/X509CertImpl/
Test results: passed: 5; failed: 1
Report written to /root/jdk/JTreport/html/report.html
Results written to /root/jdk/JTwork
Error: Some tests failed or other problems occurred.

# cat /root/jdk/JTwork/jtData/harness.trace
# Trace file started at 2022-07-08T04:47:29-0400
# JT Harness version 6.0
# class directory: /root/jdk/jtreg/lib/javatest.jar
# using java: /usr/lib/jvm/java-18-openjdk-18.0.1.0.10-1.rolling.fc36.x86_64
2022-07-08T04:47:29-0400 Starting tests.
Test suite class: com.sun.javatest.regtest.config.RegressionTestSuite
Test finder class: com.sun.javatest.regtest.config.RegressionTestFinder
2022-07-08T04:47:30-0400 Test starting: sun/security/x509/X509CertImpl/CertificateValidation.java
2022-07-08T04:47:30-0400 Test finished: sun/security/x509/X509CertImpl/CertificateValidation.java: Passed. Execution successful
2022-07-08T04:47:30-0400 Test starting: sun/security/x509/X509CertImpl/ECSigParamsVerifyWithCert.java
2022-07-08T04:47:31-0400 Test finished: sun/security/x509/X509CertImpl/ECSigParamsVerifyWithCert.java: Passed. Execution successful
2022-07-08T04:47:31-0400 Test starting: sun/security/x509/X509CertImpl/GetFingerprintError.java
2022-07-08T04:47:31-0400 Test finished: sun/security/x509/X509CertImpl/GetFingerprintError.java: Passed. Execution successful
2022-07-08T04:47:31-0400 Test starting: sun/security/x509/X509CertImpl/JDK8283082.java
2022-07-08T04:47:31-0400 Test finished: sun/security/x509/X509CertImpl/JDK8283082.java: Failed. Execution failed: `main' threw exception: java.lang.NullPointerException: Cannot invoke "sun.security.x509.X509CertInfo.set(String, Object)" because "this.info" is null
2022-07-08T04:47:31-0400 Test starting: sun/security/x509/X509CertImpl/V3Certificate.java
2022-07-08T04:47:32-0400 Test finished: sun/security/x509/X509CertImpl/V3Certificate.java: Passed. Execution successful
2022-07-08T04:47:32-0400 Test starting: sun/security/x509/X509CertImpl/Verify.java
2022-07-08T04:47:32-0400 Test finished: sun/security/x509/X509CertImpl/Verify.java: Passed. Execution successful
2022-07-08T04:47:32-0400 Doing post-run cleanup
2022-07-08T04:47:32-0400 Completed: Some tests did not pass

After Patch:

jtreg/bin/jtreg -jdk:/root/jdk/build.8283082/linux-x86_64-server-release/images/jdk/ test/jdk/sun/security/x509/X509CertImpl/
Directory "JTwork" not found: creating
Directory "JTreport" not found: creating
Test results: passed: 6
Report written to /root/jdk/JTreport/html/report.html
Results written to /root/jdk/JTwork

# cat /root/jdk/JTwork/jtData/harness.trace
# Trace file started at 2022-07-08T04:44:58-0400
# JT Harness version 6.0
# class directory: /root/jdk/jtreg/lib/javatest.jar
# using java: /usr/lib/jvm/java-18-openjdk-18.0.1.0.10-1.rolling.fc36.x86_64
2022-07-08T04:44:58-0400 Starting tests.
Test suite class: com.sun.javatest.regtest.config.RegressionTestSuite
Test finder class: com.sun.javatest.regtest.config.RegressionTestFinder
2022-07-08T04:44:58-0400 Test starting: sun/security/x509/X509CertImpl/CertificateValidation.java
2022-07-08T04:44:59-0400 Test finished: sun/security/x509/X509CertImpl/CertificateValidation.java: Passed. Execution successful
2022-07-08T04:44:59-0400 Test starting: sun/security/x509/X509CertImpl/ECSigParamsVerifyWithCert.java
2022-07-08T04:45:00-0400 Test finished: sun/security/x509/X509CertImpl/ECSigParamsVerifyWithCert.java: Passed. Execution successful
2022-07-08T04:45:00-0400 Test starting: sun/security/x509/X509CertImpl/GetFingerprintError.java
2022-07-08T04:45:01-0400 Test finished: sun/security/x509/X509CertImpl/GetFingerprintError.java: Passed. Execution successful
2022-07-08T04:45:01-0400 Test starting: sun/security/x509/X509CertImpl/JDK8283082.java
2022-07-08T04:45:02-0400 Test finished: sun/security/x509/X509CertImpl/JDK8283082.java: Passed. Execution successful
2022-07-08T04:45:02-0400 Test starting: sun/security/x509/X509CertImpl/V3Certificate.java
2022-07-08T04:45:04-0400 Test finished: sun/security/x509/X509CertImpl/V3Certificate.java: Passed. Execution successful
2022-07-08T04:45:04-0400 Test starting: sun/security/x509/X509CertImpl/Verify.java
2022-07-08T04:45:05-0400 Test finished: sun/security/x509/X509CertImpl/Verify.java: Passed. Execution successful
2022-07-08T04:45:05-0400 Doing post-run cleanup
2022-07-08T04:45:05-0400 Completed: All tests passed

So, this confirms that our test case is exercising the changes and producing the right results.
Could you please have a look at the recent changes?

@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 8, 2022
@wangweij
Copy link
Contributor

wangweij commented Jul 8, 2022

Great, this looks good. Please use 2022 in the copyright year of the test. You might also want to use your own company's name since this is a new test. See https://github.com/openjdk/jdk/blob/1ee80e03adfae5f428519f7c134e78a0f277a0a5/test/jdk/sun/security/pkcs11/Cipher/EncryptionPadding.java for an example or ask a colleague on what the correct words should be.

@jhuttana
Copy link
Contributor Author

jhuttana commented Jul 8, 2022

Great, this looks good. Please use 2022 in the copyright year of the test. You might also want to use your own company's name since this is a new test. See https://github.com/openjdk/jdk/blob/1ee80e03adfae5f428519f7c134e78a0f277a0a5/test/jdk/sun/security/pkcs11/Cipher/EncryptionPadding.java for an example or ask a colleague on what the correct words should be.

Sure. Thank you.

@jhuttana
Copy link
Contributor Author

@wangweij I have made the suggested changes to test case copyright section.
Thank you so much for reviewing this PR and guiding at every stage.

@jerboaa Thank you for suggesting the suitable changes to the test case.

Copy link
Contributor

@wangweij wangweij left a comment

Choose a reason for hiding this comment

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

Everything looks fine to me. Thanks.

@openjdk
Copy link

openjdk bot commented Jul 12, 2022

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

8283082: sun.security.x509.X509CertImpl.delete("x509.info.validity") nulls out info field

Reviewed-by: weijun

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

  • d9ca438: Merge
  • 3164c98: 8289148: j.l.foreign.VaList::nextVarg call could throw IndexOutOfBoundsException or even crash the VM
  • c3806b9: 8289709: fatal error: stuck in JvmtiVTMSTransitionDisabler::disable_VTMS_transitions
  • 39715f3: 8287902: UnreadableRB case in MissingResourceCauseTest is not working reliably on Windows
  • 62fbc3f: 8287379: Using @inheritdoc in an inapplicable context shouldn't crash javadoc
  • fed3af8: 8287809: Revisit implementation of memory session
  • e8568b8: 8290020: Deadlock in leakprofiler::emit_events during shutdown
  • 7f0e9bd: 8289745: JfrStructCopyFailed uses heap words instead of bytes for object sizes
  • 728157f: 8289917: Metadata for regionsRefilled of G1EvacuationStatistics event is wrong
  • 0e90697: 8290133: JFR: Remove unused methods in Bits.java
  • ... and 221 more: https://git.openjdk.org/jdk/compare/7905788e969727c81eea4397f0d9b918cdb5286a...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 (@wangweij) 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 Jul 12, 2022
@jhuttana
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 12, 2022

@jhuttana An unexpected error occurred during integration. No push attempt will be made. The error has been logged and will be investigated. It is possible that this error is caused by a transient issue; feel free to retry the operation.

@jhuttana
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 12, 2022

@jhuttana An unexpected error occurred during integration. No push attempt will be made. The error has been logged and will be investigated. It is possible that this error is caused by a transient issue; feel free to retry the operation.

@jhuttana
Copy link
Contributor Author

@wangweij Thanks for approving the PR.
As per instruction I typed /integrate and not sure why it is struck at some unexpected error!

@wangweij
Copy link
Contributor

I haven't seen this error before. Try again.

@jhuttana
Copy link
Contributor Author

I haven't seen this error before. Try again.

Oh okay :) Sure I will try again

@jhuttana
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 12, 2022

@jhuttana An unexpected error occurred during integration. No push attempt will be made. The error has been logged and will be investigated. It is possible that this error is caused by a transient issue; feel free to retry the operation.

@jhuttana
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 12, 2022
@openjdk
Copy link

openjdk bot commented Jul 12, 2022

@jhuttana
Your change (at version 54ce3cd) is now ready to be sponsored by a Committer.

@wangweij
Copy link
Contributor

/sponsor

@jhuttana
Copy link
Contributor Author

@wangweij Finally it worked somehow :)
Thank you!

@openjdk
Copy link

openjdk bot commented Jul 12, 2022

@wangweij @jhuttana An unexpected error occurred during sponsored integration. No push attempt will be made. The error has been logged and will be investigated. It is possible that this error is caused by a transient issue; feel free to retry the operation.

@wangweij
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Jul 12, 2022

Going to push as commit 31f7fc0.
Since your change was applied there have been 231 commits pushed to the master branch:

  • d9ca438: Merge
  • 3164c98: 8289148: j.l.foreign.VaList::nextVarg call could throw IndexOutOfBoundsException or even crash the VM
  • c3806b9: 8289709: fatal error: stuck in JvmtiVTMSTransitionDisabler::disable_VTMS_transitions
  • 39715f3: 8287902: UnreadableRB case in MissingResourceCauseTest is not working reliably on Windows
  • 62fbc3f: 8287379: Using @inheritdoc in an inapplicable context shouldn't crash javadoc
  • fed3af8: 8287809: Revisit implementation of memory session
  • e8568b8: 8290020: Deadlock in leakprofiler::emit_events during shutdown
  • 7f0e9bd: 8289745: JfrStructCopyFailed uses heap words instead of bytes for object sizes
  • 728157f: 8289917: Metadata for regionsRefilled of G1EvacuationStatistics event is wrong
  • 0e90697: 8290133: JFR: Remove unused methods in Bits.java
  • ... and 221 more: https://git.openjdk.org/jdk/compare/7905788e969727c81eea4397f0d9b918cdb5286a...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 12, 2022
@openjdk openjdk bot closed this Jul 12, 2022
@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 Jul 12, 2022
@openjdk
Copy link

openjdk bot commented Jul 12, 2022

@wangweij @jhuttana Pushed as commit 31f7fc0.

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

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 security security-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants