Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions SimpleAPI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<build.number>NOTSET</build.number>
<mysql.connector.test.group>com.mysql</mysql.connector.test.group>
<mysql.connector.test.artifact>mysql-connector-j</mysql.connector.test.artifact>
<mysql.connector.test.version>9.5.0</mysql.connector.test.version>
<mysql.connector.test.version>26.7.0</mysql.connector.test.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.release>21</maven.compiler.release>
Expand Down Expand Up @@ -262,7 +262,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>26.2-R0.1-SNAPSHOT</version>
<version>26.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -298,7 +298,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>6.1.2</version>
<version>6.1.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -310,7 +310,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.23.0</version>
<version>5.24.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -425,7 +425,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.4</version>
<version>3.2.0</version>
<configuration>
<skip>true</skip>
</configuration>
Expand Down Expand Up @@ -516,7 +516,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.4</version>
<version>3.2.0</version>
<configuration>
<skip>true</skip>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import static org.junit.jupiter.api.Assertions.*;

import java.io.File;
import java.io.StringWriter;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import java.util.jar.Attributes;
import java.util.jar.JarFile;

import javax.tools.ToolProvider;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

Expand All @@ -19,6 +23,55 @@
public class FullArtifactTest {
@TempDir Path temporary;

@Test void legacyRedisConsumerCompilesAndLinksAgainstOnlyTheFullJar() throws Exception {
Path full = fullJar();
Path source = temporary.resolve("LegacyRedisConsumer.java");
Files.writeString(source, """
import java.util.Set;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisClientConfig;
import redis.clients.jedis.JedisPooled;
import redis.clients.jedis.JedisSentineled;
import redis.clients.jedis.UnifiedJedis;

public final class LegacyRedisConsumer {
// Compile the established constructor calls without opening a connection.
public static Object[] construct(HostAndPort endpoint, JedisClientConfig config,
Set<HostAndPort> sentinels) {
return new Object[] {
new JedisPooled(endpoint, config),
new JedisSentineled("synthetic-master", config, sentinels, config),
new UnifiedJedis(endpoint, config)
};
}

public static int link() throws Exception {
JedisPooled.class.getConstructor(HostAndPort.class, JedisClientConfig.class);
JedisSentineled.class.getConstructor(String.class, JedisClientConfig.class,
Set.class, JedisClientConfig.class);
UnifiedJedis.class.getConstructor(HostAndPort.class, JedisClientConfig.class);
return 3;
}
}
""");
var compiler = ToolProvider.getSystemJavaCompiler();
assertNotNull(compiler, "Packaged API verification requires the build JDK");
StringWriter diagnostics = new StringWriter();
try (var files = compiler.getStandardFileManager(null, null, StandardCharsets.UTF_8)) {
boolean compiled = compiler.getTask(diagnostics, files, null,
java.util.List.of("--release", "21", "-proc:none", "-classpath", full.toString(),
"-d", temporary.toString()), null,
files.getJavaFileObjects(source.toFile())).call();
assertTrue(compiled, "Legacy Redis consumer must compile using only the packaged JAR: " + diagnostics);
}
// Platform parent excludes every Maven dependency, including any older Jedis on the test classpath.
try (var loader = new URLClassLoader(new java.net.URL[] {
temporary.toUri().toURL(), full.toUri().toURL() }, ClassLoader.getPlatformClassLoader())) {
Class<?> consumer = Class.forName("LegacyRedisConsumer", true, loader);
assertEquals(3, consumer.getMethod("link").invoke(null));
}
}

@Test void omitsExternalCryptoProvider() throws Exception {
Path full = fullJar();
try (JarFile output = new JarFile(full.toFile())) {
Expand Down
Loading