|  | 
| 18 | 18 | package org.newsclub.net.unix.rmi; | 
| 19 | 19 | 
 | 
| 20 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; | 
| 21 |  | -import static org.junit.jupiter.api.Assertions.assertThrows; | 
|  | 21 | +import static org.junit.jupiter.api.Assertions.fail; | 
| 22 | 22 | 
 | 
| 23 | 23 | import java.io.IOException; | 
| 24 | 24 | import java.rmi.NoSuchObjectException; | 
| @@ -60,14 +60,19 @@ public void testRemoteCloseableWithACloseableThing() throws IOException, NotBoun | 
| 60 | 60 |         remoteCloseable.close(); | 
| 61 | 61 |         assertEquals(1, svc.remoteCloseableThingNumberOfCloseCalls(IsCloseable.class)); | 
| 62 | 62 | 
 | 
| 63 |  | -        assertThrows(NoSuchObjectException.class, () -> { | 
| 64 |  | -          remoteCloseable.close(); | 
| 65 |  | -        }); | 
|  | 63 | +        remoteCloseable.close(); | 
|  | 64 | +        fail("Should have thrown an exception"); | 
| 66 | 65 |       } | 
| 67 | 66 |     } catch (NoSuchObjectException e) { | 
| 68 | 67 |       // expected — since the object was forcibly closed above, it was unexported already. | 
| 69 | 68 |       // ideally, RMI could gracefully handle calling #close() on an proxy that points to an | 
| 70 | 69 |       // unexported object. | 
|  | 70 | +    } catch (IllegalArgumentException e) { | 
|  | 71 | +      if (e.getCause() instanceof NoSuchMethodException) { | 
|  | 72 | +        // observed with GraalVM 17.0.9; see java.rmi.server.RemoteObjectInvocationHandler | 
|  | 73 | +      } else { | 
|  | 74 | +        throw e; | 
|  | 75 | +      } | 
| 71 | 76 |     } | 
| 72 | 77 |     assertEquals(1, svc.remoteCloseableThingNumberOfCloseCalls(IsCloseable.class)); | 
| 73 | 78 | 
 | 
| @@ -99,13 +104,18 @@ public void testRemoteCloseableWithANotCloseableThing() throws IOException, NotB | 
| 99 | 104 |       remoteCloseable.close(); | 
| 100 | 105 |       assertEquals(0, svc.remoteCloseableThingNumberOfCloseCalls(NotCloseable.class)); | 
| 101 | 106 | 
 | 
| 102 |  | -      assertThrows(NoSuchObjectException.class, () -> { | 
| 103 |  | -        remoteCloseable.close(); | 
| 104 |  | -      }); | 
|  | 107 | +      remoteCloseable.close(); | 
|  | 108 | +      fail("Should have thrown an exception"); | 
| 105 | 109 |     } catch (NoSuchObjectException e) { | 
| 106 | 110 |       // expected — since the object was forcibly closed above, it was unexported already. | 
| 107 | 111 |       // ideally, RMI could gracefully handle calling #close() on an proxy that points to an | 
| 108 | 112 |       // unexported object. | 
|  | 113 | +    } catch (IllegalArgumentException e) { | 
|  | 114 | +      if (e.getCause() instanceof NoSuchMethodException) { | 
|  | 115 | +        // observed with GraalVM 17.0.9; see java.rmi.server.RemoteObjectInvocationHandler | 
|  | 116 | +      } else { | 
|  | 117 | +        throw e; | 
|  | 118 | +      } | 
| 109 | 119 |     } | 
| 110 | 120 |     assertEquals(0, svc.remoteCloseableThingNumberOfCloseCalls(NotCloseable.class)); | 
| 111 | 121 | 
 | 
|  | 
0 commit comments