1
0
mirror of synced 2026-08-04 17:27:13 +00:00

Cleanup redundant type casts

This commit is contained in:
Lars Grefer
2019-07-04 19:04:19 +02:00
committed by Rob Winch
parent 43737a56bd
commit c5b5cc507c
31 changed files with 38 additions and 42 deletions
@@ -23,7 +23,7 @@ public final class ExpressionUtils {
public static boolean evaluateAsBoolean(Expression expr, EvaluationContext ctx) {
try {
return ((Boolean) expr.getValue(ctx, Boolean.class)).booleanValue();
return expr.getValue(ctx, Boolean.class).booleanValue();
}
catch (EvaluationException e) {
throw new IllegalArgumentException("Failed to evaluate expression '"
@@ -98,7 +98,7 @@ public class MapBasedMethodSecurityMetadataSource extends
Class<?> clazz) {
RegisteredMethod registeredMethod = new RegisteredMethod(method, clazz);
if (methodMap.containsKey(registeredMethod)) {
return (List<ConfigAttribute>) methodMap.get(registeredMethod);
return methodMap.get(registeredMethod);
}
// Search superclass
if (clazz.getSuperclass() != null) {
@@ -166,7 +166,7 @@ public class MapBasedMethodSecurityMetadataSource extends
// register all matching methods
for (Method method : matchingMethods) {
RegisteredMethod registeredMethod = new RegisteredMethod(method, javaType);
String regMethodName = (String) this.nameMap.get(registeredMethod);
String regMethodName = this.nameMap.get(registeredMethod);
if ((regMethodName == null)
|| (!regMethodName.equals(name) && (regMethodName.length() <= name
@@ -17,7 +17,6 @@
package org.springframework.security.jackson2;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.authentication.BadCredentialsException;
@@ -54,7 +53,7 @@ public class CoreJackson2Module extends SimpleModule {
@Override
public void setupModule(SetupContext context) {
SecurityJackson2Modules.enableDefaultTyping((ObjectMapper) context.getOwner());
SecurityJackson2Modules.enableDefaultTyping(context.getOwner());
context.setMixInAnnotations(AnonymousAuthenticationToken.class, AnonymousAuthenticationTokenMixin.class);
context.setMixInAnnotations(RememberMeAuthenticationToken.class, RememberMeAuthenticationTokenMixin.class);
context.setMixInAnnotations(SimpleGrantedAuthority.class, SimpleGrantedAuthorityMixin.class);
@@ -58,7 +58,7 @@ public class AnonymousAuthenticationTokenTests {
try {
new AnonymousAuthenticationToken("key", "Test",
(List<GrantedAuthority>) null);
null);
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException expected) {
@@ -21,7 +21,6 @@ package org.springframework.security.authentication.dao;
import java.util.HashMap;
import java.util.Map;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserCache;
import org.springframework.security.core.userdetails.UserDetails;
@@ -29,7 +28,7 @@ public class MockUserCache implements UserCache {
private Map<String, UserDetails> cache = new HashMap<>();
public UserDetails getUserFromCache(String username) {
return (User) cache.get(username);
return cache.get(username);
}
public void putUserInCache(UserDetails user) {
@@ -62,7 +62,7 @@ public abstract class AbstractDelegatingSecurityContextScheduledExecutorServiceT
@Test
public void scheduleCallable() {
when(
(ScheduledFuture<Object>) delegate.schedule(wrappedCallable, 1,
delegate.schedule(wrappedCallable, 1,
TimeUnit.SECONDS)).thenReturn(expectedResult);
ScheduledFuture<Object> result = executor.schedule(callable, 1, TimeUnit.SECONDS);
assertThat(result).isEqualTo(expectedResult);
@@ -40,7 +40,7 @@ public class KeyBasedPersistenceTokenServiceTests {
service.setServerSecret("MY:SECRET$$$#");
service.setServerInteger(Integer.valueOf(454545));
try {
SecureRandom rnd = (SecureRandom) fb.getObject();
SecureRandom rnd = fb.getObject();
service.setSecureRandom(rnd);
service.afterPropertiesSet();
}
@@ -406,7 +406,7 @@ public class JdbcUserDetailsManagerTests {
private Map<String, UserDetails> cache = new HashMap<>();
public UserDetails getUserFromCache(String username) {
return (User) cache.get(username);
return cache.get(username);
}
public void putUserInCache(UserDetails user) {