Skip to content

Commit

Permalink
Fix PluginDescriptorCache
Browse files Browse the repository at this point in the history
The second get-method wasn't actually overloaded, but had a different
signature than the superclass. This resulted in the superclass cache
being filled and never cleared, even when flush is called.
  • Loading branch information
oehme authored and gnodet committed May 11, 2023
1 parent a15abc2 commit dcf8dac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
@Priority(10)
public class InvalidatingPluginDescriptorCache extends DefaultPluginDescriptorCache {

@FunctionalInterface
public interface PluginDescriptorSupplier {
PluginDescriptor load()
throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException;
}

protected static class Record implements CacheRecord {

private final PluginDescriptor descriptor;
Expand All @@ -71,6 +65,9 @@ public Stream<Path> getDependencyPaths() {
@Override
public void invalidate() {
ClassRealm realm = descriptor.getClassRealm();
if (realm == null) {
return;
}
try {
realm.getWorld().disposeRealm(realm.getId());
} catch (NoSuchRealmException e) {
Expand All @@ -97,6 +94,7 @@ public PluginDescriptor get(Key key) {
return r != null ? clone(r.descriptor) : null;
}

@Override
public PluginDescriptor get(Key key, PluginDescriptorSupplier supplier)
throws PluginDescriptorParsingException, PluginResolutionException, InvalidPluginDescriptorException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
import java.util.stream.Stream;

import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.DefaultPluginDescriptorCache;
import org.apache.maven.plugin.InvalidPluginDescriptorException;
import org.apache.maven.plugin.PluginDescriptorParsingException;
import org.apache.maven.plugin.PluginResolutionException;
import org.apache.maven.plugin.*;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
Expand All @@ -47,13 +44,6 @@
@Named
@Priority(10)
public class InvalidatingPluginDescriptorCache extends DefaultPluginDescriptorCache {

@FunctionalInterface
public interface PluginDescriptorSupplier {
PluginDescriptor load()
throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException;
}

protected static class Record implements CacheRecord {

private final PluginDescriptor descriptor;
Expand All @@ -71,6 +61,9 @@ public Stream<Path> getDependencyPaths() {
@Override
public void invalidate() {
ClassRealm realm = descriptor.getClassRealm();
if (realm == null) {
return;
}
try {
realm.getWorld().disposeRealm(realm.getId());
} catch (NoSuchRealmException e) {
Expand All @@ -97,6 +90,7 @@ public PluginDescriptor get(Key key) {
return r != null ? clone(r.descriptor) : null;
}

@Override
public PluginDescriptor get(Key key, PluginDescriptorSupplier supplier)
throws PluginDescriptorParsingException, PluginResolutionException, InvalidPluginDescriptorException {
try {
Expand Down

0 comments on commit dcf8dac

Please sign in to comment.