Fix EI_EXPOSE_REP: Return defensive copies from collection getters in DTOs#29
Merged
brunoborges merged 3 commits intomainfrom Feb 6, 2026
Merged
Conversation
…REP findings Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
…ackages Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix SpotBugs EI_EXPOSE_REP issues in DTO classes
Fix EI_EXPOSE_REP: Return defensive copies from collection getters in DTOs
Feb 6, 2026
brunoborges
approved these changes
Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SpotBugs identified 95 instances of EI_EXPOSE_REP (CWE-374) where getters in DTO/event classes expose mutable collections, allowing external modification of internal state.
Changes
Applied defensive copy pattern to collection getters across 16 classes in
eventsandjsonpackages:Collections.unmodifiableList()Collections.unmodifiableMap().clone()Example
Before:
After:
Scope
Affected classes include configuration DTOs (
SessionConfig,CreateSessionRequest,ResumeSessionConfig), event data classes (AssistantMessageEvent,AssistantUsageEvent,UserMessageEvent), and related types. Setters unchanged - Jackson deserialization remains functional. No API-breaking changes.Remaining EI_EXPOSE_REP findings relate to
getData()methods returning complete data objects, not addressed in this PR.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
checkstyle.org/opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/copilot-sdk-java/.codeql-scratch/dbs/java/working/files-to-index10602877755701355398.list --sourceArchiveDir=/home/REDACTED/work/copilot-sdk-java/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/copilot-sdk-java/.codeql-scratch/dbs/java/trap/java which n-Hotspot_jdk/17.0.18-8/x64/bin/java(dns block)https://api.github.com/copilot_internal/user/home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot --server --log-level info --stdio --auth-token-env COPILOT_SDK_AUTH_TOKEN --no-auto-login(http block)/home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot --server --log-level info --stdio --auth-token-env COPILOT_SDK_AUTH_TOKEN --no-auto-login r/.m2/repository/usr/lib/jvm/temurin-17-jdk-amd64/lib/jspawnhelper(http block)/home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot --server --log-level info --stdio --auth-token-env COPILOT_SDK_AUTH_TOKEN --no-auto-login /sdk/json/ModelSgit /sdk/json/ModelCrev-parse /sdk/json/Sessio--show-toplevel /sdk/json/GetForegroundSessionResponse.java /sdk�� /sdk/json/ModelInfo.java /sdk/json/UserInputHandler.java ache/Java_Temurin-Hotspot_jdk/17.0.18-8/x64/bin/grep 8bf1bbb6(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.