From 02be21d0dce6a94739bbaf8fa4c42b524db13a4f Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 2 Mar 2019 14:15:43 +0100 Subject: [PATCH] Polishing --- .../event/SimpleApplicationEventMulticaster.java | 6 +++--- .../context/support/AbstractApplicationContext.java | 10 +++++----- .../event/AnnotationDrivenEventListenerTests.java | 10 +++++----- .../web/filter/reactive/ForwardedHeaderFilter.java | 4 ++-- .../web/server/adapter/WebHttpHandlerBuilderTests.java | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java b/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java index d62de6834eb..d9de4d88d37 100644 --- a/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java +++ b/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java @@ -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"); * you may not use this file except in compliance with the License. @@ -130,8 +130,8 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM @Override public void multicastEvent(final ApplicationEvent event, @Nullable ResolvableType eventType) { 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) { executor.execute(() -> invokeListener(listener, event)); } diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 25831f3a6b5..fb8966cccbd 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -92,24 +92,24 @@ import org.springframework.util.ReflectionUtils; * to detect special beans defined in its internal bean factory: * Therefore, this class automatically registers * {@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} * which are defined as beans in the context. * *

A {@link org.springframework.context.MessageSource} may also be supplied * as a bean in the context, with the name "messageSource"; otherwise, message * 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} * in the context; otherwise, a default multicaster of type * {@link org.springframework.context.event.SimpleApplicationEventMulticaster} will be used. * - *

Implements resource loading through extending + *

Implements resource loading by extending * {@link org.springframework.core.io.DefaultResourceLoader}. * Consequently treats non-URL resource paths as class path resources * (supporting full class path resource names that include the package path, * 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 Juergen Hoeller @@ -390,7 +390,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader else { applicationEvent = new PayloadApplicationEvent<>(this, event); if (eventType == null) { - eventType = ((PayloadApplicationEvent) applicationEvent).getResolvableType(); + eventType = ((PayloadApplicationEvent) applicationEvent).getResolvableType(); } } diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index 190771c6af7..1c069347dbc 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -155,6 +155,7 @@ public class AnnotationDrivenEventListenerTests { @Test public void methodSignatureNoEvent() { + @SuppressWarnings("resource") AnnotationConfigApplicationContext failingContext = new AnnotationConfigApplicationContext(); failingContext.register(BasicConfiguration.class, @@ -173,7 +174,6 @@ public class AnnotationDrivenEventListenerTests { ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class); TestEventListener listener = this.context.getBean(TestEventListener.class); - this.eventCollector.assertNoEventReceived(listener); this.eventCollector.assertNoEventReceived(replyEventListener); this.context.publishEvent(event); @@ -747,7 +747,7 @@ public class AnnotationDrivenEventListenerTests { @EventListener @Async public void handleAsync(AnotherTestEvent event) { - assertTrue(!Thread.currentThread().getName().equals(event.content)); + assertNotEquals(event.content, Thread.currentThread().getName()); collectEvent(event); this.countDownLatch.countDown(); } @@ -794,7 +794,7 @@ public class AnnotationDrivenEventListenerTests { @EventListener @Async public void handleAsync(AnotherTestEvent event) { - assertTrue(!Thread.currentThread().getName().equals(event.content)); + assertNotEquals(event.content, Thread.currentThread().getName()); this.eventCollector.addEvent(this, event); this.countDownLatch.countDown(); } @@ -820,7 +820,7 @@ public class AnnotationDrivenEventListenerTests { @EventListener @Async public void handleAsync(AnotherTestEvent event) { - assertTrue(!Thread.currentThread().getName().equals(event.content)); + assertNotEquals(event.content, Thread.currentThread().getName()); this.eventCollector.addEvent(this, event); this.countDownLatch.countDown(); } diff --git a/spring-web/src/main/java/org/springframework/web/filter/reactive/ForwardedHeaderFilter.java b/spring-web/src/main/java/org/springframework/web/filter/reactive/ForwardedHeaderFilter.java index 4416d1f2e8c..3d4bfce7d33 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/reactive/ForwardedHeaderFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/reactive/ForwardedHeaderFilter.java @@ -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"); * 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. * *

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 Rossen Stoyanchev diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java index e2616478595..71e3f84e7a4 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java @@ -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"); * 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.mock.http.server.reactive.test.MockServerHttpRequest; 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.WebExceptionHandler; import org.springframework.web.server.WebFilter; @@ -180,12 +179,13 @@ public class WebHttpHandlerBuilderTests { } @Configuration - @SuppressWarnings({"unused", "deprecation"}) + @SuppressWarnings("unused") static class ForwardedHeaderFilterConfig { @Bean - public ForwardedHeaderFilter forwardedHeaderFilter() { - return new ForwardedHeaderFilter(); + @SuppressWarnings("deprecation") + public WebFilter forwardedHeaderFilter() { + return new org.springframework.web.filter.reactive.ForwardedHeaderFilter(); } @Bean