Fix PluginDescriptorCache

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.
This commit is contained in:
Stefan Oehme
2023-04-06 15:36:32 +02:00
committed by Guillaume Nodet
parent a15abc25df
commit dcf8dacfd4
2 changed files with 9 additions and 17 deletions

View File

@@ -48,12 +48,6 @@ import org.mvndaemon.mvnd.cache.CacheRecord;
@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;
@@ -71,6 +65,9 @@ public class InvalidatingPluginDescriptorCache extends DefaultPluginDescriptorCa
@Override
public void invalidate() {
ClassRealm realm = descriptor.getClassRealm();
if (realm == null) {
return;
}
try {
realm.getWorld().disposeRealm(realm.getId());
} catch (NoSuchRealmException e) {
@@ -97,6 +94,7 @@ public class InvalidatingPluginDescriptorCache extends DefaultPluginDescriptorCa
return r != null ? clone(r.descriptor) : null;
}
@Override
public PluginDescriptor get(Key key, PluginDescriptorSupplier supplier)
throws PluginDescriptorParsingException, PluginResolutionException, InvalidPluginDescriptorException {
try {

View File

@@ -29,10 +29,7 @@ import java.util.Optional;
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;
@@ -47,13 +44,6 @@ import org.mvndaemon.mvnd.cache.CacheRecord;
@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;
@@ -71,6 +61,9 @@ public class InvalidatingPluginDescriptorCache extends DefaultPluginDescriptorCa
@Override
public void invalidate() {
ClassRealm realm = descriptor.getClassRealm();
if (realm == null) {
return;
}
try {
realm.getWorld().disposeRealm(realm.getId());
} catch (NoSuchRealmException e) {
@@ -97,6 +90,7 @@ public class InvalidatingPluginDescriptorCache extends DefaultPluginDescriptorCa
return r != null ? clone(r.descriptor) : null;
}
@Override
public PluginDescriptor get(Key key, PluginDescriptorSupplier supplier)
throws PluginDescriptorParsingException, PluginResolutionException, InvalidPluginDescriptorException {
try {