Skip to content

Commit 07f9807

Browse files
committed
Extract ExecutorFactory for Java 21 support using newVirtualThreadPerTaskExecutor()
1 parent 29b97d3 commit 07f9807

File tree

5 files changed

+78
-2
lines changed

5 files changed

+78
-2
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
java_version: [11]
16+
java_version: [21]
1717
os: [ubuntu-latest]
1818

1919
steps:

ebean-datasource/pom.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,58 @@
9292

9393
</dependencies>
9494

95+
<build>
96+
<plugins>
97+
98+
<plugin> <!-- Multi-Release with 21 -->
99+
<groupId>org.apache.maven.plugins</groupId>
100+
<artifactId>maven-jar-plugin</artifactId>
101+
<version>3.3.0</version>
102+
<configuration>
103+
<archive>
104+
<manifestEntries>
105+
<Multi-Release>true</Multi-Release>
106+
</manifestEntries>
107+
</archive>
108+
</configuration>
109+
</plugin>
110+
111+
<plugin>
112+
<groupId>org.apache.maven.plugins</groupId>
113+
<artifactId>maven-compiler-plugin</artifactId>
114+
<version>3.14.0</version>
115+
<executions>
116+
<!-- Compile for base version Java 11 -->
117+
<execution>
118+
<id>base</id>
119+
<goals>
120+
<goal>compile</goal>
121+
</goals>
122+
<configuration>
123+
<release>11</release>
124+
<compileSourceRoots>
125+
<compileSourceRoot>${project.basedir}/src/main/java</compileSourceRoot>
126+
</compileSourceRoots>
127+
</configuration>
128+
</execution>
129+
<!-- Compile for Java 21 -->
130+
<execution>
131+
<id>java21</id>
132+
<goals>
133+
<goal>compile</goal>
134+
</goals>
135+
<configuration>
136+
<release>21</release>
137+
<compileSourceRoots>
138+
<compileSourceRoot>${project.basedir}/src/main/java21</compileSourceRoot>
139+
</compileSourceRoots>
140+
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/21</outputDirectory>
141+
</configuration>
142+
</execution>
143+
</executions>
144+
</plugin>
145+
146+
</plugins>
147+
</build>
148+
95149
</project>

ebean-datasource/src/main/java/io/ebean/datasource/pool/ConnectionPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ private void startExecutor() {
769769
executorLock.lock();
770770
try {
771771
if (executor == null) {
772-
executor = Executors.newSingleThreadExecutor();
772+
executor = ExecutorFactory.newExecutor();
773773
}
774774
} finally {
775775
executorLock.unlock();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.ebean.datasource.pool;
2+
3+
import java.util.concurrent.ExecutorService;
4+
import java.util.concurrent.Executors;
5+
6+
final class ExecutorFactory {
7+
8+
static ExecutorService newExecutor() {
9+
return Executors.newSingleThreadExecutor();
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.ebean.datasource.pool;
2+
3+
import java.util.concurrent.ExecutorService;
4+
import java.util.concurrent.Executors;
5+
6+
final class ExecutorFactory {
7+
8+
static ExecutorService newExecutor() {
9+
return Executors.newVirtualThreadPerTaskExecutor();
10+
}
11+
}

0 commit comments

Comments
 (0)