Fix UpdateMockWebServerDispatcher classpath lookup#975
Merged
knutwannheden merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
The recipe asked for `okhttp-4.10` via `classpathFromResources`, but that artifact is only bundled in the test type table — production runs of the recipe (e.g. via the Moderne CLI) fail with `IllegalArgumentException: Unable to find classpath resource dependencies beginning with: 'okhttp-4.10'` whenever a project has `mockwebserver` on its classpath. The template snippet only references `MockResponse` and `.build()` (itself a 5.x-only method, so the parser is already lenient about unresolved members), so dropping the unused `okhttp-4.10` request is sufficient and matches the sister `UpdateMockWebServerMockResponse` recipe, which uses just `mockwebserver3`.
UpdateMockWebServerDispatcher classpath lookup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
UpdateMockWebServerDispatcher(added in Fix MockWebServer Dispatcher return type and RecordedRequest renames #972) asksJavaParserfor theokhttp-4.10classpath resource:That artifact is only declared as a
testParserClasspathdependency, so it lives in the test type table (src/test/resources/META-INF/rewrite/classpath.tsv.gz) and is not bundled with the published recipe artifact. Local unit tests pass because both type tables are on the classpath; production runs (Moderne CLI, etc.) blow up the moment they hit aDispatcher.dispatch()override:Caught today across three
rewrite-maventest files inopenrewrite/rewrite(results).Summary
"okhttp-4.10"argument from theclasspathFromResourcescall. The template snippet only referencesMockResponseand.build()(a 5.x-only method, so the template parser is already tolerating unresolved members); no okhttp type is needed at template-parse time. Sibling recipeUpdateMockWebServerMockResponseuses just"mockwebserver3"for the same kind of template and works fine.Test plan
UpdateMockWebServerMockResponseTest(which exercises the sameDispatcher.dispatch()rewrite path viadispatcherReturnTypeAndGetPathRename) still passes with only"mockwebserver-4.10"requested by the recipe.UpgradeOkHttpMockWebServerTest— green.Reproduction
Run any recipe-execution path that exercises
UpdateMockWebServerDispatcheragainst a project whose classpath hasmockwebserver:4.10.xbut does not bundleokhttp:4.10.xas a separately-named jar. The cleanest reproducer is the flagship run linked above; the affected files were:rewrite-maven/src/test/java/org/openrewrite/maven/MavenParserTest.javarewrite-maven/src/test/java/org/openrewrite/maven/UpgradeDependencyVersionTest.javarewrite-maven/src/test/java/org/openrewrite/maven/internal/MavenPomDownloaderTest.java