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

8274949: Use String.contains() instead of String.indexOf() in java.base #5559

Conversation

turbanoff
Copy link
Member

@turbanoff turbanoff commented Sep 17, 2021

String.contains was introduced in Java 5.
Some code in java.base still uses old approach with String.indexOf to check if String contains specified substring.
I propose to migrate such usages. Makes code shorter and easier to read.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8274949: Use String.contains() instead of String.indexOf() in java.base

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5559

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Sep 17, 2021

👋 Welcome back turbanoff! 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 openjdk bot commented Sep 17, 2021

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

  • core-libs
  • i18n
  • 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 core-libs net i18n labels Sep 17, 2021
Copy link
Contributor

@wangweij wangweij left a comment

security-related change looks fine.

@turbanoff turbanoff changed the title [PATCH] Use String.contains instead of String.index of in java.base [PATCH] Use String.contains instead of String.indexOf of in java.base Oct 8, 2021
@turbanoff turbanoff changed the title [PATCH] Use String.contains instead of String.indexOf of in java.base 8274949: Use String.contains() instead of String.indexOf() in java.base Oct 8, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 8, 2021

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

8274949: Use String.contains() instead of String.indexOf() in java.base

Reviewed-by: weijun, dfuchs, vtewari, lancea

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

  • 75f5145: 8274925: Shenandoah: shenandoah/TestAllocHumongousFragment.java test failed on lock rank check
  • 83c3771: 8273881: Metaspace: test repeated deallocations
  • 3f01d03: 8275021: Test serviceability/sa/TestJmapCore.java fails with: java.io.IOException: Stack frame 0x4 not found
  • 3f07337: 8273614: Shenandoah: intermittent timeout with ConcurrentGCBreakpoint tests
  • 0d80f6c: 8274379: Allow process of unsafe access errors in check_special_condition_for_native_trans
  • b870468: 8274347: Passing a nested switch expression as a parameter causes an NPE during compile
  • 110e38d: 8274753: ZGC: SEGV in MetaspaceShared::link_shared_classes
  • b7af890: 8274430: Remove some debug error printing code added in JDK-8017163
  • aaf2401: 8274927: Remove unnecessary G1ArchiveAllocator code
  • c55dd36: 8275008: gtest build failure due to stringop-overflow warning with gcc11
  • ... and 281 more: https://git.openjdk.java.net/jdk/compare/35f6f1d69f4238f16595b9b8f1d11db9e49d4cc9...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, @dfuch, @vyommani, @LanceAndersen) 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 ready rfr labels Oct 8, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 8, 2021

Webrevs

dfuch
dfuch approved these changes Oct 8, 2021
Copy link
Member

@dfuch dfuch left a comment

Changes to java.net look OK. Did you run tier1, tier2?

Copy link
Contributor

@vyommani vyommani left a comment

java.net changes look OK to me.

@turbanoff
Copy link
Member Author

@turbanoff turbanoff commented Oct 8, 2021

Did you run tier1, tier2?

I did run tier2. (tier1 is automatically checked by GithubActions).
No new tests failed. Only usual tests, which always fail on my machine, were failed.

@turbanoff
Copy link
Member Author

@turbanoff turbanoff commented Oct 11, 2021

/integrate

@openjdk openjdk bot added the sponsor label Oct 11, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 11, 2021

@turbanoff
Your change (at version 7462b1b) is now ready to be sponsored by a Committer.

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Nov 9, 2021

@turbanoff This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@RogerRiggs
Copy link
Contributor

@RogerRiggs RogerRiggs commented Nov 19, 2021

/sponsor
Passes Tier1-3

@openjdk
Copy link

@openjdk openjdk bot commented Nov 19, 2021

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

  • 09e8c8c: 8277342: vmTestbase/nsk/stress/strace/strace004.java fails with SIGSEGV in InstanceKlass::jni_id_for
  • 976c2bb: 8277212: GC accidentally cleans valid megamorphic vtable inline caches
  • 03f8c0f: 8275887: jarsigner prints invalid digest/signature algorithm warnings if keysize is weak/disabled
  • 936f7ff: 8276150: Quarantined jpackage apps are labeled as "damaged"
  • a022796: 8275745: Reproducible copyright headers
  • b1a1bf4: 8277427: Update jib-profiles.js to use JMH 1.33 devkit
  • 03debf2: 8276774: Cookie stored in CookieHandler not sent if user headers contain cookie
  • b15e6f0: 8277449: compiler/vectorapi/TestLongVectorNeg.java fails with release VMs
  • 11d819d: 8277439: G1: Correct include guard name in G1EvacFailureObjectsSet.hpp
  • 7a046e0: 8277371: Remove unnecessary DefNewGeneration::ref_processor_init()
  • ... and 811 more: https://git.openjdk.java.net/jdk/compare/35f6f1d69f4238f16595b9b8f1d11db9e49d4cc9...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Nov 19, 2021
@openjdk openjdk bot added integrated and removed ready rfr sponsor labels Nov 19, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Nov 19, 2021

@RogerRiggs @turbanoff Pushed as commit 6677554.

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

@turbanoff turbanoff deleted the use_String.contains_instead_of_String.indexOf_in_java.base branch Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs i18n integrated net security
6 participants