Use diamond type
This commit is contained in:
@@ -42,7 +42,7 @@ public final class DefaultSecurityFilterChain implements SecurityFilterChain {
|
||||
public DefaultSecurityFilterChain(RequestMatcher requestMatcher, List<Filter> filters) {
|
||||
logger.info("Creating filter chain: " + requestMatcher + ", " + filters);
|
||||
this.requestMatcher = requestMatcher;
|
||||
this.filters = new ArrayList<Filter>(filters);
|
||||
this.filters = new ArrayList<>(filters);
|
||||
}
|
||||
|
||||
public RequestMatcher getRequestMatcher() {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PortMapperImpl implements PortMapper {
|
||||
// ===================================================================================================
|
||||
|
||||
public PortMapperImpl() {
|
||||
this.httpsPortMappings = new HashMap<Integer, Integer>();
|
||||
this.httpsPortMappings = new HashMap<>();
|
||||
this.httpsPortMappings.put(Integer.valueOf(80), Integer.valueOf(443));
|
||||
this.httpsPortMappings.put(Integer.valueOf(8080), Integer.valueOf(8443));
|
||||
}
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ public class ChannelDecisionManagerImpl implements ChannelDecisionManager,
|
||||
@SuppressWarnings("cast")
|
||||
public void setChannelProcessors(List<?> newList) {
|
||||
Assert.notEmpty(newList, "A list of ChannelProcessors is required");
|
||||
channelProcessors = new ArrayList<ChannelProcessor>(newList.size());
|
||||
channelProcessors = new ArrayList<>(newList.size());
|
||||
|
||||
for (Object currentObject : newList) {
|
||||
Assert.isInstanceOf(ChannelProcessor.class, currentObject,
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ public class ChannelProcessingFilter extends GenericFilterBean {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<ConfigAttribute> unsupportedAttributes = new HashSet<ConfigAttribute>();
|
||||
Set<ConfigAttribute> unsupportedAttributes = new HashSet<>();
|
||||
|
||||
for (ConfigAttribute attr : attrDefs) {
|
||||
if (!this.channelDecisionManager.supports(attr)) {
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public final class ExpressionBasedFilterInvocationSecurityMetadataSource
|
||||
RequestMatcher request = entry.getKey();
|
||||
Assert.isTrue(entry.getValue().size() == 1,
|
||||
"Expected a single expression attribute for " + request);
|
||||
ArrayList<ConfigAttribute> attributes = new ArrayList<ConfigAttribute>(1);
|
||||
ArrayList<ConfigAttribute> attributes = new ArrayList<>(1);
|
||||
String expression = entry.getValue().toArray(new ConfigAttribute[1])[0]
|
||||
.getAttribute();
|
||||
logger.debug("Adding web access control expression '" + expression + "', for "
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public class DefaultFilterInvocationSecurityMetadataSource implements
|
||||
// ========================================================================================================
|
||||
|
||||
public Collection<ConfigAttribute> getAllConfigAttributes() {
|
||||
Set<ConfigAttribute> allAttributes = new HashSet<ConfigAttribute>();
|
||||
Set<ConfigAttribute> allAttributes = new HashSet<>();
|
||||
|
||||
for (Map.Entry<RequestMatcher, Collection<ConfigAttribute>> entry : requestMap
|
||||
.entrySet()) {
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ExceptionMappingAuthenticationFailureHandler extends
|
||||
SimpleUrlAuthenticationFailureHandler {
|
||||
private final Map<String, String> failureUrlMap = new HashMap<String, String>();
|
||||
private final Map<String, String> failureUrlMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailure(HttpServletRequest request,
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails extends
|
||||
HttpServletRequest request, Collection<? extends GrantedAuthority> authorities) {
|
||||
super(request);
|
||||
|
||||
List<GrantedAuthority> temp = new ArrayList<GrantedAuthority>(authorities.size());
|
||||
List<GrantedAuthority> temp = new ArrayList<>(authorities.size());
|
||||
temp.addAll(authorities);
|
||||
this.authorities = Collections.unmodifiableList(temp);
|
||||
}
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource
|
||||
* making the request.
|
||||
*/
|
||||
protected Collection<String> getUserRoles(HttpServletRequest request) {
|
||||
ArrayList<String> j2eeUserRolesList = new ArrayList<String>();
|
||||
ArrayList<String> j2eeUserRolesList = new ArrayList<>();
|
||||
|
||||
for (String role : j2eeMappableRoles) {
|
||||
if (request.isUserInRole(role)) {
|
||||
|
||||
+2
-2
@@ -82,7 +82,7 @@ public class WebXmlMappableAttributesRetriever implements ResourceLoaderAware,
|
||||
NodeList securityRoles = ((Element) webApp.item(0))
|
||||
.getElementsByTagName("security-role");
|
||||
|
||||
ArrayList<String> roleNames = new ArrayList<String>();
|
||||
ArrayList<String> roleNames = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < securityRoles.getLength(); i++) {
|
||||
Element secRoleElt = (Element) securityRoles.item(i);
|
||||
@@ -98,7 +98,7 @@ public class WebXmlMappableAttributesRetriever implements ResourceLoaderAware,
|
||||
}
|
||||
}
|
||||
|
||||
mappableAttributes = Collections.unmodifiableSet(new HashSet<String>(roleNames));
|
||||
mappableAttributes = Collections.unmodifiableSet(new HashSet<>(roleNames));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import java.util.Map;
|
||||
* @author Luke Taylor
|
||||
*/
|
||||
public class InMemoryTokenRepositoryImpl implements PersistentTokenRepository {
|
||||
private final Map<String, PersistentRememberMeToken> seriesTokens = new HashMap<String, PersistentRememberMeToken>();
|
||||
private final Map<String, PersistentRememberMeToken> seriesTokens = new HashMap<>();
|
||||
|
||||
public synchronized void createNewToken(PersistentRememberMeToken token) {
|
||||
PersistentRememberMeToken current = seriesTokens.get(token.getSeries());
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ public class SessionFixationProtectionStrategy extends
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private HashMap<String, Object> createMigratedAttributeMap(HttpSession session) {
|
||||
HashMap<String, Object> attributesToMigrate = new HashMap<String, Object>();
|
||||
HashMap<String, Object> attributesToMigrate = new HashMap<>();
|
||||
|
||||
Enumeration enumer = session.getAttributeNames();
|
||||
|
||||
|
||||
+1
-1
@@ -335,7 +335,7 @@ public class SwitchUserFilter extends GenericFilterBean
|
||||
}
|
||||
|
||||
// add the new switch user authority
|
||||
List<GrantedAuthority> newAuths = new ArrayList<GrantedAuthority>(orig);
|
||||
List<GrantedAuthority> newAuths = new ArrayList<>(orig);
|
||||
newAuths.add(switchAuthority);
|
||||
|
||||
// create the new authentication token
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ final class DigestAuthUtils {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
int i = 0;
|
||||
int start = 0;
|
||||
boolean match = false;
|
||||
@@ -158,7 +158,7 @@ final class DigestAuthUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
for (String s : array) {
|
||||
String postRemove;
|
||||
|
||||
@@ -160,7 +160,7 @@ public final class CsrfFilter extends OncePerRequestFilter {
|
||||
}
|
||||
|
||||
private static final class DefaultRequiresCsrfMatcher implements RequestMatcher {
|
||||
private final HashSet<String> allowedMethods = new HashSet<String>(
|
||||
private final HashSet<String> allowedMethods = new HashSet<>(
|
||||
Arrays.asList("GET", "HEAD", "TRACE", "OPTIONS"));
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public final class CacheControlHeadersWriter implements HeaderWriter {
|
||||
}
|
||||
|
||||
private static List<Header> createHeaders() {
|
||||
List<Header> headers = new ArrayList<Header>(2);
|
||||
List<Header> headers = new ArrayList<>(2);
|
||||
headers.add(new Header(CACHE_CONTROL,
|
||||
"no-cache, no-store, max-age=0, must-revalidate"));
|
||||
headers.add(new Header(PRAGMA, "no-cache"));
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ public final class HpkpHeaderWriter implements HeaderWriter {
|
||||
|
||||
private final RequestMatcher requestMatcher = new SecureRequestMatcher();
|
||||
|
||||
private Map<String, String> pins = new LinkedHashMap<String, String>();
|
||||
private Map<String, String> pins = new LinkedHashMap<>();
|
||||
|
||||
private long maxAgeInSeconds;
|
||||
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public class ReferrerPolicyHeaderWriter implements HeaderWriter {
|
||||
private static final Map<String, ReferrerPolicy> REFERRER_POLICIES;
|
||||
|
||||
static {
|
||||
Map<String, ReferrerPolicy> referrerPolicies = new HashMap<String, ReferrerPolicy>();
|
||||
Map<String, ReferrerPolicy> referrerPolicies = new HashMap<>();
|
||||
for (ReferrerPolicy referrerPolicy : values()) {
|
||||
referrerPolicies.put(referrerPolicy.getPolicy(), referrerPolicy);
|
||||
}
|
||||
|
||||
+7
-7
@@ -62,11 +62,11 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final ArrayList<SavedCookie> cookies = new ArrayList<SavedCookie>();
|
||||
private final ArrayList<Locale> locales = new ArrayList<Locale>();
|
||||
private final Map<String, List<String>> headers = new TreeMap<String, List<String>>(
|
||||
private final ArrayList<SavedCookie> cookies = new ArrayList<>();
|
||||
private final ArrayList<Locale> locales = new ArrayList<>();
|
||||
private final Map<String, List<String>> headers = new TreeMap<>(
|
||||
String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<String, String[]> parameters = new TreeMap<String, String[]>();
|
||||
private final Map<String, String[]> parameters = new TreeMap<>();
|
||||
private final String contextPath;
|
||||
private final String method;
|
||||
private final String pathInfo;
|
||||
@@ -163,7 +163,7 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
List<String> values = headers.get(name);
|
||||
|
||||
if (values == null) {
|
||||
values = new ArrayList<String>();
|
||||
values = new ArrayList<>();
|
||||
headers.put(name, values);
|
||||
}
|
||||
|
||||
@@ -407,8 +407,8 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
|
||||
private List<SavedCookie> cookies = null;
|
||||
private List<Locale> locales = null;
|
||||
private Map<String, List<String>> headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
|
||||
private Map<String, String[]> parameters = new TreeMap<String, String[]>();
|
||||
private Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
private Map<String, String[]> parameters = new TreeMap<>();
|
||||
private String contextPath;
|
||||
private String method;
|
||||
private String pathInfo;
|
||||
|
||||
@@ -92,7 +92,7 @@ public class Enumerator<T> implements Enumeration<T> {
|
||||
this.iterator = iterator;
|
||||
}
|
||||
else {
|
||||
List<T> list = new ArrayList<T>();
|
||||
List<T> list = new ArrayList<>();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
list.add(iterator.next());
|
||||
|
||||
+2
-2
@@ -65,10 +65,10 @@ public class FastHttpDateFormat {
|
||||
protected static String currentDate = null;
|
||||
|
||||
/** Formatter cache. */
|
||||
protected static final HashMap<Long, String> formatCache = new HashMap<Long, String>();
|
||||
protected static final HashMap<Long, String> formatCache = new HashMap<>();
|
||||
|
||||
/** Parser cache. */
|
||||
protected static final HashMap<String, Long> parseCache = new HashMap<String, Long>();
|
||||
protected static final HashMap<String, Long> parseCache = new HashMap<>();
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
+7
-7
@@ -121,13 +121,13 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration getHeaderNames() {
|
||||
return new Enumerator<String>(savedRequest.getHeaderNames());
|
||||
return new Enumerator<>(savedRequest.getHeaderNames());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration getHeaders(String name) {
|
||||
return new Enumerator<String>(savedRequest.getHeaderValues(name));
|
||||
return new Enumerator<>(savedRequest.getHeaderValues(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,11 +156,11 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
if (locales.isEmpty()) {
|
||||
// Fall back to default locale
|
||||
locales = new ArrayList<Locale>(1);
|
||||
locales = new ArrayList<>(1);
|
||||
locales.add(Locale.getDefault());
|
||||
}
|
||||
|
||||
return new Enumerator<Locale>(locales);
|
||||
return new Enumerator<>(locales);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,7 +199,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map getParameterMap() {
|
||||
Set<String> names = getCombinedParameterNames();
|
||||
Map<String, String[]> parameterMap = new HashMap<String, String[]>(names.size());
|
||||
Map<String, String[]> parameterMap = new HashMap<>(names.size());
|
||||
|
||||
for (String name : names) {
|
||||
parameterMap.put(name, getParameterValues(name));
|
||||
@@ -210,7 +210,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Set<String> getCombinedParameterNames() {
|
||||
Set<String> names = new HashSet<String>();
|
||||
Set<String> names = new HashSet<>();
|
||||
names.addAll(super.getParameterMap().keySet());
|
||||
names.addAll(savedRequest.getParameterMap().keySet());
|
||||
|
||||
@@ -238,7 +238,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
// We have parameters in both saved and wrapped requests so have to merge them
|
||||
List<String> wrappedParamsList = Arrays.asList(wrappedRequestParams);
|
||||
List<String> combinedParams = new ArrayList<String>(wrappedParamsList);
|
||||
List<String> combinedParams = new ArrayList<>(wrappedParamsList);
|
||||
|
||||
// We want to add all parameters of the saved request *apart from* duplicates of
|
||||
// those already added
|
||||
|
||||
+2
-2
@@ -67,7 +67,7 @@ public final class CsrfRequestDataValueProcessor implements RequestDataValueProc
|
||||
if (token == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, String> hiddenFields = new HashMap<String, String>(1);
|
||||
Map<String, String> hiddenFields = new HashMap<>(1);
|
||||
hiddenFields.put(token.getParameterName(), token.getToken());
|
||||
return hiddenFields;
|
||||
}
|
||||
@@ -75,4 +75,4 @@ public final class CsrfRequestDataValueProcessor implements RequestDataValueProc
|
||||
public String processUrl(HttpServletRequest request, String url) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public class HttpSessionDestroyedEvent extends SessionDestroyedEvent {
|
||||
|
||||
Enumeration<String> attributes = session.getAttributeNames();
|
||||
|
||||
ArrayList<SecurityContext> contexts = new ArrayList<SecurityContext>();
|
||||
ArrayList<SecurityContext> contexts = new ArrayList<>();
|
||||
|
||||
while (attributes.hasMoreElements()) {
|
||||
String attributeName = attributes.nextElement();
|
||||
|
||||
@@ -174,7 +174,7 @@ public class ThrowableAnalyzer {
|
||||
throw new IllegalArgumentException("Invalid throwable: null");
|
||||
}
|
||||
|
||||
List<Throwable> chain = new ArrayList<Throwable>();
|
||||
List<Throwable> chain = new ArrayList<>();
|
||||
Throwable currentThrowable = throwable;
|
||||
|
||||
while (currentThrowable != null) {
|
||||
|
||||
Reference in New Issue
Block a user