Browse Source

Avoid inner assignments

Replace code of the form `a = b =c` with distinct statements. Although
this results in more lines of code, they are usually easier to
understand.

Issue gh-8945
Phillip Webb 5 years ago
parent
commit
418c3d6808

+ 3 - 1
acl/src/main/java/org/springframework/security/acls/domain/AclAuthorizationStrategyImpl.java

@@ -73,7 +73,9 @@ public class AclAuthorizationStrategyImpl implements AclAuthorizationStrategy {
 			this.gaGeneralChanges = auths[2];
 		}
 		else {
-			this.gaTakeOwnership = this.gaModifyAuditing = this.gaGeneralChanges = auths[0];
+			this.gaTakeOwnership = auths[0];
+			this.gaModifyAuditing = auths[0];
+			this.gaGeneralChanges = auths[0];
 		}
 	}
 

+ 4 - 2
core/src/main/java/org/springframework/security/authentication/ProviderManager.java

@@ -202,7 +202,8 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
 		if (result == null && this.parent != null) {
 			// Allow the parent to try.
 			try {
-				result = parentResult = this.parent.authenticate(authentication);
+				parentResult = this.parent.authenticate(authentication);
+				result = parentResult;
 			}
 			catch (ProviderNotFoundException e) {
 				// ignore as we will throw below if no other exception occurred prior to
@@ -211,7 +212,8 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
 				// handled the request
 			}
 			catch (AuthenticationException e) {
-				lastException = parentException = e;
+				parentException = e;
+				lastException = e;
 			}
 		}
 

+ 0 - 1
etc/checkstyle/checkstyle-suppressions.xml

@@ -3,7 +3,6 @@
 		"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
 		"https://checkstyle.org/dtds/suppressions_1_2.dtd">
 <suppressions>
-	<suppress files=".*" checks="InnerAssignment" />
 	<suppress files=".*" checks="InnerTypeLast" />
 	<suppress files=".*" checks="InterfaceIsType" />
 	<suppress files=".*" checks="JavadocMethod" />

+ 2 - 2
oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/userinfo/CustomUserTypesOAuth2UserService.java

@@ -83,8 +83,8 @@ public class CustomUserTypesOAuth2UserService implements OAuth2UserService<OAuth
 	public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {
 		Assert.notNull(userRequest, "userRequest cannot be null");
 		String registrationId = userRequest.getClientRegistration().getRegistrationId();
-		Class<? extends OAuth2User> customUserType;
-		if ((customUserType = this.customUserTypes.get(registrationId)) == null) {
+		Class<? extends OAuth2User> customUserType = this.customUserTypes.get(registrationId);
+		if (customUserType == null) {
 			return null;
 		}
 

+ 2 - 1
remoting/src/main/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocation.java

@@ -68,7 +68,8 @@ public class ContextPropagatingRemoteInvocation extends RemoteInvocation {
 			this.credentials = userCredentials == null ? null : userCredentials.toString();
 		}
 		else {
-			this.principal = this.credentials = null;
+			this.credentials = null;
+			this.principal = null;
 		}
 
 		if (logger.isDebugEnabled()) {