-
Notifications
You must be signed in to change notification settings - Fork 367
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
Compilation error due to ExecutorService API change in JDK 19 #285
Comments
Ooof. An API break in the JDK that's not even mentioned in the change notes. (At least I didn't see it there.) That's going to be "fun" to sort out. It's the kind of fun I could do without. The immediate issue seems to be that |
The CSR for the change (https://bugs.openjdk.org/browse/JDK-8285450) does at least acknowledge this could happen:
Based on some testing I've been doing with 19 this problem does seem to be very rare. |
ExecutorService implements AutoCloseable in Java 19 and provides a default method for close(). This conflicts in CloseableExecutorService, which mixes in org.apache.sshd.common.Closeable, which has its own default method for close(). As a minimum fix add overrides of close() as needed, explicitly calling the Apache MINA sshd variant of close(). Bug: apache#285
ExecutorService implements AutoCloseable in Java 19 and provides a default method for close(). This conflicts in CloseableExecutorService, which mixes in org.apache.sshd.common.Closeable, which has its own default method for close(). As a minimum fix add an overrides of close() explicitly calling the Apache MINA sshd variant of close(). Bug: apache#285
ExecutorService implements AutoCloseable in Java 19 and provides a default method for close(). This conflicts in CloseableExecutorService, which mixes in org.apache.sshd.common.Closeable, which has its own default method for close(). As a minimum fix add overrides of close() as needed, explicitly calling the Apache MINA sshd variant of close(). Bug: apache#285
I'm still seeing a compilation error:
One option might be to rethrow as diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/CloseableExecutorService.java b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/CloseableExecutorService.java
index cc7a81b9..3f4bf77d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/CloseableExecutorService.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/CloseableExecutorService.java
@@ -20,6 +20,7 @@
package org.apache.sshd.common.util.threads;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.time.Duration;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
@@ -34,7 +35,11 @@ public interface CloseableExecutorService extends ExecutorService, Closeable {
}
@Override
- default void close() throws IOException {
- Closeable.super.close();
+ default void close() {
+ try {
+ Closeable.super.close();
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
}
} |
Want to provide a pull request? |
Follow-up to 03986c5 Bug: apache#285
Thank you, Liam! |
Version
3b16da4
Bug description
Starting in JDK 19,
ExecutorService
implementsAutoCloseable
: openjdk/jdk@00e6c63#diff-139913957207a1eeaa338c35b269f2c566b358590ae62dd2a8063e98bb5b0456This change causes a compilation error in mina-sshd.
Actual behavior
Expected behavior
I expected the project to compile
Relevant log output
Other information
No response
The text was updated successfully, but these errors were encountered: