`BoundValueOperations` not visible when initializing `boundValueOps` on Fork/Join pool
Closed this issue · 1 comments
app2smile commented
environment:
jdk21
spring boot 3.2.6
caffeine
Describe the bug:
org.springframework.data.redis.core.BoundValueOperations referenced from a method is not visible from class loader: 'app'
When I ran the following code inside the Docker container, an error occurred I am unable to reproduce this issue when running in a local environment I don't know what caused this problem
@SpringBootApplication
public class CaffeineDemoApplication implements CommandLineRunner {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Override
public void run(String... args) throws Exception {
LoadingCache<String, String> cache = Caffeine.newBuilder()
.refreshAfterWrite(Duration.ofSeconds(5))
.build(key -> {
// do something
// ...
stringRedisTemplate.boundValueOps(key).set("1");
// ...
return "any";
});
cache.get("1");
// error
// java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: org.springframework.data.redis.core.BoundValueOperations referenced from a method is not visible from class loader: 'app'
cache.refresh("1");
}
public static void main(String[] args) {
SpringApplication.run(CaffeineDemoApplication.class, args);
}
}
To Reproduce:
- modify the Redis configuration in application.yml
- maven install
- docker build -t demo:v1 .
- docker run --rm --net=host demo:v1
mp911de commented
Thanks for the report. The issue is caused by Spring Data Redis relying on the contextual class loader. Running code on the Fork/Join pool resorts to the app class loader that was used to bootstrap the Spring Boot loader. Spring Boot uses a different class loader that has access to the bundled jars and so class loading fails.
We need to fix this.