Skip to content

Commit 922ec0e

Browse files
Copilotbrunoborges
andcommitted
Fix remaining collection getter defensive copies in events and json packages
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent 0735b52 commit 922ec0e

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/main/java/com/github/copilot/sdk/events/SubagentSelectedEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void setAgentDisplayName(String agentDisplayName) {
6060
}
6161

6262
public String[] getTools() {
63-
return tools;
63+
return tools == null ? null : tools.clone();
6464
}
6565

6666
public void setTools(String[] tools) {

src/main/java/com/github/copilot/sdk/events/ToolExecutionCompleteEvent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
88
import com.fasterxml.jackson.annotation.JsonProperty;
99

10+
import java.util.Collections;
1011
import java.util.Map;
1112

1213
/**
@@ -98,7 +99,7 @@ public void setError(Error error) {
9899
}
99100

100101
public Map<String, Object> getToolTelemetry() {
101-
return toolTelemetry;
102+
return toolTelemetry == null ? null : Collections.unmodifiableMap(toolTelemetry);
102103
}
103104

104105
public void setToolTelemetry(Map<String, Object> toolTelemetry) {

src/main/java/com/github/copilot/sdk/events/UserMessageEvent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
88
import com.fasterxml.jackson.annotation.JsonProperty;
99

10+
import java.util.Collections;
1011
import java.util.List;
1112

1213
/**
@@ -65,7 +66,7 @@ public void setTransformedContent(String transformedContent) {
6566
}
6667

6768
public List<Attachment> getAttachments() {
68-
return attachments;
69+
return attachments == null ? null : Collections.unmodifiableList(attachments);
6970
}
7071

7172
public void setAttachments(List<Attachment> attachments) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package com.github.copilot.sdk.json;
66

7+
import java.util.Collections;
78
import java.util.List;
89
import java.util.Map;
910

@@ -128,7 +129,7 @@ public CustomAgentConfig setDescription(String description) {
128129
* @return the list of tool identifiers
129130
*/
130131
public List<String> getTools() {
131-
return tools;
132+
return tools == null ? null : Collections.unmodifiableList(tools);
132133
}
133134

134135
/**
@@ -175,7 +176,7 @@ public CustomAgentConfig setPrompt(String prompt) {
175176
* @return the MCP servers map
176177
*/
177178
public Map<String, Object> getMcpServers() {
178-
return mcpServers;
179+
return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers);
179180
}
180181

181182
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package com.github.copilot.sdk.json;
66

7+
import java.util.Collections;
78
import java.util.List;
89

910
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -60,7 +61,7 @@ public MessageOptions setPrompt(String prompt) {
6061
* @return the list of attachments
6162
*/
6263
public List<Attachment> getAttachments() {
63-
return attachments;
64+
return attachments == null ? null : Collections.unmodifiableList(attachments);
6465
}
6566

6667
/**

0 commit comments

Comments
 (0)