Skip to content

Commit 5efade4

Browse files
authored
fix: promote lettuce-core from compileOnly to implementation (#223)
## Summary Follow-up to #222. `compileOnly` fixed the Java 25 javac type-annotation error but left `lettuce-core` off the runtime classpath — `spring-data-redis` declares it `optional` in its Maven POM, so Gradle omits it entirely without an explicit dep. Spring Session Redis would throw `NoClassDefFoundError` at runtime when a Redis session store is configured. Changing to `implementation` puts it on both the compile and runtime classpath.
2 parents 09a6ef7 + 6a8c9e6 commit 5efade4

2 files changed

Lines changed: 87 additions & 1 deletion

File tree

git-proxy-java-dashboard/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ dependencies {
170170
// MongoDB driver — compile-scoped because MongoSessionRepository uses the sync client directly.
171171
implementation "org.mongodb:mongodb-driver-sync:${mongoVersion}"
172172

173-
compileOnly "io.lettuce:lettuce-core:${lettuceVersion}"
173+
implementation "io.lettuce:lettuce-core:${lettuceVersion}"
174174

175175
// OpenAPI spec generation — core model + YAML/JSON serialisation only (no JAX-RS required).
176176
// The spec is built programmatically from Spring's RequestMappingHandlerMapping.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package org.finos.gitproxy.dashboard.session;
2+
3+
import static org.junit.jupiter.api.Assertions.*;
4+
5+
import java.time.Duration;
6+
import org.junit.jupiter.api.*;
7+
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
8+
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
9+
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
10+
import org.springframework.data.redis.core.RedisTemplate;
11+
import org.springframework.data.redis.serializer.RedisSerializer;
12+
import org.springframework.session.data.redis.RedisIndexedSessionRepository;
13+
import org.testcontainers.containers.GenericContainer;
14+
import org.testcontainers.junit.jupiter.Container;
15+
import org.testcontainers.junit.jupiter.Testcontainers;
16+
import org.testcontainers.utility.DockerImageName;
17+
18+
@Testcontainers
19+
@Tag("integration")
20+
class RedisSessionRepositoryIntegrationTest {
21+
22+
@SuppressWarnings("resource")
23+
@Container
24+
static final GenericContainer<?> VALKEY =
25+
new GenericContainer<>(DockerImageName.parse("docker.io/valkey/valkey:8")).withExposedPorts(6379);
26+
27+
private LettuceConnectionFactory factory;
28+
private RedisIndexedSessionRepository repo;
29+
30+
@BeforeEach
31+
void setUp() {
32+
var standalone = new RedisStandaloneConfiguration(VALKEY.getHost(), VALKEY.getMappedPort(6379));
33+
factory = new LettuceConnectionFactory(standalone, LettuceClientConfiguration.defaultConfiguration());
34+
factory.afterPropertiesSet();
35+
36+
var template = new RedisTemplate<String, Object>();
37+
template.setConnectionFactory(factory);
38+
template.setKeySerializer(RedisSerializer.string());
39+
template.setHashKeySerializer(RedisSerializer.string());
40+
template.afterPropertiesSet();
41+
42+
repo = new RedisIndexedSessionRepository(template);
43+
repo.setDefaultMaxInactiveInterval(Duration.ofMinutes(30));
44+
}
45+
46+
@AfterEach
47+
void tearDown() {
48+
factory.destroy();
49+
}
50+
51+
@Test
52+
void createSession_hasConfiguredTimeout() {
53+
var s = repo.createSession();
54+
assertEquals(Duration.ofMinutes(30), s.getMaxInactiveInterval());
55+
}
56+
57+
@Test
58+
void save_then_findById_roundTripsAttributes() {
59+
var s = repo.createSession();
60+
s.setAttribute("username", "alice");
61+
s.setAttribute("role-count", 3);
62+
repo.save(s);
63+
64+
var loaded = repo.findById(s.getId());
65+
assertNotNull(loaded);
66+
assertEquals(s.getId(), loaded.getId());
67+
assertEquals("alice", loaded.getAttribute("username"));
68+
assertEquals(Integer.valueOf(3), loaded.getAttribute("role-count"));
69+
}
70+
71+
@Test
72+
void findById_unknownId_returnsNull() {
73+
assertNull(repo.findById("does-not-exist"));
74+
}
75+
76+
@Test
77+
void deleteById_removesSession() {
78+
var s = repo.createSession();
79+
s.setAttribute("k", "v");
80+
repo.save(s);
81+
assertNotNull(repo.findById(s.getId()));
82+
83+
repo.deleteById(s.getId());
84+
assertNull(repo.findById(s.getId()));
85+
}
86+
}

0 commit comments

Comments
 (0)