Skip to content

Conversation

@motlin
Copy link
Contributor

@motlin motlin commented Jan 28, 2026

What's changed?

Added a precondition to TemporaryFolderToTempDir that skips conversion when TemporaryFolder is used within a RuleChain. The recipe now detects calls to RuleChain.outerRule() and RuleChain.around() that receive a TemporaryFolder argument, and skips the entire file in those cases.

What's your motivation?

When TemporaryFolder is converted to @TempDir File, the resulting File type does not implement TestRule, which breaks RuleChain.around() calls that expect a TestRule. By skipping these cases, the existing HandleExternalResourceRules recipe can handle them instead by adding @ExtendWith(ExternalResourceSupport.class).

Anything in particular you'd like reviewers to focus on?

The precondition operates at the file level—if any TemporaryFolder is used in a RuleChain, the entire file is skipped. This is conservative but simple. A more granular approach could convert standalone TemporaryFolder instances while skipping only those in RuleChain, but this adds complexity for an edge case (mixed usage in a single file).

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

  1. Granular per-field detection - More complex; would require tracking which specific fields are in RuleChain and only skipping those

Any additional context

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

@timtebeek timtebeek self-requested a review January 29, 2026 00:54
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.

Perfect addition; thanks a lot for adding this precondition! Best to be safe indeed.

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Jan 29, 2026
@timtebeek timtebeek merged commit 8f02e31 into openrewrite:main Jan 29, 2026
2 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Jan 29, 2026
@motlin motlin deleted the temporary-folder-rulechain branch January 29, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants