Polishing

This commit is contained in:
Sam Brannen 2019-03-02 14:15:43 +01:00
parent 7d926a847d
commit 02be21d0dc
5 changed files with 20 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@ -130,8 +130,8 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM
@Override @Override
public void multicastEvent(final ApplicationEvent event, @Nullable ResolvableType eventType) { public void multicastEvent(final ApplicationEvent event, @Nullable ResolvableType eventType) {
ResolvableType type = (eventType != null ? eventType : resolveDefaultEventType(event)); ResolvableType type = (eventType != null ? eventType : resolveDefaultEventType(event));
for (final ApplicationListener<?> listener : getApplicationListeners(event, type)) { Executor executor = getTaskExecutor();
Executor executor = getTaskExecutor(); for (ApplicationListener<?> listener : getApplicationListeners(event, type)) {
if (executor != null) { if (executor != null) {
executor.execute(() -> invokeListener(listener, event)); executor.execute(() -> invokeListener(listener, event));
} }

View File

@ -92,24 +92,24 @@ import org.springframework.util.ReflectionUtils;
* to detect special beans defined in its internal bean factory: * to detect special beans defined in its internal bean factory:
* Therefore, this class automatically registers * Therefore, this class automatically registers
* {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor BeanFactoryPostProcessors}, * {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor BeanFactoryPostProcessors},
* {@link org.springframework.beans.factory.config.BeanPostProcessor BeanPostProcessors} * {@link org.springframework.beans.factory.config.BeanPostProcessor BeanPostProcessors},
* and {@link org.springframework.context.ApplicationListener ApplicationListeners} * and {@link org.springframework.context.ApplicationListener ApplicationListeners}
* which are defined as beans in the context. * which are defined as beans in the context.
* *
* <p>A {@link org.springframework.context.MessageSource} may also be supplied * <p>A {@link org.springframework.context.MessageSource} may also be supplied
* as a bean in the context, with the name "messageSource"; otherwise, message * as a bean in the context, with the name "messageSource"; otherwise, message
* resolution is delegated to the parent context. Furthermore, a multicaster * resolution is delegated to the parent context. Furthermore, a multicaster
* for application events can be supplied as "applicationEventMulticaster" bean * for application events can be supplied as an "applicationEventMulticaster" bean
* of type {@link org.springframework.context.event.ApplicationEventMulticaster} * of type {@link org.springframework.context.event.ApplicationEventMulticaster}
* in the context; otherwise, a default multicaster of type * in the context; otherwise, a default multicaster of type
* {@link org.springframework.context.event.SimpleApplicationEventMulticaster} will be used. * {@link org.springframework.context.event.SimpleApplicationEventMulticaster} will be used.
* *
* <p>Implements resource loading through extending * <p>Implements resource loading by extending
* {@link org.springframework.core.io.DefaultResourceLoader}. * {@link org.springframework.core.io.DefaultResourceLoader}.
* Consequently treats non-URL resource paths as class path resources * Consequently treats non-URL resource paths as class path resources
* (supporting full class path resource names that include the package path, * (supporting full class path resource names that include the package path,
* e.g. "mypackage/myresource.dat"), unless the {@link #getResourceByPath} * e.g. "mypackage/myresource.dat"), unless the {@link #getResourceByPath}
* method is overwritten in a subclass. * method is overridden in a subclass.
* *
* @author Rod Johnson * @author Rod Johnson
* @author Juergen Hoeller * @author Juergen Hoeller
@ -390,7 +390,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
else { else {
applicationEvent = new PayloadApplicationEvent<>(this, event); applicationEvent = new PayloadApplicationEvent<>(this, event);
if (eventType == null) { if (eventType == null) {
eventType = ((PayloadApplicationEvent) applicationEvent).getResolvableType(); eventType = ((PayloadApplicationEvent<?>) applicationEvent).getResolvableType();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@ -155,6 +155,7 @@ public class AnnotationDrivenEventListenerTests {
@Test @Test
public void methodSignatureNoEvent() { public void methodSignatureNoEvent() {
@SuppressWarnings("resource")
AnnotationConfigApplicationContext failingContext = AnnotationConfigApplicationContext failingContext =
new AnnotationConfigApplicationContext(); new AnnotationConfigApplicationContext();
failingContext.register(BasicConfiguration.class, failingContext.register(BasicConfiguration.class,
@ -173,7 +174,6 @@ public class AnnotationDrivenEventListenerTests {
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class); ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
TestEventListener listener = this.context.getBean(TestEventListener.class); TestEventListener listener = this.context.getBean(TestEventListener.class);
this.eventCollector.assertNoEventReceived(listener); this.eventCollector.assertNoEventReceived(listener);
this.eventCollector.assertNoEventReceived(replyEventListener); this.eventCollector.assertNoEventReceived(replyEventListener);
this.context.publishEvent(event); this.context.publishEvent(event);
@ -747,7 +747,7 @@ public class AnnotationDrivenEventListenerTests {
@EventListener @EventListener
@Async @Async
public void handleAsync(AnotherTestEvent event) { public void handleAsync(AnotherTestEvent event) {
assertTrue(!Thread.currentThread().getName().equals(event.content)); assertNotEquals(event.content, Thread.currentThread().getName());
collectEvent(event); collectEvent(event);
this.countDownLatch.countDown(); this.countDownLatch.countDown();
} }
@ -794,7 +794,7 @@ public class AnnotationDrivenEventListenerTests {
@EventListener @EventListener
@Async @Async
public void handleAsync(AnotherTestEvent event) { public void handleAsync(AnotherTestEvent event) {
assertTrue(!Thread.currentThread().getName().equals(event.content)); assertNotEquals(event.content, Thread.currentThread().getName());
this.eventCollector.addEvent(this, event); this.eventCollector.addEvent(this, event);
this.countDownLatch.countDown(); this.countDownLatch.countDown();
} }
@ -820,7 +820,7 @@ public class AnnotationDrivenEventListenerTests {
@EventListener @EventListener
@Async @Async
public void handleAsync(AnotherTestEvent event) { public void handleAsync(AnotherTestEvent event) {
assertTrue(!Thread.currentThread().getName().equals(event.content)); assertNotEquals(event.content, Thread.currentThread().getName());
this.eventCollector.addEvent(this, event); this.eventCollector.addEvent(this, event);
this.countDownLatch.countDown(); this.countDownLatch.countDown();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@ -30,7 +30,7 @@ import org.springframework.web.server.adapter.ForwardedHeaderTransformer;
* client-originated protocol and address. * client-originated protocol and address.
* *
* <p>Alternatively if {@link #setRemoveOnly removeOnly} is set to "true", then * <p>Alternatively if {@link #setRemoveOnly removeOnly} is set to "true", then
* "Forwarded" and "X-Forwarded-*" headers are only removed, and not used. * "Forwarded" and "X-Forwarded-*" headers are only removed and not used.
* *
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Rossen Stoyanchev * @author Rossen Stoyanchev

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@ -32,7 +32,6 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse; import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse;
import org.springframework.web.filter.reactive.ForwardedHeaderFilter;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebExceptionHandler; import org.springframework.web.server.WebExceptionHandler;
import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebFilter;
@ -180,12 +179,13 @@ public class WebHttpHandlerBuilderTests {
} }
@Configuration @Configuration
@SuppressWarnings({"unused", "deprecation"}) @SuppressWarnings("unused")
static class ForwardedHeaderFilterConfig { static class ForwardedHeaderFilterConfig {
@Bean @Bean
public ForwardedHeaderFilter forwardedHeaderFilter() { @SuppressWarnings("deprecation")
return new ForwardedHeaderFilter(); public WebFilter forwardedHeaderFilter() {
return new org.springframework.web.filter.reactive.ForwardedHeaderFilter();
} }
@Bean @Bean