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

8314199: Initial size PBEKeyFactory#validTypes is not up-to-date #16103

Closed
wants to merge 4 commits into from

Conversation

driverkt
Copy link
Member

@driverkt driverkt commented Oct 9, 2023

fixes JDK-8314199 by initializing the HashSet with a more accurate number


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-8314199: Initial size PBEKeyFactory#validTypes is not up-to-date (Bug - P5)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16103

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 9, 2023

👋 Welcome back kdriver! 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 Oct 9, 2023
@openjdk
Copy link

openjdk bot commented Oct 9, 2023

@driverkt 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 Oct 9, 2023
@mlbridge
Copy link

mlbridge bot commented Oct 9, 2023

Webrevs

@@ -56,7 +56,7 @@ private PBEKeyFactory(String keytype) {
}

static {
validTypes = HashSet.newHashSet(17);
validTypes = HashSet.newHashSet(21);
Copy link
Member

Choose a reason for hiding this comment

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

Rather than having to change the initial size and keep it synchronized with all the subsequent adds, could we just change the type of validTypes to Set<String> and initialize it using Set.of(E...)? It seems like that would allow you to set all the values directly in the declaration up on line 49, would remove the need for the static block and I think you could even declare validTypes final, couldn't you? And any new additions to the set could simply be added and not worry about setting an accurate count in the constructor.

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 wondered about an approach like this. I'll push another commit with these changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think we'll lose performance in a meaningful way? One of the guarantees of HashSet is constant-time operations.

There is no such guarantee for Set. The number of members is probably small enough, relatively speaking, to not affect things much at creation time (and we only do this once); however, lookup time (in engineGetKeySpec and engineTranslateKey) might take a small hit if these methods are called repeatedly.

Let me know whether you think this is a valid concern. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

I think there could be sight timing variations between HashSet and whatever Set implementation is returned by Set.of() but creation only happens once as you stated, and iterations over 20-ish elements just seems like the variance would be negligible in any real-world use cases.

Choose a reason for hiding this comment

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

How about changing to use the HashSet(Collection<? extends E> c) constructor? First construct a collection with the various algorithms and then construct validType w/ this collection. validType can be made unmodifiable also since it's read only.

Copy link
Member

@jnimeh jnimeh left a comment

Choose a reason for hiding this comment

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

LGTM.

@openjdk
Copy link

openjdk bot commented Oct 9, 2023

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

8314199: Initial size PBEKeyFactory#validTypes is not up-to-date

Reviewed-by: jnimeh

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

  • f61499c: 8316608: Enable parallelism in vmTestbase/gc/vector tests
  • 3ff5a78: 8317693: Unused parameter to Tokens.Token.comment method
  • 508fa71: 8317736: Stream::handleReset locks twice
  • 1f06325: 8317471: ListFormat::parseObject() spec can be improved on parsePosition valid values

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 Oct 9, 2023
@driverkt
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Oct 10, 2023

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

  • d313915: 8316233: VirtualThreadStart events should not be thread-filtered
  • 053f456: 8316447: 8 sun/management/jmxremote tests ignore VM flags
  • 5b311f2: 8316446: 4 sun/management/jdp tests ignore VM flags
  • 8e0686b: 8317633: Modernize text.testlib.HexDumpReader
  • 5e8d893: 8317631: Refactor ChoiceFormat tests to use JUnit
  • f61499c: 8316608: Enable parallelism in vmTestbase/gc/vector tests
  • 3ff5a78: 8317693: Unused parameter to Tokens.Token.comment method
  • 508fa71: 8317736: Stream::handleReset locks twice
  • 1f06325: 8317471: ListFormat::parseObject() spec can be improved on parsePosition valid values

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Oct 10, 2023

@driverkt Pushed as commit e882718.

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

@driverkt driverkt deleted the 8314199 branch October 10, 2023 05:44
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
3 participants