mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-08-22 22:22:56 +02:00
Downgrade jedis and h2
This commit is contained in:
@@ -25,7 +25,7 @@ dependencies {
|
||||
testImplementation 'org.mockito:mockito-core:5.18.0'
|
||||
testImplementation 'org.mockito:mockito-junit-jupiter:5.18.0'
|
||||
|
||||
testImplementation 'com.h2database:h2:2.3.232'
|
||||
testImplementation 'com.h2database:h2:2.1.214'
|
||||
testImplementation 'org.mongodb:mongodb-driver-legacy:5.5.0'
|
||||
testImplementation 'org.spongepowered:configurate-yaml:3.7.3'
|
||||
testImplementation 'org.spongepowered:configurate-hocon:3.7.3'
|
||||
@@ -97,7 +97,7 @@ dependencies {
|
||||
transitive = false
|
||||
}
|
||||
compileOnly 'com.zaxxer:HikariCP:6.3.0'
|
||||
compileOnly 'redis.clients:jedis:6.0.0'
|
||||
compileOnly 'redis.clients:jedis:5.2.0'
|
||||
compileOnly 'io.nats:jnats:2.21.1'
|
||||
compileOnly 'com.rabbitmq:amqp-client:5.25.0'
|
||||
compileOnly 'org.mongodb:mongodb-driver-legacy:5.5.0'
|
||||
|
@@ -171,8 +171,8 @@ public enum Dependency {
|
||||
H2_DRIVER(
|
||||
"com.h2database",
|
||||
"h2",
|
||||
"2.3.232",
|
||||
"ja5i0i24mCw9yzgm7bnHJ8XTAgY6Z+731j2C3kAfB9M="
|
||||
"2.1.214",
|
||||
"1iPNwPYdIYz1SajQnxw5H/kQlhFrIuJHVHX85PvnK9A="
|
||||
// we don't apply relocations to h2 - it gets loaded via
|
||||
// an isolated classloader
|
||||
),
|
||||
@@ -238,8 +238,8 @@ public enum Dependency {
|
||||
JEDIS(
|
||||
"redis.clients",
|
||||
"jedis",
|
||||
"6.0.0",
|
||||
"ZJq2D7GDoNQa7nAsfhCTsClsedbEp3N2j2V3qXhk8kU=",
|
||||
"5.2.0",
|
||||
"3U+9osED8xmrSVrbK8GQYTmEB0bP1MZrJ3ENGvmDgtQ=",
|
||||
Relocation.of("jedis", "redis{}clients{}jedis"),
|
||||
Relocation.of("commonspool2", "org{}apache{}commons{}pool2")
|
||||
),
|
||||
|
@@ -27,7 +27,6 @@ package me.lucko.luckperms.common.extension;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.plugin.classpath.URLClassLoaderAccess;
|
||||
import me.lucko.luckperms.common.util.gson.GsonProvider;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.extension.Extension;
|
||||
@@ -115,7 +114,6 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable {
|
||||
}
|
||||
|
||||
String className;
|
||||
boolean useParentClassLoader = false;
|
||||
try (JarFile jar = new JarFile(path.toFile())) {
|
||||
JarEntry extensionJarEntry = jar.getJarEntry("extension.json");
|
||||
if (extensionJarEntry == null) {
|
||||
@@ -128,8 +126,14 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
|
||||
JsonObject parsed = GsonProvider.parser().parse(reader).getAsJsonObject();
|
||||
className = parsed.get("class").getAsString();
|
||||
|
||||
// check for deprecated flags
|
||||
if (parsed.has("useParentClassLoader")) {
|
||||
useParentClassLoader = parsed.get("useParentClassLoader").getAsBoolean();
|
||||
boolean useParentClassLoader = parsed.get("useParentClassLoader").getAsBoolean();
|
||||
if (useParentClassLoader) {
|
||||
this.plugin.getLogger().warn("Extension '" + className + "' specifies the 'useParentClassLoader' extension flag, which has been deprecated/removed. " +
|
||||
"The extension will be loaded using the classloader of the LuckPerms plugin, and not the classloader of the platform, which may break functionality.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,15 +143,7 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable {
|
||||
throw new IllegalArgumentException("class is null");
|
||||
}
|
||||
|
||||
if (useParentClassLoader && isJarInJar()) {
|
||||
try {
|
||||
addJarToParentClasspath(path);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Exception whilst classloading extension", e);
|
||||
}
|
||||
} else {
|
||||
this.plugin.getBootstrap().getClassPathAppender().addJarToClasspath(path);
|
||||
}
|
||||
this.plugin.getBootstrap().getClassPathAppender().addJarToClasspath(path);
|
||||
|
||||
Class<? extends Extension> extensionClass;
|
||||
try {
|
||||
@@ -191,21 +187,6 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable {
|
||||
return this.extensions.stream().map(e -> e.instance).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private static boolean isJarInJar() {
|
||||
String thisClassLoaderName = SimpleExtensionManager.class.getClassLoader().getClass().getName();
|
||||
return thisClassLoaderName.equals("me.lucko.luckperms.common.loader.JarInJarClassLoader");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static void addJarToParentClasspath(Path path) throws Exception {
|
||||
ClassLoader parentClassLoader = SimpleExtensionManager.class.getClassLoader().getParent();
|
||||
if (!(parentClassLoader instanceof URLClassLoader)) {
|
||||
throw new RuntimeException("useParentClassLoader is true but parent is not a URLClassLoader");
|
||||
}
|
||||
|
||||
URLClassLoaderAccess.create(((URLClassLoader) parentClassLoader)).addURL(path.toUri().toURL());
|
||||
}
|
||||
|
||||
private static final class LoadedExtension {
|
||||
private final Extension instance;
|
||||
private final Path path;
|
||||
|
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.plugin.classpath;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ReflectionClassPathAppender implements ClassPathAppender {
|
||||
private final URLClassLoaderAccess classLoaderAccess;
|
||||
|
||||
public ReflectionClassPathAppender(ClassLoader classLoader) throws IllegalStateException {
|
||||
if (classLoader instanceof URLClassLoader) {
|
||||
this.classLoaderAccess = URLClassLoaderAccess.create((URLClassLoader) classLoader);
|
||||
} else {
|
||||
throw new IllegalStateException("ClassLoader is not instance of URLClassLoader");
|
||||
}
|
||||
}
|
||||
|
||||
public ReflectionClassPathAppender(LuckPermsBootstrap bootstrap) throws IllegalStateException {
|
||||
this(bootstrap.getClass().getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addJarToClasspath(Path file) {
|
||||
try {
|
||||
this.classLoaderAccess.addURL(file.toUri().toURL());
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.plugin.classpath;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Provides access to {@link URLClassLoader}#addURL.
|
||||
*/
|
||||
public abstract class URLClassLoaderAccess {
|
||||
|
||||
/**
|
||||
* Creates a {@link URLClassLoaderAccess} for the given class loader.
|
||||
*
|
||||
* @param classLoader the class loader
|
||||
* @return the access object
|
||||
*/
|
||||
public static URLClassLoaderAccess create(URLClassLoader classLoader) {
|
||||
if (Reflection.isSupported()) {
|
||||
return new Reflection(classLoader);
|
||||
} else if (Unsafe.isSupported()) {
|
||||
return new Unsafe(classLoader);
|
||||
} else {
|
||||
return Noop.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
private final URLClassLoader classLoader;
|
||||
|
||||
protected URLClassLoaderAccess(URLClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the given URL to the class loader.
|
||||
*
|
||||
* @param url the URL to add
|
||||
*/
|
||||
public abstract void addURL(@NonNull URL url);
|
||||
|
||||
private static void throwError(Throwable cause) throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException("LuckPerms is unable to inject into the plugin URLClassLoader.\n" +
|
||||
"You may be able to fix this problem by adding the following command-line argument " +
|
||||
"directly after the 'java' command in your start script: \n'--add-opens java.base/java.lang=ALL-UNNAMED'", cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accesses using reflection, not supported on Java 9+.
|
||||
*/
|
||||
private static class Reflection extends URLClassLoaderAccess {
|
||||
private static final Method ADD_URL_METHOD;
|
||||
|
||||
static {
|
||||
Method addUrlMethod;
|
||||
try {
|
||||
addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
|
||||
addUrlMethod.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
addUrlMethod = null;
|
||||
}
|
||||
ADD_URL_METHOD = addUrlMethod;
|
||||
}
|
||||
|
||||
private static boolean isSupported() {
|
||||
return ADD_URL_METHOD != null;
|
||||
}
|
||||
|
||||
Reflection(URLClassLoader classLoader) {
|
||||
super(classLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addURL(@NonNull URL url) {
|
||||
try {
|
||||
ADD_URL_METHOD.invoke(super.classLoader, url);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
URLClassLoaderAccess.throwError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accesses using sun.misc.Unsafe, supported on Java 9+.
|
||||
*
|
||||
* @author Vaishnav Anil (https://github.com/slimjar/slimjar)
|
||||
*/
|
||||
private static class Unsafe extends URLClassLoaderAccess {
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
|
||||
static {
|
||||
sun.misc.Unsafe unsafe;
|
||||
try {
|
||||
Field unsafeField = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
|
||||
unsafeField.setAccessible(true);
|
||||
unsafe = (sun.misc.Unsafe) unsafeField.get(null);
|
||||
} catch (Throwable t) {
|
||||
unsafe = null;
|
||||
}
|
||||
UNSAFE = unsafe;
|
||||
}
|
||||
|
||||
private static boolean isSupported() {
|
||||
return UNSAFE != null;
|
||||
}
|
||||
|
||||
private final Collection<URL> unopenedURLs;
|
||||
private final Collection<URL> pathURLs;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Unsafe(URLClassLoader classLoader) {
|
||||
super(classLoader);
|
||||
|
||||
Collection<URL> unopenedURLs;
|
||||
Collection<URL> pathURLs;
|
||||
try {
|
||||
Object ucp = fetchField(URLClassLoader.class, classLoader, "ucp");
|
||||
unopenedURLs = (Collection<URL>) fetchField(ucp.getClass(), ucp, "unopenedUrls");
|
||||
pathURLs = (Collection<URL>) fetchField(ucp.getClass(), ucp, "path");
|
||||
} catch (Throwable e) {
|
||||
unopenedURLs = null;
|
||||
pathURLs = null;
|
||||
}
|
||||
|
||||
this.unopenedURLs = unopenedURLs;
|
||||
this.pathURLs = pathURLs;
|
||||
}
|
||||
|
||||
private static Object fetchField(final Class<?> clazz, final Object object, final String name) throws NoSuchFieldException {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
long offset = UNSAFE.objectFieldOffset(field);
|
||||
return UNSAFE.getObject(object, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addURL(@NonNull URL url) {
|
||||
if (this.unopenedURLs == null || this.pathURLs == null) {
|
||||
URLClassLoaderAccess.throwError(new NullPointerException("unopenedURLs or pathURLs"));
|
||||
}
|
||||
|
||||
synchronized (this.unopenedURLs) {
|
||||
this.unopenedURLs.add(url);
|
||||
this.pathURLs.add(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Noop extends URLClassLoaderAccess {
|
||||
private static final Noop INSTANCE = new Noop();
|
||||
|
||||
private Noop() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addURL(@NonNull URL url) {
|
||||
URLClassLoaderAccess.throwError(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -14,9 +14,9 @@ dependencies {
|
||||
api 'net.minecrell:terminalconsoleappender:1.3.0'
|
||||
api 'org.jline:jline-terminal-jansi:3.20.0'
|
||||
|
||||
api 'com.google.code.gson:gson:2.9.0'
|
||||
api 'com.google.guava:guava:31.1-jre'
|
||||
api 'io.netty:netty-all:4.1.93.Final'
|
||||
api 'com.google.code.gson:gson:2.13.1'
|
||||
api 'com.google.guava:guava:33.4.8-jre'
|
||||
api 'io.netty:netty-all:4.2.1.Final'
|
||||
|
||||
api('net.kyori:adventure-api:4.21.0') {
|
||||
exclude(module: 'adventure-bom')
|
||||
|
@@ -25,30 +25,29 @@ dependencies {
|
||||
compileOnly project(':common:loader-utils')
|
||||
compileOnly project(':standalone:app')
|
||||
|
||||
compileOnly 'org.spongepowered:configurate-yaml:3.7.2'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.0'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.1'
|
||||
testImplementation "org.testcontainers:junit-jupiter:1.18.3"
|
||||
testImplementation 'org.mockito:mockito-core:4.11.0'
|
||||
testImplementation 'org.mockito:mockito-junit-jupiter:4.11.0'
|
||||
testImplementation 'org.awaitility:awaitility:4.2.0'
|
||||
testImplementation 'org.testcontainers:junit-jupiter:1.21.1'
|
||||
testImplementation 'org.mockito:mockito-core:5.18.0'
|
||||
testImplementation 'org.mockito:mockito-junit-jupiter:5.18.0'
|
||||
testImplementation 'org.awaitility:awaitility:4.3.0'
|
||||
|
||||
testImplementation 'com.zaxxer:HikariCP:4.0.3'
|
||||
testImplementation 'redis.clients:jedis:4.4.3'
|
||||
testImplementation 'io.nats:jnats:2.16.4'
|
||||
testImplementation 'com.rabbitmq:amqp-client:5.12.0'
|
||||
testImplementation 'org.postgresql:postgresql:42.6.0'
|
||||
testImplementation 'com.zaxxer:HikariCP:6.3.0'
|
||||
testImplementation 'redis.clients:jedis:5.2.0'
|
||||
testImplementation 'io.nats:jnats:2.21.1'
|
||||
testImplementation 'com.rabbitmq:amqp-client:5.25.0'
|
||||
testImplementation 'org.postgresql:postgresql:42.7.6'
|
||||
testImplementation 'com.h2database:h2:2.1.214'
|
||||
testImplementation 'org.xerial:sqlite-jdbc:3.42.0.0'
|
||||
testImplementation 'mysql:mysql-connector-java:8.0.23'
|
||||
testImplementation 'org.mariadb.jdbc:mariadb-java-client:3.1.3'
|
||||
testImplementation 'org.mongodb:mongodb-driver-legacy:4.5.0'
|
||||
testImplementation 'org.xerial:sqlite-jdbc:3.49.1.0'
|
||||
testImplementation 'com.mysql:mysql-connector-j:9.3.0'
|
||||
testImplementation 'org.mariadb.jdbc:mariadb-java-client:3.5.2'
|
||||
testImplementation 'org.mongodb:mongodb-driver-legacy:5.5.0'
|
||||
testImplementation 'me.lucko.configurate:configurate-toml:3.7'
|
||||
testImplementation 'org.spongepowered:configurate-hocon:3.7.2'
|
||||
testImplementation 'org.yaml:snakeyaml:1.28'
|
||||
testImplementation 'net.luckperms:rest-api-java-client:0.1-SNAPSHOT'
|
||||
testImplementation 'org.spongepowered:configurate-yaml:3.7.3'
|
||||
testImplementation 'org.spongepowered:configurate-hocon:3.7.3'
|
||||
testImplementation 'org.yaml:snakeyaml:1.22'
|
||||
testImplementation 'net.luckperms:rest-api-java-client:0.1'
|
||||
|
||||
testImplementation project(':standalone:app')
|
||||
testImplementation project(':common:loader-utils')
|
||||
|
Reference in New Issue
Block a user