Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with multi-release-jar support in Coretto 21 #89

Open
thiagohora opened this issue Mar 13, 2025 · 4 comments
Open

Issue with multi-release-jar support in Coretto 21 #89

thiagohora opened this issue Mar 13, 2025 · 4 comments

Comments

@thiagohora
Copy link

thiagohora commented Mar 13, 2025

Describe the bug

I'm using the JVM argument -Dreactor.schedulers.defaultBoundedElasticOnVirtualThreads=true but, but it doesn't work well with Correto. When specifying this argument, Virtual threads would be the default thread pool.

However, when compiling and running my code using Correto, that doesn't happen. It seems that is the root cause:

META-INF/versions/11/reactor/core/publisher/CallSiteSupplierFactory.class:                                                   compiled Java class data, version 55.0 (Java SE 11)
META-INF/versions/21/reactor/core/scheduler/BoundedElasticThreadPerTaskScheduler$BoundedServices.class:                      compiled Java class data, version 65.0
META-INF/versions/21/reactor/core/scheduler/BoundedElasticThreadPerTaskScheduler$SequentialThreadPerTaskExecutor.class:      compiled Java class data, version 65.0
META-INF/versions/21/reactor/core/scheduler/BoundedElasticThreadPerTaskScheduler.class:                                      compiled Java class data, version 65.0
META-INF/versions/21/reactor/core/scheduler/BoundedElasticSchedulerSupplier.class:                                           compiled Java class data, version 65.0
META-INF/versions/21/reactor/core/scheduler/BoundedElasticThreadPerTaskScheduler$SingleThreadExecutorWorker.class:           compiled Java class data, version 65.0
META-INF/versions/21/reactor/core/scheduler/BoundedElasticThreadPerTaskScheduler$BoundedServices$ActiveExecutorsState.class: compiled Java class data, version 65.0
META-INF/versions/21/reactor/core/scheduler/BoundedElasticThreadPerTaskScheduler$SchedulerTask.class:                        compiled Java class data, version 65.0
META-INF/versions/21/reactor/core/scheduler/BoundedElasticThreadPerTaskScheduler$BoundedServices$1.class:                    compiled Java class data, version 65.0
META-INF/versions/21/reactor/core/scheduler/VirtualThreadFactory.class:   

The same code works with other JVM providers.

To Reproduce

Create a small java project using project reactor, compile and run it using this JVM arg -Dreactor.schedulers.defaultBoundedElasticOnVirtualThreads=true.

Use this code:

public static void main(String[] args) throws InterruptedException {
  final Mono<String> mono = Mono.just("hello "); 

  Thread t = new Thread(() -> mono
      .map(msg -> msg + "thread ")
      .subscribe(v -> 
          System.out.println(v + Thread.currentThread().getName()) 
      )
  );
  t.start();
  t.join();
}

Expected behavior

See the print of the Virtual thread pool.

Error

2025-03-13 11:38:00 WARN  [2025-03-13 10:38:00,844] reactor.core.scheduler.BoundedElasticSchedulerSupplier: Virtual Threads support is not available on the given JVM. Falling back to default BoundedElastic setup

Platform information

OS:  Linux backend 6.10.14-linuxkit #1 SMP Mon Feb 24 16:35:16 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux
Version OpenJDK 64-Bit Server VM Corretto-21.0.6.7.1 (build 21.0.6+7-LTS, mixed mode, sharing)

Additional context

Related issue: reactor/reactor-core#4012

@cost0much
Copy link
Contributor

Hello,

I apologize for the delay in response. You state that the following code works with other JVM providers, could you list which ones?

@thiagohora
Copy link
Author

thiagohora commented Mar 14, 2025

Hi @cost0much,

OpenJDK 21.0.2-open

openjdk version "21.0.2" 2024-01-16
OpenJDK Runtime Environment (build 21.0.2+13-58)
OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)

@cost0much
Copy link
Contributor

cost0much commented Mar 14, 2025

Hello,
Unfortunately, I was not able to reproduce your issue on my end. Could you give an alternative method/more detailed steps to your reproducer?

$ javac -cp "lib/reactor-core-3.7.4.jar:lib/reactive-streams-1.0.4.jar" Main.java
$ java -cp ".:lib/reactor-core-3.7.4.jar:lib/reactive-streams-1.0.4.jar" Main
hello thread Thread-0
$ java -Dreactor.schedulers.defaultBoundedElasticOnVirtualThreads=true -cp ".:lib/reactor-core-3.7.4.jar:lib/reactive-streams-1.0.4.jar" Main
hello thread Thread-0
$ java -version
openjdk version "21.0.6" 2025-01-21 LTS
OpenJDK Runtime Environment Corretto-21.0.6.7.1 (build 21.0.6+7-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.6.7.1 (build 21.0.6+7-LTS, mixed mode, sharing)
$ cat Main.java
import reactor.core.publisher.Mono;
public class Main {
public static void main(String[] args) throws InterruptedException {
  final Mono<String> mono = Mono.just("hello "); 

  Thread t = new Thread(() -> mono
      .map(msg -> msg + "thread ")
      .subscribe(v -> 
          System.out.println(v + Thread.currentThread().getName()) 
      )
  );
  t.start();
  t.join();
}
}

@thiagohora
Copy link
Author

thiagohora commented Mar 14, 2025

I used this project to reproduce, but now I see the same error when running the jar, running the IDE is works. The issue is when running in the JAR

https://github.com/thiagohora/jvm-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants