Skip to content

Commit

Permalink
Consistent not-null assertions for configured interceptors
Browse files Browse the repository at this point in the history
Closes gh-25088
  • Loading branch information
jhoeller committed May 18, 2020
1 parent 06cfd80 commit c35b21b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -87,17 +87,20 @@ public String getBeanName() {

@Override
public void setInterceptors(List<ChannelInterceptor> interceptors) {
Assert.noNullElements(interceptors, "'interceptors' must not contain null elements");
this.interceptors.clear();
this.interceptors.addAll(interceptors);
}

@Override
public void addInterceptor(ChannelInterceptor interceptor) {
Assert.notNull(interceptor, "'interceptor' must not be null");
this.interceptors.add(interceptor);
}

@Override
public void addInterceptor(int index, ChannelInterceptor interceptor) {
Assert.notNull(interceptor, "'interceptor' must not be null");
this.interceptors.add(index, interceptor);
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.InterceptingClientHttpRequestFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;

/**
Expand Down Expand Up @@ -57,6 +58,7 @@ public abstract class InterceptingHttpAccessor extends HttpAccessor {
* @see AnnotationAwareOrderComparator
*/
public void setInterceptors(List<ClientHttpRequestInterceptor> interceptors) {
Assert.noNullElements(interceptors, "'interceptors' must not contain null elements");
// Take getInterceptors() List as-is when passed in here
if (this.interceptors != interceptors) {
this.interceptors.clear();
Expand Down

0 comments on commit c35b21b

Please sign in to comment.