diff --git a/.lastmerge b/.lastmerge index 6d9098bab..04846a767 100644 --- a/.lastmerge +++ b/.lastmerge @@ -1 +1 @@ -e40d57c86e18b495722adbf42045288c03924342 +304d812cd4c98755159da427c6701bfb7e0b7c32 diff --git a/src/test/java/com/github/copilot/sdk/CopilotClientTest.java b/src/test/java/com/github/copilot/sdk/CopilotClientTest.java index 05e7290b3..1dde9fd01 100644 --- a/src/test/java/com/github/copilot/sdk/CopilotClientTest.java +++ b/src/test/java/com/github/copilot/sdk/CopilotClientTest.java @@ -424,6 +424,28 @@ void testForceStopWithNoConnectionCompletes() throws Exception { } } + @Test + void testCloseSessionAfterStoppingClientDoesNotThrow() throws Exception { + if (cliPath == null) { + System.out.println("Skipping test: CLI not found"); + return; + } + + try (var client = new CopilotClient(new CopilotClientOptions().setCliPath(cliPath))) { + var session = client.createSession().get(); + + // Stop the client first (which closes the RPC connection) + client.stop().get(); + + // Then close the session - should not throw even though RPC is closed + assertDoesNotThrow(() -> session.close(), "Closing session after client.stop() should not throw exception"); + + // Verify session is terminated + assertThrows(IllegalStateException.class, () -> session.send("test"), + "Session should be terminated after close()"); + } + } + // ===== start() idempotency ===== @Test