Fix(#1555): stale plugin descriptor for rebuilt reactor plugins#1655
Open
HarshMehta112 wants to merge 1 commit into
Open
Fix(#1555): stale plugin descriptor for rebuilt reactor plugins#1655HarshMehta112 wants to merge 1 commit into
HarshMehta112 wants to merge 1 commit into
Conversation
…ngRealmCacheEventSpy Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
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.
Problem
When a project builds a Maven plugin in its own reactor (e.g.
mvnd verify),subsequent daemon invocations keep serving a stale plugin descriptor even
after the plugin's code changes. The reported symptom is the
threadSafeflagnot being re-read: toggle a Mojo's
@Mojo(threadSafe = ...), rebuild, and thedaemon still uses the old value (#877).
Root cause
InvalidatingRealmCacheEventSpyalready evicts reactor plugin realms andextension realms at the end of each build (any realm whose URLs point under
multiModuleProjectDirectory). However, thePluginDescriptor— which carriesthe
threadSafeflag,@Parameterdefault values, etc. — is stored in aseparate singleton cache (
InvalidatingPluginDescriptorCache) that was neverevicted there.
The timestamp-based invalidation cannot cover this case: with
verify/test(no
install), a reactor plugin is resolved to atarget/classesdirectory.A directory's
lastModifiedTimedoes not change when a.classfile inside itis rewritten, so the cached descriptor's file state looks unchanged and the stale
descriptor is reused. (The existing
ModuleAndPluginNativeITdoes not hit thisbecause it uses
clean install, which rewrites the jar in the local repo andbumps its mtime, invalidating everything.)
Fix
Extend
InvalidatingRealmCacheEventSpyto also evict theInvalidatingPluginDescriptorCacheandInvalidatingPluginArtifactsCacheentries that refer to artifacts in the build tree (or match the configured
mvnd.pluginRealmEvictPattern) atMavenExecutionResult. Eviction is driven byCacheRecord.getDependencyPaths(), consistent with the existing realm eviction.Test
Adds
ReactorPluginDescriptorReloadTest, which runsclean package(no install,so the plugin stays a
target/classesdirectory), changes a@ParameterdefaultValuebetween two daemon invocations, and asserts the new value takeseffect. This fails before the fix and passes after.
Fixes #1555