From c64a322e1984e2bac25ff7d92d0075b96f962c9b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 19 Jul 2023 01:25:20 +0200 Subject: [PATCH] Polishing --- .../ROOT/pages/core/beans/context-introduction.adoc | 4 ++-- .../springframework/aop/framework/CglibAopProxy.java | 4 ++-- .../support/AbstractXmlApplicationContext.java | 12 +++++++----- .../springframework/mock/env/MockEnvironment.java | 2 +- .../core/testfixture/env/MockPropertySource.java | 4 ++-- .../jms/connection/CachingConnectionFactory.java | 5 ++--- .../springframework/mock/env/MockEnvironment.java | 5 +++-- .../springframework/mock/env/MockPropertySource.java | 4 +++- .../web/util/pattern/PathPattern.java | 4 +--- 9 files changed, 23 insertions(+), 21 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/core/beans/context-introduction.adoc b/framework-docs/modules/ROOT/pages/core/beans/context-introduction.adoc index c77bc8a923..44e766609b 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/context-introduction.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/context-introduction.adoc @@ -910,7 +910,7 @@ Java:: [source,java,indent=0,subs="verbatim,quotes",role="primary"] ---- // create a startup step and start recording - StartupStep scanPackages = this.getApplicationStartup().start("spring.context.base-packages.scan"); + StartupStep scanPackages = getApplicationStartup().start("spring.context.base-packages.scan"); // add tagging information to the current step scanPackages.tag("packages", () -> Arrays.toString(basePackages)); // perform the actual phase we're instrumenting @@ -924,7 +924,7 @@ Kotlin:: [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] ---- // create a startup step and start recording - val scanPackages = this.getApplicationStartup().start("spring.context.base-packages.scan") + val scanPackages = getApplicationStartup().start("spring.context.base-packages.scan") // add tagging information to the current step scanPackages.tag("packages", () -> Arrays.toString(basePackages)) // perform the actual phase we're instrumenting diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java index 4b331ffec8..dceed756b4 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java @@ -370,8 +370,8 @@ class CglibAopProxy implements AopProxy, Serializable { @Override public boolean equals(@Nullable Object other) { - return (this == other || (other instanceof CglibAopProxy cglibAopProxy && - AopProxyUtils.equalsInProxy(this.advised, cglibAopProxy.advised))); + return (this == other || (other instanceof CglibAopProxy that && + AopProxyUtils.equalsInProxy(this.advised, that.advised))); } @Override diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java index c81d851c9f..c21002abd2 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2023 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. @@ -20,6 +20,7 @@ import java.io.IOException; import org.springframework.beans.BeansException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.factory.xml.BeanDefinitionDocumentReader; import org.springframework.beans.factory.xml.ResourceEntityResolver; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.ApplicationContext; @@ -95,12 +96,13 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC } /** - * Initialize the bean definition reader used for loading the bean - * definitions of this context. Default implementation is empty. + * Initialize the bean definition reader used for loading the bean definitions + * of this context. The default implementation sets the validating flag. *

Can be overridden in subclasses, e.g. for turning off XML validation - * or using a different XmlBeanDefinitionParser implementation. + * or using a different {@link BeanDefinitionDocumentReader} implementation. * @param reader the bean definition reader used by this context - * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader#setDocumentReaderClass + * @see XmlBeanDefinitionReader#setValidating + * @see XmlBeanDefinitionReader#setDocumentReaderClass */ protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) { reader.setValidating(this.validating); diff --git a/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java b/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java index 6397865a1f..9a533f5635 100644 --- a/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java +++ b/spring-context/src/test/java/org/springframework/mock/env/MockEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2023 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. diff --git a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/MockPropertySource.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/MockPropertySource.java index f6b444d139..a4cbd1f22e 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/MockPropertySource.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/env/MockPropertySource.java @@ -28,7 +28,7 @@ import org.springframework.core.env.PropertySource; * * The {@link #setProperty} and {@link #withProperty} methods are exposed for * convenience, for example: - *

+ * 
  * {@code
  *   PropertySource source = new MockPropertySource().withProperty("foo", "bar");
  * }
