Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/src/main/java/io/a2a/spec/Artifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Builder metadata(Map<String, Object> metadata) {
}

public Builder extensions(List<String> extensions) {
this.extensions = this.extensions = (extensions == null) ? null : List.copyOf(extensions);
this.extensions = (extensions == null) ? null : List.copyOf(extensions);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the typo fix is correct, consider initializing extensions to an empty list instead of null when the input is null. This avoids potential NullPointerExceptions for consumers of the Artifact object and aligns with the general best practice of returning empty collections instead of nulls. It also appears to be consistent with how other parts of the codebase handle collections, based on the tests for the Task class.

Suggested change
this.extensions = (extensions == null) ? null : List.copyOf(extensions);
this.extensions = (extensions == null) ? List.of() : List.copyOf(extensions);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to ignore this one since we use null elsewhere too.

return this;
}

Expand Down