diff --git a/junixsocket-rmi/src/test/java/org/newsclub/net/unix/rmi/RemoteCloseableTest.java b/junixsocket-rmi/src/test/java/org/newsclub/net/unix/rmi/RemoteCloseableTest.java index 5fd31927a..fb890ddf4 100644 --- a/junixsocket-rmi/src/test/java/org/newsclub/net/unix/rmi/RemoteCloseableTest.java +++ b/junixsocket-rmi/src/test/java/org/newsclub/net/unix/rmi/RemoteCloseableTest.java @@ -18,7 +18,7 @@ package org.newsclub.net.unix.rmi; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.rmi.NoSuchObjectException; @@ -60,14 +60,19 @@ public void testRemoteCloseableWithACloseableThing() throws IOException, NotBoun remoteCloseable.close(); assertEquals(1, svc.remoteCloseableThingNumberOfCloseCalls(IsCloseable.class)); - assertThrows(NoSuchObjectException.class, () -> { - remoteCloseable.close(); - }); + remoteCloseable.close(); + fail("Should have thrown an exception"); } } catch (NoSuchObjectException e) { // expected — since the object was forcibly closed above, it was unexported already. // ideally, RMI could gracefully handle calling #close() on an proxy that points to an // unexported object. + } catch (IllegalArgumentException e) { + if (e.getCause() instanceof NoSuchMethodException) { + // observed with GraalVM 17.0.9; see java.rmi.server.RemoteObjectInvocationHandler + } else { + throw e; + } } assertEquals(1, svc.remoteCloseableThingNumberOfCloseCalls(IsCloseable.class)); @@ -99,13 +104,18 @@ public void testRemoteCloseableWithANotCloseableThing() throws IOException, NotB remoteCloseable.close(); assertEquals(0, svc.remoteCloseableThingNumberOfCloseCalls(NotCloseable.class)); - assertThrows(NoSuchObjectException.class, () -> { - remoteCloseable.close(); - }); + remoteCloseable.close(); + fail("Should have thrown an exception"); } catch (NoSuchObjectException e) { // expected — since the object was forcibly closed above, it was unexported already. // ideally, RMI could gracefully handle calling #close() on an proxy that points to an // unexported object. + } catch (IllegalArgumentException e) { + if (e.getCause() instanceof NoSuchMethodException) { + // observed with GraalVM 17.0.9; see java.rmi.server.RemoteObjectInvocationHandler + } else { + throw e; + } } assertEquals(0, svc.remoteCloseableThingNumberOfCloseCalls(NotCloseable.class)); diff --git a/src/site/markdown/changelog.md b/src/site/markdown/changelog.md index 635ef5900..762c53ba0 100644 --- a/src/site/markdown/changelog.md +++ b/src/site/markdown/changelog.md @@ -17,6 +17,7 @@ artifact (`pom`); see [Add junixsocket to your project](dependency. - Fix left-over temporary library files on Windows - Fix duplicate file descriptors being received sporadically for non-blocking sockets and upon error - Fix a flaky selftest when VSOCK is not supported +- Fix a flaky selftest with GraalvM 17 - Improve interoperability with exotic Linux/Java combinations - Add support for loongarch64 Linux - Add more tests