@@ -77,7 +77,7 @@ public class MockPropertySource extends PropertiesPropertySource {
 
 	/**
 	 * Create a new {@code MockPropertySource} with the given name and backed by the given
-	 * {@link Properties} object
+	 * {@link Properties} object.
 	 * @param name the {@linkplain #getName() name} of the property source
 	 * @param properties the properties to use
 	 */
diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java
index 589c8cc098..e124185f94 100644
--- a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java
+++ b/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java
@@ -559,11 +559,10 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
 		}
 
 		@Override
-		public boolean equals(@Nullable Object obj) {
+		public boolean equals(@Nullable Object other) {
 			// Effectively checking object equality as well as toString equality.
 			// On WebSphere MQ, Destination objects do not implement equals...
-			return (this == obj || (obj instanceof DestinationCacheKey otherKey &&
-					destinationEquals(otherKey)));
+			return (this == other || (other instanceof DestinationCacheKey that && destinationEquals(that)));
 		}
 
 		@Override
diff --git a/spring-test/src/main/java/org/springframework/mock/env/MockEnvironment.java b/spring-test/src/main/java/org/springframework/mock/env/MockEnvironment.java
index 8975e15f45..88072db943 100644
--- a/spring-test/src/main/java/org/springframework/mock/env/MockEnvironment.java
+++ b/spring-test/src/main/java/org/springframework/mock/env/MockEnvironment.java
@@ -21,8 +21,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
 
 /**
  * Simple {@link ConfigurableEnvironment} implementation exposing
- * {@link #setProperty(String, String)} and {@link #withProperty(String, String)}
- * methods for testing purposes.
+ * {@link #setProperty} and {@link #withProperty} methods for testing purposes.
  *
  * @author Chris Beams
  * @author Sam Brannen
@@ -33,6 +32,7 @@ public class MockEnvironment extends AbstractEnvironment {
 
 	private final MockPropertySource propertySource = new MockPropertySource();
 
+
 	/**
 	 * Create a new {@code MockEnvironment} with a single {@link MockPropertySource}.
 	 */
@@ -40,6 +40,7 @@ public class MockEnvironment extends AbstractEnvironment {
 		getPropertySources().addLast(this.propertySource);
 	}
 
+
 	/**
 	 * Set a property on the underlying {@link MockPropertySource} for this environment.
 	 */
diff --git a/spring-test/src/main/java/org/springframework/mock/env/MockPropertySource.java b/spring-test/src/main/java/org/springframework/mock/env/MockPropertySource.java
index 5bf297c1e2..3ef180fcf2 100644
--- a/spring-test/src/main/java/org/springframework/mock/env/MockPropertySource.java
+++ b/spring-test/src/main/java/org/springframework/mock/env/MockPropertySource.java
@@ -48,6 +48,7 @@ public class MockPropertySource extends PropertiesPropertySource {
 	 */
 	public static final String MOCK_PROPERTIES_PROPERTY_SOURCE_NAME = "mockProperties";
 
+
 	/**
 	 * Create a new {@code MockPropertySource} named {@value #MOCK_PROPERTIES_PROPERTY_SOURCE_NAME}
 	 * that will maintain its own internal {@link Properties} instance.
@@ -84,6 +85,7 @@ public class MockPropertySource extends PropertiesPropertySource {
 		super(name, properties);
 	}
 
+
 	/**
 	 * Set the given property on the underlying {@link Properties} object.
 	 */
@@ -97,7 +99,7 @@ public class MockPropertySource extends PropertiesPropertySource {
 	 * @return this {@link MockPropertySource} instance
 	 */
 	public MockPropertySource withProperty(String name, Object value) {
-		this.setProperty(name, value);
+		setProperty(name, value);
 		return this;
 	}
 
diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java
index 95876951ae..545fe66724 100644
--- a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java
+++ b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java
@@ -599,13 +599,11 @@ public class PathPattern implements Comparable {
 
 		private final PathMatchInfo pathMatchInfo;
 
-
 		PathRemainingMatchInfo(PathContainer pathMatched, PathContainer pathRemaining) {
 			this(pathMatched, pathRemaining, PathMatchInfo.EMPTY);
 		}
 
-		PathRemainingMatchInfo(PathContainer pathMatched, PathContainer pathRemaining,
-				PathMatchInfo pathMatchInfo) {
+		PathRemainingMatchInfo(PathContainer pathMatched, PathContainer pathRemaining, PathMatchInfo pathMatchInfo) {
 			this.pathRemaining = pathRemaining;
 			this.pathMatched = pathMatched;
 			this.pathMatchInfo = pathMatchInfo;