diff --git a/docs/src/test/java/docs/IndexDocTests.java b/docs/src/test/java/docs/IndexDocTests.java index af2b8743..836ff150 100644 --- a/docs/src/test/java/docs/IndexDocTests.java +++ b/docs/src/test/java/docs/IndexDocTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -49,7 +49,7 @@ public class IndexDocTests { @Test public void repositoryDemo() { - RepositoryDemo demo = new RepositoryDemo(); + RepositoryDemo demo = new RepositoryDemo<>(); demo.repository = new MapSessionRepository(); demo.demo(); @@ -81,7 +81,7 @@ public class IndexDocTests { @Test public void expireRepositoryDemo() { - ExpiringRepositoryDemo demo = new ExpiringRepositoryDemo(); + ExpiringRepositoryDemo demo = new ExpiringRepositoryDemo<>(); demo.repository = new MapSessionRepository(); demo.demo(); diff --git a/samples/boot/redis-json/src/integration-test/java/sample/pages/HomePage.java b/samples/boot/redis-json/src/integration-test/java/sample/pages/HomePage.java index daeb6d1b..ad2b7295 100644 --- a/samples/boot/redis-json/src/integration-test/java/sample/pages/HomePage.java +++ b/samples/boot/redis-json/src/integration-test/java/sample/pages/HomePage.java @@ -49,7 +49,7 @@ public class HomePage { public HomePage(WebDriver driver) { this.driver = driver; - this.attributes = new ArrayList(); + this.attributes = new ArrayList<>(); } private static void get(WebDriver driver, String get) { @@ -80,7 +80,7 @@ public class HomePage { } public List attributes() { - List rows = new ArrayList(); + List rows = new ArrayList<>(); for (WebElement tr : this.trs) { rows.add(new Attribute(tr)); } diff --git a/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java b/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java index 356216a9..6e0eeafe 100644 --- a/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java +++ b/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -38,13 +38,13 @@ public class WebSocketHandlersConfig { public WebSocketConnectHandler webSocketConnectHandler( SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository repository) { - return new WebSocketConnectHandler(messagingTemplate, repository); + return new WebSocketConnectHandler<>(messagingTemplate, repository); } @Bean public WebSocketDisconnectHandler webSocketDisconnectHandler( SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository repository) { - return new WebSocketDisconnectHandler(messagingTemplate, repository); + return new WebSocketDisconnectHandler<>(messagingTemplate, repository); } } diff --git a/samples/boot/websocket/src/test/java/sample/ApplicationTests.java b/samples/boot/websocket/src/test/java/sample/ApplicationTests.java index c71bd480..a5b9d5b5 100644 --- a/samples/boot/websocket/src/test/java/sample/ApplicationTests.java +++ b/samples/boot/websocket/src/test/java/sample/ApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -56,7 +56,7 @@ public class ApplicationTests { @Test public void run() throws Exception { - List transports = new ArrayList(2); + List transports = new ArrayList<>(2); transports.add(new WebSocketTransport(new StandardWebSocketClient())); transports.add(new RestTemplateXhrTransport()); diff --git a/samples/javaconfig/custom-cookie/src/integration-test/java/sample/pages/HomePage.java b/samples/javaconfig/custom-cookie/src/integration-test/java/sample/pages/HomePage.java index e9e0134f..f15543f8 100644 --- a/samples/javaconfig/custom-cookie/src/integration-test/java/sample/pages/HomePage.java +++ b/samples/javaconfig/custom-cookie/src/integration-test/java/sample/pages/HomePage.java @@ -46,7 +46,7 @@ public class HomePage { public HomePage(WebDriver driver) { this.driver = driver; - this.attributes = new ArrayList(); + this.attributes = new ArrayList<>(); } private static void get(WebDriver driver, String get) { @@ -64,7 +64,7 @@ public class HomePage { } public List attributes() { - List rows = new ArrayList(); + List rows = new ArrayList<>(); for (WebElement tr : this.trs) { rows.add(new Attribute(tr)); } diff --git a/samples/javaconfig/jdbc/src/integration-test/java/sample/pages/HomePage.java b/samples/javaconfig/jdbc/src/integration-test/java/sample/pages/HomePage.java index e9e0134f..f15543f8 100644 --- a/samples/javaconfig/jdbc/src/integration-test/java/sample/pages/HomePage.java +++ b/samples/javaconfig/jdbc/src/integration-test/java/sample/pages/HomePage.java @@ -46,7 +46,7 @@ public class HomePage { public HomePage(WebDriver driver) { this.driver = driver; - this.attributes = new ArrayList(); + this.attributes = new ArrayList<>(); } private static void get(WebDriver driver, String get) { @@ -64,7 +64,7 @@ public class HomePage { } public List attributes() { - List rows = new ArrayList(); + List rows = new ArrayList<>(); for (WebElement tr : this.trs) { rows.add(new Attribute(tr)); } diff --git a/samples/javaconfig/redis/src/integration-test/java/sample/pages/HomePage.java b/samples/javaconfig/redis/src/integration-test/java/sample/pages/HomePage.java index e9e0134f..f15543f8 100644 --- a/samples/javaconfig/redis/src/integration-test/java/sample/pages/HomePage.java +++ b/samples/javaconfig/redis/src/integration-test/java/sample/pages/HomePage.java @@ -46,7 +46,7 @@ public class HomePage { public HomePage(WebDriver driver) { this.driver = driver; - this.attributes = new ArrayList(); + this.attributes = new ArrayList<>(); } private static void get(WebDriver driver, String get) { @@ -64,7 +64,7 @@ public class HomePage { } public List attributes() { - List rows = new ArrayList(); + List rows = new ArrayList<>(); for (WebElement tr : this.trs) { rows.add(new Attribute(tr)); } diff --git a/samples/javaconfig/rest/src/main/java/sample/mvc/RestDemoController.java b/samples/javaconfig/rest/src/main/java/sample/mvc/RestDemoController.java index 58e2a502..8833a378 100644 --- a/samples/javaconfig/rest/src/main/java/sample/mvc/RestDemoController.java +++ b/samples/javaconfig/rest/src/main/java/sample/mvc/RestDemoController.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -35,7 +35,7 @@ public class RestDemoController { @RequestMapping(value = "/", produces = "application/json") public Map helloUser(Principal principal) { - HashMap result = new HashMap(); + HashMap result = new HashMap<>(); result.put("username", principal.getName()); return result; } diff --git a/samples/javaconfig/users/src/main/java/sample/UserAccountsFilter.java b/samples/javaconfig/users/src/main/java/sample/UserAccountsFilter.java index 7e499056..1e8daefe 100644 --- a/samples/javaconfig/users/src/main/java/sample/UserAccountsFilter.java +++ b/samples/javaconfig/users/src/main/java/sample/UserAccountsFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -55,7 +55,7 @@ public class UserAccountsFilter implements Filter { String unauthenticatedAlias = null; String contextPath = httpRequest.getContextPath(); - List accounts = new ArrayList(); + List accounts = new ArrayList<>(); Account currentAccount = null; for (Map.Entry entry : sessionIds.entrySet()) { String alias = entry.getKey(); diff --git a/samples/misc/hazelcast/src/integration-test/java/sample/pages/HomePage.java b/samples/misc/hazelcast/src/integration-test/java/sample/pages/HomePage.java index e9e0134f..f15543f8 100644 --- a/samples/misc/hazelcast/src/integration-test/java/sample/pages/HomePage.java +++ b/samples/misc/hazelcast/src/integration-test/java/sample/pages/HomePage.java @@ -46,7 +46,7 @@ public class HomePage { public HomePage(WebDriver driver) { this.driver = driver; - this.attributes = new ArrayList(); + this.attributes = new ArrayList<>(); } private static void get(WebDriver driver, String get) { @@ -64,7 +64,7 @@ public class HomePage { } public List attributes() { - List rows = new ArrayList(); + List rows = new ArrayList<>(); for (WebElement tr : this.trs) { rows.add(new Attribute(tr)); } diff --git a/samples/misc/hazelcast/src/main/java/sample/Initializer.java b/samples/misc/hazelcast/src/main/java/sample/Initializer.java index ee0258a6..d52d813a 100644 --- a/samples/misc/hazelcast/src/main/java/sample/Initializer.java +++ b/samples/misc/hazelcast/src/main/java/sample/Initializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -66,7 +66,7 @@ public class Initializer implements ServletContextListener { SessionRepository sessionRepository = new MapSessionRepository( sessions); - SessionRepositoryFilter filter = new SessionRepositoryFilter( + SessionRepositoryFilter filter = new SessionRepositoryFilter<>( sessionRepository); Dynamic fr = sc.addFilter("springSessionFilter", filter); fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); diff --git a/samples/xml/jdbc/src/integration-test/java/sample/pages/HomePage.java b/samples/xml/jdbc/src/integration-test/java/sample/pages/HomePage.java index e9e0134f..f15543f8 100644 --- a/samples/xml/jdbc/src/integration-test/java/sample/pages/HomePage.java +++ b/samples/xml/jdbc/src/integration-test/java/sample/pages/HomePage.java @@ -46,7 +46,7 @@ public class HomePage { public HomePage(WebDriver driver) { this.driver = driver; - this.attributes = new ArrayList(); + this.attributes = new ArrayList<>(); } private static void get(WebDriver driver, String get) { @@ -64,7 +64,7 @@ public class HomePage { } public List attributes() { - List rows = new ArrayList(); + List rows = new ArrayList<>(); for (WebElement tr : this.trs) { rows.add(new Attribute(tr)); } diff --git a/samples/xml/redis/src/integration-test/java/sample/pages/HomePage.java b/samples/xml/redis/src/integration-test/java/sample/pages/HomePage.java index 92b9062a..fbfa041c 100644 --- a/samples/xml/redis/src/integration-test/java/sample/pages/HomePage.java +++ b/samples/xml/redis/src/integration-test/java/sample/pages/HomePage.java @@ -46,7 +46,7 @@ public class HomePage { public HomePage(WebDriver driver) { this.driver = driver; - this.attributes = new ArrayList(); + this.attributes = new ArrayList<>(); } private static void get(WebDriver driver, String get) { @@ -64,7 +64,7 @@ public class HomePage { } public List attributes() { - List rows = new ArrayList(); + List rows = new ArrayList<>(); for (WebElement tr : this.trs) { rows.add(new Attribute(tr)); } diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/SessionEventRegistry.java b/spring-session/src/integration-test/java/org/springframework/session/data/SessionEventRegistry.java index fb742a70..c9c8c2b0 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/SessionEventRegistry.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/SessionEventRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -23,8 +23,8 @@ import org.springframework.context.ApplicationListener; import org.springframework.session.events.AbstractSessionEvent; public class SessionEventRegistry implements ApplicationListener { - private Map events = new HashMap(); - private Map locks = new HashMap(); + private Map events = new HashMap<>(); + private Map locks = new HashMap<>(); public void onApplicationEvent(AbstractSessionEvent event) { String sessionId = event.getSessionId(); diff --git a/spring-session/src/main/java/org/springframework/session/MapSession.java b/spring-session/src/main/java/org/springframework/session/MapSession.java index 531772f5..16278b0d 100644 --- a/spring-session/src/main/java/org/springframework/session/MapSession.java +++ b/spring-session/src/main/java/org/springframework/session/MapSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -50,7 +50,7 @@ public final class MapSession implements ExpiringSession, Serializable { public static final int DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS = 1800; private String id; - private Map sessionAttrs = new HashMap(); + private Map sessionAttrs = new HashMap<>(); private long creationTime = System.currentTimeMillis(); private long lastAccessedTime = this.creationTime; @@ -88,7 +88,7 @@ public final class MapSession implements ExpiringSession, Serializable { throw new IllegalArgumentException("session cannot be null"); } this.id = session.getId(); - this.sessionAttrs = new HashMap( + this.sessionAttrs = new HashMap<>( session.getAttributeNames().size()); for (String attrName : session.getAttributeNames()) { Object attrValue = session.getAttribute(attrName); diff --git a/spring-session/src/main/java/org/springframework/session/MapSessionRepository.java b/spring-session/src/main/java/org/springframework/session/MapSessionRepository.java index 1b1327c3..3dfa3367 100644 --- a/spring-session/src/main/java/org/springframework/session/MapSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/MapSessionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -49,7 +49,7 @@ public class MapSessionRepository implements SessionRepository * Creates an instance backed by a {@link java.util.concurrent.ConcurrentHashMap}. */ public MapSessionRepository() { - this(new ConcurrentHashMap()); + this(new ConcurrentHashMap<>()); } /** diff --git a/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java b/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java index 67efa27f..a71c512e 100644 --- a/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java +++ b/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -101,7 +101,7 @@ public class SpringHttpSessionConfiguration implements ApplicationContextAware { private HttpSessionStrategy httpSessionStrategy = this.defaultHttpSessionStrategy; - private List httpSessionListeners = new ArrayList(); + private List httpSessionListeners = new ArrayList<>(); @PostConstruct public void init() { @@ -124,7 +124,7 @@ public class SpringHttpSessionConfiguration implements ApplicationContextAware { @Bean public SessionRepositoryFilter springSessionRepositoryFilter( SessionRepository sessionRepository) { - SessionRepositoryFilter sessionRepositoryFilter = new SessionRepositoryFilter( + SessionRepositoryFilter sessionRepositoryFilter = new SessionRepositoryFilter<>( sessionRepository); sessionRepositoryFilter.setServletContext(this.servletContext); if (this.httpSessionStrategy instanceof MultiHttpSessionStrategy) { diff --git a/spring-session/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java b/spring-session/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java index e3720fdf..9777fc03 100644 --- a/spring-session/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -410,7 +410,7 @@ public class RedisOperationsSessionRepository implements String principalKey = getPrincipalKey(indexValue); Set sessionIds = this.sessionRedisOperations.boundSetOps(principalKey) .members(); - Map sessions = new HashMap( + Map sessions = new HashMap<>( sessionIds.size()); for (Object id : sessionIds) { RedisSession session = getSession((String) id); @@ -650,7 +650,7 @@ public class RedisOperationsSessionRepository implements private static RedisTemplate createDefaultTemplate( RedisConnectionFactory connectionFactory) { Assert.notNull(connectionFactory, "connectionFactory cannot be null"); - RedisTemplate template = new RedisTemplate(); + RedisTemplate template = new RedisTemplate<>(); template.setKeySerializer(new StringRedisSerializer()); template.setHashKeySerializer(new StringRedisSerializer()); template.setConnectionFactory(connectionFactory); @@ -670,7 +670,7 @@ public class RedisOperationsSessionRepository implements final class RedisSession implements ExpiringSession { private final MapSession cached; private Long originalLastAccessTime; - private Map delta = new HashMap(); + private Map delta = new HashMap<>(); private boolean isNew; private String originalPrincipalName; @@ -797,7 +797,7 @@ public class RedisOperationsSessionRepository implements } } - this.delta = new HashMap(this.delta.size()); + this.delta = new HashMap<>(this.delta.size()); Long originalExpiration = this.originalLastAccessTime == null ? null : this.originalLastAccessTime + TimeUnit.SECONDS diff --git a/spring-session/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.java b/spring-session/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.java index 14e8db90..c9e8e408 100644 --- a/spring-session/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.java +++ b/spring-session/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -107,7 +107,7 @@ public class RedisHttpSessionConfiguration extends SpringHttpSessionConfiguratio @Bean public RedisTemplate sessionRedisTemplate( RedisConnectionFactory connectionFactory) { - RedisTemplate template = new RedisTemplate(); + RedisTemplate template = new RedisTemplate<>(); template.setKeySerializer(new StringRedisSerializer()); template.setHashKeySerializer(new StringRedisSerializer()); if (this.defaultRedisSerializer != null) { diff --git a/spring-session/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java b/spring-session/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java index 2c551798..861e74b0 100644 --- a/spring-session/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -230,7 +230,7 @@ public class HazelcastSessionRepository implements } Collection sessions = this.sessions.values( Predicates.equal(PRINCIPAL_NAME_ATTRIBUTE, indexValue)); - Map sessionMap = new HashMap( + Map sessionMap = new HashMap<>( sessions.size()); for (MapSession session : sessions) { sessionMap.put(session.getId(), new HazelcastSession(session)); diff --git a/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java b/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java index 28b2e8b9..0b5e4918 100644 --- a/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -391,7 +391,7 @@ public class JdbcOperationsSessionRepository implements }); if (!session.getAttributeNames().isEmpty()) { - final List attributeNames = new ArrayList(session.getAttributeNames()); + final List attributeNames = new ArrayList<>(session.getAttributeNames()); JdbcOperationsSessionRepository.this.jdbcOperations.batchUpdate( JdbcOperationsSessionRepository.this.createSessionAttributeQuery, new BatchPreparedStatementSetter() { @@ -551,7 +551,7 @@ public class JdbcOperationsSessionRepository implements }); - Map sessionMap = new HashMap( + Map sessionMap = new HashMap<>( sessions.size()); for (ExpiringSession session : sessions) { @@ -650,7 +650,7 @@ public class JdbcOperationsSessionRepository implements private boolean changed; - private Map delta = new HashMap(); + private Map delta = new HashMap<>(); JdbcSession() { this.delegate = new MapSession(); @@ -767,7 +767,7 @@ public class JdbcOperationsSessionRepository implements implements ResultSetExtractor> { public List extractData(ResultSet rs) throws SQLException, DataAccessException { - List sessions = new ArrayList(); + List sessions = new ArrayList<>(); while (rs.next()) { String id = rs.getString("SESSION_ID"); MapSession session; diff --git a/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionRegistry.java b/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionRegistry.java index 8f70e648..392c2b2d 100644 --- a/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionRegistry.java +++ b/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -17,7 +17,6 @@ package org.springframework.session.security; import java.security.Principal; - import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -25,10 +24,8 @@ import java.util.List; import org.springframework.security.core.session.SessionInformation; import org.springframework.security.core.session.SessionRegistry; import org.springframework.security.core.userdetails.UserDetails; - import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; - import org.springframework.util.Assert; /** @@ -60,7 +57,7 @@ public class SpringSessionBackedSessionRegistry implements SessionRegistry { public List getAllSessions(Object principal, boolean includeExpiredSessions) { Collection sessions = this.sessionRepository.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, name(principal)).values(); - List infos = new ArrayList(); + List infos = new ArrayList<>(); for (ExpiringSession session : sessions) { if (includeExpiredSessions || !Boolean.TRUE.equals(session.getAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR))) { infos.add(new SpringSessionBackedSessionInformation(session, this.sessionRepository)); diff --git a/spring-session/src/main/java/org/springframework/session/web/http/CookieHttpSessionStrategy.java b/spring-session/src/main/java/org/springframework/session/web/http/CookieHttpSessionStrategy.java index 02b8c1fa..b3a57b36 100644 --- a/spring-session/src/main/java/org/springframework/session/web/http/CookieHttpSessionStrategy.java +++ b/spring-session/src/main/java/org/springframework/session/web/http/CookieHttpSessionStrategy.java @@ -237,7 +237,7 @@ public final class CookieHttpSessionStrategy Set sessionsWritten = (Set) request .getAttribute(SESSION_IDS_WRITTEN_ATTR); if (sessionsWritten == null) { - sessionsWritten = new HashSet(); + sessionsWritten = new HashSet<>(); request.setAttribute(SESSION_IDS_WRITTEN_ATTR, sessionsWritten); } return sessionsWritten; @@ -326,7 +326,7 @@ public final class CookieHttpSessionStrategy List cookieValues = this.cookieSerializer.readCookieValues(request); String sessionCookieValue = cookieValues.isEmpty() ? "" : cookieValues.iterator().next(); - Map result = new LinkedHashMap(); + Map result = new LinkedHashMap<>(); StringTokenizer tokens = new StringTokenizer(sessionCookieValue, this.deserializationDelimiter); if (tokens.countTokens() == 1) { diff --git a/spring-session/src/main/java/org/springframework/session/web/http/DefaultCookieSerializer.java b/spring-session/src/main/java/org/springframework/session/web/http/DefaultCookieSerializer.java index b2c0abc1..e8764c83 100644 --- a/spring-session/src/main/java/org/springframework/session/web/http/DefaultCookieSerializer.java +++ b/spring-session/src/main/java/org/springframework/session/web/http/DefaultCookieSerializer.java @@ -65,7 +65,7 @@ public class DefaultCookieSerializer implements CookieSerializer { */ public List readCookieValues(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); - List matchingCookieValues = new ArrayList(); + List matchingCookieValues = new ArrayList<>(); if (cookies != null) { for (Cookie cookie : cookies) { if (this.cookieName.equals(cookie.getName())) { diff --git a/spring-session/src/main/java/org/springframework/session/web/http/SessionEventHttpSessionListenerAdapter.java b/spring-session/src/main/java/org/springframework/session/web/http/SessionEventHttpSessionListenerAdapter.java index bda6c8dd..f3462f12 100644 --- a/spring-session/src/main/java/org/springframework/session/web/http/SessionEventHttpSessionListenerAdapter.java +++ b/spring-session/src/main/java/org/springframework/session/web/http/SessionEventHttpSessionListenerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -74,7 +74,7 @@ public class SessionEventHttpSessionListenerAdapter private HttpSessionEvent createHttpSessionEvent(AbstractSessionEvent event) { ExpiringSession session = event.getSession(); - HttpSession httpSession = new ExpiringSessionHttpSession(session, + HttpSession httpSession = new ExpiringSessionHttpSession<>(session, this.context); HttpSessionEvent httpSessionEvent = new HttpSessionEvent(httpSession); return httpSessionEvent; diff --git a/spring-session/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java b/spring-session/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java index 180a9283..6643a1fc 100644 --- a/spring-session/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java +++ b/spring-session/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -275,7 +275,7 @@ public class SessionRepositoryFilter } // eagerly get session attributes in case implementation lazily loads them - Map attrs = new HashMap(); + Map attrs = new HashMap<>(); Enumeration iAttrNames = session.getAttributeNames(); while (iAttrNames.hasMoreElements()) { String attrName = iAttrNames.nextElement(); diff --git a/spring-session/src/main/java/org/springframework/session/web/socket/config/annotation/AbstractSessionWebSocketMessageBrokerConfigurer.java b/spring-session/src/main/java/org/springframework/session/web/socket/config/annotation/AbstractSessionWebSocketMessageBrokerConfigurer.java index 1b569e72..f0a2524a 100644 --- a/spring-session/src/main/java/org/springframework/session/web/socket/config/annotation/AbstractSessionWebSocketMessageBrokerConfigurer.java +++ b/spring-session/src/main/java/org/springframework/session/web/socket/config/annotation/AbstractSessionWebSocketMessageBrokerConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -126,7 +126,7 @@ public abstract class AbstractSessionWebSocketMessageBrokerConfigurer sessionRepositoryInterceptor() { - return new SessionRepositoryMessageInterceptor(this.sessionRepository); + return new SessionRepositoryMessageInterceptor<>(this.sessionRepository); } /** diff --git a/spring-session/src/main/java/org/springframework/session/web/socket/handler/WebSocketRegistryListener.java b/spring-session/src/main/java/org/springframework/session/web/socket/handler/WebSocketRegistryListener.java index ce36b387..2b8cf7b2 100644 --- a/spring-session/src/main/java/org/springframework/session/web/socket/handler/WebSocketRegistryListener.java +++ b/spring-session/src/main/java/org/springframework/session/web/socket/handler/WebSocketRegistryListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -55,7 +55,7 @@ public final class WebSocketRegistryListener CloseStatus.POLICY_VIOLATION.getCode(), "This connection was established under an authenticated HTTP Session that has expired"); - private final ConcurrentHashMap> httpSessionIdToWsSessions = new ConcurrentHashMap>(); + private final ConcurrentHashMap> httpSessionIdToWsSessions = new ConcurrentHashMap<>(); public void onApplicationEvent(ApplicationEvent event) { if (event instanceof SessionDestroyedEvent) { @@ -117,7 +117,7 @@ public final class WebSocketRegistryListener Map sessions = this.httpSessionIdToWsSessions .get(httpSessionId); if (sessions == null) { - sessions = new ConcurrentHashMap(); + sessions = new ConcurrentHashMap<>(); this.httpSessionIdToWsSessions.putIfAbsent(httpSessionId, sessions); sessions = this.httpSessionIdToWsSessions.get(httpSessionId); } diff --git a/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java b/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java index bf319231..7ce71ec3 100644 --- a/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java +++ b/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java @@ -469,7 +469,7 @@ public class RedisOperationsSessionRepositoryTests { given(this.redisOperations.boundSetOps(anyString())) .willReturn(this.boundSetOperations); - Set expiredIds = new HashSet( + Set expiredIds = new HashSet<>( Arrays.asList("expired-key1", "expired-key2")); given(this.boundSetOperations.members()).willReturn(expiredIds); @@ -701,7 +701,7 @@ public class RedisOperationsSessionRepositoryTests { } private Map map(Object... objects) { - Map result = new HashMap(); + Map result = new HashMap<>(); if (objects == null) { return result; } diff --git a/spring-session/src/test/java/org/springframework/session/hazelcast/HazelcastSessionRepositoryTests.java b/spring-session/src/test/java/org/springframework/session/hazelcast/HazelcastSessionRepositoryTests.java index a0ae300e..f4be81ed 100644 --- a/spring-session/src/test/java/org/springframework/session/hazelcast/HazelcastSessionRepositoryTests.java +++ b/spring-session/src/test/java/org/springframework/session/hazelcast/HazelcastSessionRepositoryTests.java @@ -309,7 +309,7 @@ public class HazelcastSessionRepositoryTests { String principal = "username"; Authentication authentication = new UsernamePasswordAuthenticationToken(principal, "notused", AuthorityUtils.createAuthorityList("ROLE_USER")); - List saved = new ArrayList(2); + List saved = new ArrayList<>(2); MapSession saved1 = new MapSession(); saved1.setAttribute(SPRING_SECURITY_CONTEXT, authentication); saved.add(saved1); diff --git a/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java b/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java index 886701f6..0523ee63 100644 --- a/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java +++ b/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java @@ -493,7 +493,7 @@ public class JdbcOperationsSessionRepositoryTests { String principal = "username"; Authentication authentication = new UsernamePasswordAuthenticationToken(principal, "notused", AuthorityUtils.createAuthorityList("ROLE_USER")); - List saved = new ArrayList(2); + List saved = new ArrayList<>(2); MapSession saved1 = new MapSession(); saved1.setAttribute(SPRING_SECURITY_CONTEXT, authentication); saved.add(saved1); diff --git a/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java b/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java index 721f5e74..6e0be60b 100644 --- a/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java +++ b/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java @@ -140,7 +140,7 @@ public class SpringSessionBackedSessionRegistryTest { ExpiringSession session1 = createSession(SESSION_ID, USER_NAME, NOW.getTime()); session1.setAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR, Boolean.TRUE); ExpiringSession session2 = createSession(SESSION_ID2, USER_NAME, NOW.getTime()); - Map sessions = new LinkedHashMap(); + Map sessions = new LinkedHashMap<>(); sessions.put(session1.getId(), session1); sessions.put(session2.getId(), session2); when(this.sessionRepository.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, USER_NAME)).thenReturn(sessions); diff --git a/spring-session/src/test/java/org/springframework/session/web/http/OncePerRequestFilterTests.java b/spring-session/src/test/java/org/springframework/session/web/http/OncePerRequestFilterTests.java index 420a8f11..005b6d4d 100644 --- a/spring-session/src/test/java/org/springframework/session/web/http/OncePerRequestFilterTests.java +++ b/spring-session/src/test/java/org/springframework/session/web/http/OncePerRequestFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 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. @@ -52,7 +52,7 @@ public class OncePerRequestFilterTests { this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); this.chain = new MockFilterChain(); - this.invocations = new ArrayList(); + this.invocations = new ArrayList<>(); this.filter = new OncePerRequestFilter() { @Override protected void doFilterInternal(HttpServletRequest request, diff --git a/spring-session/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java b/spring-session/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java index d020fe6b..06ffec4e 100644 --- a/spring-session/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java +++ b/spring-session/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java @@ -88,9 +88,9 @@ public class SessionRepositoryFilterTests { @Before public void setup() throws Exception { - this.sessions = new HashMap(); + this.sessions = new HashMap<>(); this.sessionRepository = new MapSessionRepository(this.sessions); - this.filter = new SessionRepositoryFilter( + this.filter = new SessionRepositoryFilter<>( this.sessionRepository); setupRequest(); } @@ -129,7 +129,7 @@ public class SessionRepositoryFilterTests { session.setLastAccessedTime(0L); this.sessionRepository = spy(this.sessionRepository); given(this.sessionRepository.createSession()).willReturn(session); - this.filter = new SessionRepositoryFilter( + this.filter = new SessionRepositoryFilter<>( this.sessionRepository); doFilter(new DoInFilter() { @@ -235,7 +235,7 @@ public class SessionRepositoryFilterTests { @Test public void doFilterServletContextExplicit() throws Exception { final ServletContext expectedContext = new MockServletContext(); - this.filter = new SessionRepositoryFilter( + this.filter = new SessionRepositoryFilter<>( this.sessionRepository); this.filter.setServletContext(expectedContext); @@ -426,7 +426,7 @@ public class SessionRepositoryFilterTests { return createSession(); } }; - this.filter = new SessionRepositoryFilter( + this.filter = new SessionRepositoryFilter<>( this.sessionRepository); doFilter(new DoInFilter() { @Override @@ -1259,7 +1259,7 @@ public class SessionRepositoryFilterTests { SessionRepository sessionRepository = spy( new MapSessionRepository()); - this.filter = new SessionRepositoryFilter(sessionRepository); + this.filter = new SessionRepositoryFilter<>(sessionRepository); doFilter(new DoInFilter() { @Override @@ -1287,7 +1287,7 @@ public class SessionRepositoryFilterTests { SessionRepository sessionRepository = spy( new MapSessionRepository()); - this.filter = new SessionRepositoryFilter(sessionRepository); + this.filter = new SessionRepositoryFilter<>(sessionRepository); doFilter(new DoInFilter() { @Override @@ -1307,7 +1307,7 @@ public class SessionRepositoryFilterTests { this.sessionRepository); setSessionCookie(session.getId()); - this.filter = new SessionRepositoryFilter(sessionRepository); + this.filter = new SessionRepositoryFilter<>(sessionRepository); doFilter(new DoInFilter() { @Override @@ -1348,7 +1348,7 @@ public class SessionRepositoryFilterTests { public void getSessionFalseWithInvalidSessionIdShouldOnlyAskRepositoryOnce() throws ServletException, IOException { this.sessionRepository = spy(this.sessionRepository); - this.filter = new SessionRepositoryFilter( + this.filter = new SessionRepositoryFilter<>( this.sessionRepository); final String nonExistantSessionId = "nonExistantSessionId"; @@ -1425,7 +1425,7 @@ public class SessionRepositoryFilterTests { } private void nextRequest() throws Exception { - Map nameToCookie = new HashMap(); + Map nameToCookie = new HashMap<>(); if (this.request.getCookies() != null) { for (Cookie cookie : this.request.getCookies()) { nameToCookie.put(cookie.getName(), cookie); @@ -1436,7 +1436,7 @@ public class SessionRepositoryFilterTests { nameToCookie.put(cookie.getName(), cookie); } } - Cookie[] nextRequestCookies = new ArrayList(nameToCookie.values()) + Cookie[] nextRequestCookies = new ArrayList<>(nameToCookie.values()) .toArray(new Cookie[0]); setupRequest(); diff --git a/spring-session/src/test/java/org/springframework/session/web/socket/handler/WebSocketRegistryListenerTests.java b/spring-session/src/test/java/org/springframework/session/web/socket/handler/WebSocketRegistryListenerTests.java index e89914ad..f1f37c06 100644 --- a/spring-session/src/test/java/org/springframework/session/web/socket/handler/WebSocketRegistryListenerTests.java +++ b/spring-session/src/test/java/org/springframework/session/web/socket/handler/WebSocketRegistryListenerTests.java @@ -74,7 +74,7 @@ public class WebSocketRegistryListenerTests { @Before public void setup() { this.sessionId = "session-id"; - this.attributes = new HashMap(); + this.attributes = new HashMap<>(); SessionRepositoryMessageInterceptor.setSessionId(this.attributes, this.sessionId); given(this.wsSession.getAttributes()).willReturn(this.attributes); @@ -85,7 +85,7 @@ public class WebSocketRegistryListenerTests { given(this.wsSession2.getPrincipal()).willReturn(this.principal); given(this.wsSession2.getId()).willReturn("wsSession-id2"); - Map headers = new HashMap(); + Map headers = new HashMap<>(); headers.put(SimpMessageHeaderAccessor.SESSION_ATTRIBUTES, this.attributes); given(this.message.getHeaders()).willReturn(new MessageHeaders(headers)); diff --git a/spring-session/src/test/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptorTests.java b/spring-session/src/test/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptorTests.java index 25abce19..068df07b 100644 --- a/spring-session/src/test/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptorTests.java +++ b/spring-session/src/test/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptorTests.java @@ -67,11 +67,11 @@ public class SessionRepositoryMessageInterceptorTests { @Before public void setup() { - this.interceptor = new SessionRepositoryMessageInterceptor( + this.interceptor = new SessionRepositoryMessageInterceptor<>( this.sessionRepository); this.headers = SimpMessageHeaderAccessor.create(); this.headers.setSessionId("session"); - this.headers.setSessionAttributes(new HashMap()); + this.headers.setSessionAttributes(new HashMap<>()); setMessageType(SimpMessageType.MESSAGE); String sessionId = "http-session"; setSessionId(sessionId); @@ -80,7 +80,7 @@ public class SessionRepositoryMessageInterceptorTests { @Test(expected = IllegalArgumentException.class) public void preSendconstructorNullRepository() { - new SessionRepositoryMessageInterceptor(null); + new SessionRepositoryMessageInterceptor<>(null); } @Test @@ -246,7 +246,7 @@ public class SessionRepositoryMessageInterceptorTests { MockHttpServletRequest httpRequest = new MockHttpServletRequest(); HttpSession httpSession = httpRequest.getSession(); ServletServerHttpRequest request = new ServletServerHttpRequest(httpRequest); - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); assertThat(this.interceptor.beforeHandshake(request, null, null, attributes)) .isTrue();