Skip to content

Recipe ReplaceLocalizedStreamMethods#532

Merged
cjobinabo merged 11 commits intoopenrewrite:mainfrom
BhavanaPidapa:Recipe_LocalizedStreamMethods
Aug 20, 2024
Merged

Recipe ReplaceLocalizedStreamMethods#532
cjobinabo merged 11 commits intoopenrewrite:mainfrom
BhavanaPidapa:Recipe_LocalizedStreamMethods

Conversation

@BhavanaPidapa
Copy link
Copy Markdown
Contributor

What's changed?

This PR contains recipe - org.openrewrite.java.migrate.ReplaceLocalizedStreamMethods
Rule:
image

What's your motivation?

This custom recipe replaces the occurrences of Runtime.getLocalizedInputStream and Runtime.getLocalizedOutputStream methods. The occurrence of getLocalizedInputStream(in) is replaced with in parameter and getLocalizedOutputStream(out) is replaced with out parameter.

Anyone you would like to review specifically?

@timtebeek @cjobinabo

Have you considered any alternatives or workarounds?

I created sample files, created a local plugin using
./gradlew publishToMavenLocal then ran it in the Java8 Sample App using mvn rewrite:dryRun

Attaching the rewrite.patch file
rewrite.patch

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Comment thread src/test/java/org/openrewrite/java/migrate/ReplaceLocalizedStreamMethodsTest.java Outdated
Comment thread src/test/java/org/openrewrite/java/migrate/ReplaceLocalizedStreamMethodsTest.java Outdated
Comment thread src/main/resources/META-INF/rewrite/java-version-11.yml Outdated
timtebeek and others added 2 commits August 14, 2024 23:39
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Thanks @BhavanaPidapa ! I've done a few quick polish commits but with that we're good from my side. @cjobinabo can do the final review & merge.

@timtebeek timtebeek added the recipe Recipe requested label Aug 14, 2024
Comment thread src/main/java/org/openrewrite/java/migrate/ReplaceLocalizedStreamMethods.java Outdated
Comment thread src/main/java/org/openrewrite/java/migrate/ReplaceLocalizedStreamMethods.java Outdated
@ranuradh ranuradh requested a review from cjobinabo August 15, 2024 13:50

@Override
public String getDescription() {
return "Replace `Runtime.getLocalizedInputStream(InputStream)` and `Runtime.getLocalizedOutputStream(with the argument)` with their direct arguments.";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the description, I think it would be helpful to add some info about why this change is made. That the earlier implementation of these methods simply returned the input parameter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the description as mentioned.

@cjobinabo cjobinabo merged commit 270244c into openrewrite:main Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recipe Recipe requested

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants