Skip to content

Commit 3148fcd

Browse files
committed
Update to structured concurrency being out of incubation (over half a year late 🙈)…
… and also Maven plugin versions.
1 parent 98914f3 commit 3148fcd

File tree

8 files changed

+18
-31
lines changed

8 files changed

+18
-31
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ To try this out, run the client and the server in different shells.
5959
* arguments: see [`Echo.java`.](experiments/src/main/java/dev/nipafx/lab/loom/echo/server/Echo.java)
6060
* client
6161
* name: `EchoClient`
62-
* arguments: see [`Send.java`.](experiments/src/main/java/dev/nipafx/lab/loom/echo/client/Send.java),
62+
* arguments: see [`Send.java`.](experiments/src/main/java/dev/nipafx/lab/loom/echo/client/Send.java),
6363
* package: [`dev.nipafx.lab.loom.echo`](experiments/src/main/java/dev/nipafx/lab/loom/echo)
6464

6565
**Note**:

experiments/pom.xml

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
<relativePath>..</relativePath>
1515
</parent>
1616

17-
<properties>
18-
<maven.compiler.release>21</maven.compiler.release>
19-
<maven.compiler.source>21</maven.compiler.source>
20-
<maven.compiler.target>21</maven.compiler.target>
21-
</properties>
22-
2317
<build>
2418
<plugins>
2519
<plugin>
@@ -36,4 +30,4 @@
3630
</plugins>
3731
</build>
3832

39-
</project>
33+
</project>

experiments/src/main/java/dev/nipafx/lab/loom/crawl/crawler/PageTreeFactory.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import dev.nipafx.lab.loom.crawl.page.ErrorPage;
44
import dev.nipafx.lab.loom.crawl.page.GitHubPage;
55
import dev.nipafx.lab.loom.crawl.page.Page;
6-
import jdk.incubator.concurrent.StructuredTaskScope;
76

87
import java.io.IOException;
98
import java.net.URI;
@@ -19,6 +18,8 @@
1918
import java.util.concurrent.ConcurrentMap;
2019
import java.util.concurrent.ExecutionException;
2120
import java.util.concurrent.Future;
21+
import java.util.concurrent.StructuredTaskScope;
22+
import java.util.concurrent.StructuredTaskScope.Subtask;
2223

2324
import static java.util.Objects.requireNonNull;
2425

@@ -56,15 +57,15 @@ private Collection<Page> resolveLinks(Set<URI> links, int depth) throws Interrup
5657
return Collections.emptySet();
5758

5859
try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
59-
List<Future<Page>> futurePages = new ArrayList<>();
60+
List<Subtask<Page>> futurePages = new ArrayList<>();
6061
for (URI link : links)
6162
futurePages.add(scope.fork(() -> createPage(link, depth)));
6263

6364
scope.join();
6465
scope.throwIfFailed();
6566

6667
return futurePages.stream()
67-
.map(Future::resultNow)
68+
.map(Subtask::get)
6869
.toList();
6970
} catch (ExecutionException ex) {
7071
// this should not happen as `ErrorPage` instances should have been created for all errors

experiments/src/main/java/dev/nipafx/lab/loom/disk/VirtualThreadsAnalyzer.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import java.util.concurrent.Callable;
99
import java.util.concurrent.ExecutionException;
1010
import java.util.concurrent.Future;
11+
import java.util.concurrent.StructuredTaskScope;
12+
import java.util.concurrent.StructuredTaskScope.Subtask;
1113
import java.util.concurrent.atomic.LongAdder;
1214

13-
import jdk.incubator.concurrent.StructuredTaskScope;
14-
1515
import static java.util.function.Predicate.not;
1616

1717
/**
@@ -25,7 +25,7 @@ class VirtualThreadsAnalyzer implements Analyzer {
2525
public FolderStats analyzeFolder(Path folder) throws UncheckedIOException, InterruptedException {
2626
try (var scope = new StructuredTaskScope.ShutdownOnFailure();
2727
var content = Files.list(folder)) {
28-
List<Future<Stats>> childrenTasks = content
28+
List<Subtask<Stats>> childrenTasks = content
2929
.filter(not(Files::isSymbolicLink))
3030
.<Callable<Stats>>map(path -> Files.isDirectory(path)
3131
? () -> analyzeFolder(path)
@@ -38,7 +38,7 @@ public FolderStats analyzeFolder(Path folder) throws UncheckedIOException, Inter
3838
scope.throwIfFailed();
3939

4040
var children = childrenTasks.stream()
41-
.map(Future::resultNow)
41+
.map(Subtask::get)
4242
.toList();
4343
return FolderStats.createWithChildren(folder, children);
4444
} catch (ExecutionException ex) {
+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
module loom.experiments {
2-
// for virtual thread / structured concurrency APIs
3-
requires jdk.incubator.concurrent;
4-
5-
// unrelated
2+
// unrelated to virtual threads / structured concurrency
63
requires java.net.http;
74
requires java.desktop;
8-
}
5+
}

frameworks/quarkus/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<properties>
1313
<maven.compiler.release>21</maven.compiler.release>
14-
<compiler-plugin.version>3.11.0</compiler-plugin.version>
14+
<compiler-plugin.version>3.12.1</compiler-plugin.version>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1717
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>

frameworks/spring_boot/pom.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
<properties>
1818
<java.version>21</java.version>
1919
<maven.compiler.release>21</maven.compiler.release>
20-
<maven.compiler.source>21</maven.compiler.source>
21-
<maven.compiler.target>21</maven.compiler.target>
2220
</properties>
2321

2422
<dependencies>
@@ -37,11 +35,11 @@
3735
</plugin>
3836
<plugin>
3937
<artifactId>maven-clean-plugin</artifactId>
40-
<version>3.2.0</version>
38+
<version>3.3.2</version>
4139
</plugin>
4240
<plugin>
4341
<artifactId>maven-compiler-plugin</artifactId>
44-
<version>3.10.1</version>
42+
<version>3.12.1</version>
4543
</plugin>
4644
<plugin>
4745
<artifactId>maven-jar-plugin</artifactId>

pom.xml

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
<properties>
1919
<maven.compiler.release>21</maven.compiler.release>
20-
<maven.compiler.source>21</maven.compiler.source>
21-
<maven.compiler.target>21</maven.compiler.target>
2220
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2321
</properties>
2422

@@ -27,18 +25,17 @@
2725
<plugin>
2826
<groupId>org.apache.maven.plugins</groupId>
2927
<artifactId>maven-compiler-plugin</artifactId>
30-
<version>3.10.1</version>
28+
<version>3.12.1</version>
3129
<configuration>
32-
<fork>true</fork>
3330
<enablePreview>true</enablePreview>
3431
</configuration>
3532
</plugin>
3633
<plugin>
3734
<groupId>org.apache.maven.plugins</groupId>
3835
<artifactId>maven-jar-plugin</artifactId>
39-
<version>3.2.2</version>
36+
<version>3.3.0</version>
4037
</plugin>
4138
</plugins>
4239
</build>
4340

44-
</project>
41+
</project>

0 commit comments

Comments
 (0)