Skip to content

Conversation

garyrussell
Copy link
Contributor

@Nullable
public Advice[] getAdviceChain() {
return Arrays.copyOf(this.adviceChain, this.adviceChain.length);
return this.adviceChain == null ? null : Arrays.copyOf(this.adviceChain, this.adviceChain.length);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need copy here at all?
Since I see we do it anyway in the setAdviceChain().

Looks like this is an issue only for the current 2.1.x version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the user could mutate the array but it won't take any effect because we built the proxy only during initialization.

@Nullable
protected Advice[] getAdviceChain() {
return this.adviceChain;
return this.adviceChain == null ? null : Arrays.copyOf(this.adviceChain, this.adviceChain.length);
Copy link
Member

Choose a reason for hiding this comment

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

Right. And this is exactly what I commented above.
Why do we need to do this?
Is this something SonarQube complains, too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants