Skip to content

Commit

Permalink
fix multiVersionList being empty
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Sep 23, 2024
1 parent 0934e48 commit b0763d2
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import xyz.wagyourtail.jvmdg.logging.Logger;
import xyz.wagyourtail.jvmdg.util.Function;
import xyz.wagyourtail.jvmdg.util.Utils;
import xyz.wagyourtail.jvmdg.version.VersionProvider;

import java.io.Closeable;
import java.io.File;
Expand Down Expand Up @@ -38,10 +39,6 @@ public DowngradingClassLoader(ClassDowngrader downgrader) throws IOException {
this.currentVersionDowngrader = downgrader;
}
logger = holder.logger.subLogger(DowngradingClassLoader.class);
for (int i = holder.maxVersion(); i >= 52; i--) {
multiVersionList.add(i);
}
multiVersionList.add(-1);
}

public DowngradingClassLoader(ClassDowngrader downgrader, ClassLoader parent) throws IOException {
Expand Down Expand Up @@ -122,6 +119,19 @@ public byte[] apply(String s) {

@Override
protected Enumeration<URL> findResources(final String name) {
if (name.equals("META-INF/services/" + VersionProvider.class.getName())) {
return super.findResources(name);
}
if (multiVersionList.isEmpty()) {
synchronized (this) {
if (multiVersionList.isEmpty()) {
for (int i = holder.maxVersion(); i >= 52; i--) {
multiVersionList.add(i);
}
multiVersionList.add(-1);
}
}
}
return new FlatMapEnumeration<>(Collections.enumeration(multiVersionList), new Function<Integer, Enumeration<URL>>() {
@Override
public Enumeration<URL> apply(Integer integer) {
Expand Down

0 comments on commit b0763d2

Please sign in to comment.