Browse Source

Consistent not-null assertions for configured interceptors

Closes gh-25088
pull/25096/head
Juergen Hoeller 6 years ago
parent
commit
c35b21b49f
  1. 5
      spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java
  2. 4
      spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java

5
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 @Override
public void setInterceptors(List<ChannelInterceptor> interceptors) { public void setInterceptors(List<ChannelInterceptor> interceptors) {
Assert.noNullElements(interceptors, "'interceptors' must not contain null elements");
this.interceptors.clear(); this.interceptors.clear();
this.interceptors.addAll(interceptors); this.interceptors.addAll(interceptors);
} }
@Override @Override
public void addInterceptor(ChannelInterceptor interceptor) { public void addInterceptor(ChannelInterceptor interceptor) {
Assert.notNull(interceptor, "'interceptor' must not be null");
this.interceptors.add(interceptor); this.interceptors.add(interceptor);
} }
@Override @Override
public void addInterceptor(int index, ChannelInterceptor interceptor) { public void addInterceptor(int index, ChannelInterceptor interceptor) {
Assert.notNull(interceptor, "'interceptor' must not be null");
this.interceptors.add(index, interceptor); this.interceptors.add(index, interceptor);
} }

4
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.ClientHttpRequestInterceptor;
import org.springframework.http.client.InterceptingClientHttpRequestFactory; import org.springframework.http.client.InterceptingClientHttpRequestFactory;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
/** /**
@ -57,6 +58,7 @@ public abstract class InterceptingHttpAccessor extends HttpAccessor {
* @see AnnotationAwareOrderComparator * @see AnnotationAwareOrderComparator
*/ */
public void setInterceptors(List<ClientHttpRequestInterceptor> interceptors) { public void setInterceptors(List<ClientHttpRequestInterceptor> interceptors) {
Assert.noNullElements(interceptors, "'interceptors' must not contain null elements");
// Take getInterceptors() List as-is when passed in here // Take getInterceptors() List as-is when passed in here
if (this.interceptors != interceptors) { if (this.interceptors != interceptors) {
this.interceptors.clear(); this.interceptors.clear();

Loading…
Cancel
Save