Skip to content

Commit 4fdef27

Browse files
committed
On branch edburns/dd-2758695-virtual-threads-accept-executor
modified: src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java - Correctly implement the semantic of "null argument to setExecutor means use the default executor." modified: src/test/java/com/github/copilot/sdk/ConfigCloneTest.java - Adjust test based on defensive copy changes.
1 parent 11aa5d6 commit 4fdef27

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,16 @@ public Executor getExecutor() {
264264
* {@code CompletableFuture} combinators instead of the default
265265
* {@code ForkJoinPool.commonPool()}. This allows callers to isolate SDK work
266266
* onto a dedicated thread pool or integrate with container-managed threading.
267+
* <p>
268+
* Passing {@code null} reverts to the default {@code ForkJoinPool.commonPool()}
269+
* behavior.
267270
*
268271
* @param executor
269-
* the executor to use
272+
* the executor to use, or {@code null} for the default
270273
* @return this options instance for fluent chaining
271274
*/
272275
public CopilotClientOptions setExecutor(Executor executor) {
273-
this.executor = Objects.requireNonNull(executor, "executor must not be null");
276+
this.executor = executor;
274277
return this;
275278
}
276279

src/test/java/com/github/copilot/sdk/ConfigCloneTest.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,16 @@ void copilotClientOptionsArrayIndependence() {
4949
original.setCliArgs(args);
5050

5151
CopilotClientOptions cloned = original.clone();
52-
cloned.getCliArgs()[0] = "--changed";
5352

53+
// Mutate the source array after set — should not affect original or clone
54+
args[0] = "--changed";
55+
56+
assertEquals("--flag1", original.getCliArgs()[0]);
57+
assertEquals("--flag1", cloned.getCliArgs()[0]);
58+
59+
// getCliArgs() returns a copy, so mutating it should not affect internals
60+
original.getCliArgs()[0] = "--mutated";
5461
assertEquals("--flag1", original.getCliArgs()[0]);
55-
assertEquals("--changed", cloned.getCliArgs()[0]);
5662
}
5763

5864
@Test
@@ -64,12 +70,15 @@ void copilotClientOptionsEnvironmentIndependence() {
6470

6571
CopilotClientOptions cloned = original.clone();
6672

67-
// Mutate the original environment map to test independence
73+
// Mutate the source map after set — should not affect original or clone
6874
env.put("KEY2", "value2");
6975

70-
// The cloned config should be unaffected by mutations to the original map
76+
assertEquals(1, original.getEnvironment().size());
7177
assertEquals(1, cloned.getEnvironment().size());
72-
assertEquals(2, original.getEnvironment().size());
78+
79+
// getEnvironment() returns a copy, so mutating it should not affect internals
80+
original.getEnvironment().put("KEY3", "value3");
81+
assertEquals(1, original.getEnvironment().size());
7382
}
7483

7584
@Test

0 commit comments

Comments
 (0)