diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java b/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java index c933757d33..40d6a09899 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java @@ -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. @@ -87,17 +87,20 @@ public abstract class AbstractMessageChannel implements MessageChannel, Intercep @Override public void setInterceptors(List 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); } diff --git a/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java b/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java index 40b839a486..a8977cce81 100644 --- a/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java +++ b/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java @@ -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. @@ -24,6 +24,7 @@ import org.springframework.http.client.ClientHttpRequestFactory; 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; /** @@ -57,6 +58,7 @@ public abstract class InterceptingHttpAccessor extends HttpAccessor { * @see AnnotationAwareOrderComparator */ public void setInterceptors(List 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();