Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.lang.Nullable;
import org.springframework.retry.RecoveryCallback;
import org.springframework.retry.support.RetryTemplate;
import org.springframework.transaction.PlatformTransactionManager;
Expand Down Expand Up @@ -194,8 +195,9 @@ public void setDefaultRequeueRejected(Boolean requeueRejected) {
* @return the advice chain that was set. Defaults to {@code null}.
* @since 1.7.4
*/
@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.

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,9 @@ public void setAdviceChain(Advice... adviceChain) {
this.adviceChain = Arrays.copyOf(adviceChain, adviceChain.length);
}

@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?

}

/**
Expand Down