Skip to content

Conversation

JohannisK
Copy link
Contributor

What's changed?

Change .end() calls on Inflater and Deflater to .close() from autoclosable

What's your motivation?

In Java 25 these classes implement AutoClosable. This change prepares the code for tre-with-resources.

Another recipe is in the making to use try-with-resources when possible. That recipe can be ran after this one.

@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Sep 9, 2025
@JohannisK JohannisK mentioned this pull request Sep 9, 2025
5 tasks
@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Sep 9, 2025
JohannisK and others added 3 commits September 9, 2025 10:10
…rDeflaterToAutoCloseable.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…rDeflaterToAutoCloseable.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@JohannisK JohannisK force-pushed the inflater_deflater_autoclosable branch from 93bf18e to 0573321 Compare September 9, 2025 08:26
JohannisK and others added 2 commits September 9, 2025 10:29
diff --git c/src/main/java/org/openrewrite/java/migrate/util/MigrateInflaterDeflaterToAutoCloseable.java i/src/main/java/org/openrewrite/java/migrate/util/MigrateInflaterDeflaterToAutoCloseable.java
index 57cada2..28a2ad0 100644
--- c/src/main/java/org/openrewrite/java/migrate/util/MigrateInflaterDeflaterToAutoCloseable.java
+++ i/src/main/java/org/openrewrite/java/migrate/util/MigrateInflaterDeflaterToAutoCloseable.java
@@ -17,11 +17,7 @@ package org.openrewrite.java.migrate.util;

 import lombok.EqualsAndHashCode;
 import lombok.Value;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Preconditions;
 import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.java.JavaIsoVisitor;
 import org.openrewrite.java.MethodMatcher;
 import org.openrewrite.java.search.UsesJavaVersion;
 import org.openrewrite.java.search.UsesType;
Copy link
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.

I've swapped out the imperative recipe for a declarative one, such that there's less code to maintain.

@timtebeek timtebeek added recipe Recipe requested java 25+ labels Sep 9, 2025
@timtebeek timtebeek merged commit 201477d into main Sep 9, 2025
1 check passed
@timtebeek timtebeek deleted the inflater_deflater_autoclosable branch September 9, 2025 08:37
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Sep 9, 2025
mergify bot added a commit to robfrank/linklift that referenced this pull request Sep 21, 2025
…16.0 to 3.17.0 [skip ci]

[//]: # (dependabot-start)
⚠️ \*\*Dependabot is rebasing this PR\*\* ⚠️
Rebasing might not happen immediately, so don't worry if this takes some time.
Note: if you make any changes to this PR yourself, they will take precedence over the rebase.
---
[//]: # (dependabot-end)
Bumps [org.openrewrite.recipe:rewrite-migrate-java](https://github.com/openrewrite/rewrite-migrate-java) from 3.16.0 to 3.17.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-migrate-java's releases](https://github.com/openrewrite/rewrite-migrate-java/releases).*

> 3.17.0
> ------
>
> What's Changed
> --------------
>
> * Upgrading spotbugs plugin and mapstruct by [`@​steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-migrate-java#818](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/818)
> * Migrate to `Process#waitFor(Duration)` as part of Java 25 upgrade by [`@​JohannisK`](https://github.com/JohannisK) in [openrewrite/rewrite-migrate-java#840](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/840)
> * Inflater deflater autoclosable by [`@​JohannisK`](https://github.com/JohannisK) in [openrewrite/rewrite-migrate-java#843](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/843)
> * Java 25: Unused variable to underscore by [`@​JohannisK`](https://github.com/JohannisK) in [openrewrite/rewrite-migrate-java#844](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/844)
> * Use `ZipException` instead of the deprecated `ZipError` by [`@​JohannisK`](https://github.com/JohannisK) in [openrewrite/rewrite-migrate-java#841](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/841)
>
> **Full Changelog**: <openrewrite/rewrite-migrate-java@v3.16.0...v3.17.0>


Commits

* [`5037eac`](openrewrite/rewrite-migrate-java@5037eac) Use `ZipException` instead of the deprecated `ZipError` ([#841](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/841))
* [`d192070`](openrewrite/rewrite-migrate-java@d192070) Fix preconditions and remove intermediate `UpgradeBuildToJava25`
* [`1a07e7f`](openrewrite/rewrite-migrate-java@1a07e7f) Java 25: Unused variable to underscore ([#844](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/844))
* [`804c6a9`](openrewrite/rewrite-migrate-java@804c6a9) OpenRewrite recipe best practices
* [`201477d`](openrewrite/rewrite-migrate-java@201477d) Inflater deflater autoclosable ([#843](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/843))
* [`7e53332`](openrewrite/rewrite-migrate-java@7e53332) Migrate to `Process#waitFor(Duration)` as part of Java 25 upgrade ([#840](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/840))
* [`28c66ec`](openrewrite/rewrite-migrate-java@28c66ec) [Auto] SDKMAN! Java candidates as of 2025-09-08T1016
* [`1778ec6`](openrewrite/rewrite-migrate-java@1778ec6) Guard against new Ehcache releases in test output
* [`db99c93`](openrewrite/rewrite-migrate-java@db99c93) Update comment with regards to switch pattern matching recipes
* [`a6f20e4`](openrewrite/rewrite-migrate-java@a6f20e4) [Auto] SDKMAN! Java candidates as of 2025-09-01T1016
* Additional commits viewable in [compare view](openrewrite/rewrite-migrate-java@v3.16.0...v3.17.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-migrate-java&package-manager=maven&previous-version=3.16.0&new-version=3.17.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java 25+ recipe Recipe requested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants