Replace explicit type arguments with diamond operator

This commit is contained in:
Vedran Pavic
2017-03-04 08:12:11 +01:00
committed by Rob Winch
parent 78ea101a43
commit 5b4d0c40d8
36 changed files with 91 additions and 94 deletions

View File

@@ -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<ExpiringSession> demo = new RepositoryDemo<ExpiringSession>();
RepositoryDemo<ExpiringSession> demo = new RepositoryDemo<>();
demo.repository = new MapSessionRepository();
demo.demo();
@@ -81,7 +81,7 @@ public class IndexDocTests {
@Test
public void expireRepositoryDemo() {
ExpiringRepositoryDemo<ExpiringSession> demo = new ExpiringRepositoryDemo<ExpiringSession>();
ExpiringRepositoryDemo<ExpiringSession> demo = new ExpiringRepositoryDemo<>();
demo.repository = new MapSessionRepository();
demo.demo();

View File

@@ -49,7 +49,7 @@ public class HomePage {
public HomePage(WebDriver driver) {
this.driver = driver;
this.attributes = new ArrayList<Attribute>();
this.attributes = new ArrayList<>();
}
private static void get(WebDriver driver, String get) {
@@ -80,7 +80,7 @@ public class HomePage {
}
public List<Attribute> attributes() {
List<Attribute> rows = new ArrayList<Attribute>();
List<Attribute> rows = new ArrayList<>();
for (WebElement tr : this.trs) {
rows.add(new Attribute(tr));
}

View File

@@ -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<S extends ExpiringSession> {
public WebSocketConnectHandler<S> webSocketConnectHandler(
SimpMessageSendingOperations messagingTemplate,
ActiveWebSocketUserRepository repository) {
return new WebSocketConnectHandler<S>(messagingTemplate, repository);
return new WebSocketConnectHandler<>(messagingTemplate, repository);
}
@Bean
public WebSocketDisconnectHandler<S> webSocketDisconnectHandler(
SimpMessageSendingOperations messagingTemplate,
ActiveWebSocketUserRepository repository) {
return new WebSocketDisconnectHandler<S>(messagingTemplate, repository);
return new WebSocketDisconnectHandler<>(messagingTemplate, repository);
}
}

View File

@@ -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<Transport> transports = new ArrayList<Transport>(2);
List<Transport> transports = new ArrayList<>(2);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
transports.add(new RestTemplateXhrTransport());

View File

@@ -46,7 +46,7 @@ public class HomePage {
public HomePage(WebDriver driver) {
this.driver = driver;
this.attributes = new ArrayList<Attribute>();
this.attributes = new ArrayList<>();
}
private static void get(WebDriver driver, String get) {
@@ -64,7 +64,7 @@ public class HomePage {
}
public List<Attribute> attributes() {
List<Attribute> rows = new ArrayList<Attribute>();
List<Attribute> rows = new ArrayList<>();
for (WebElement tr : this.trs) {
rows.add(new Attribute(tr));
}

View File

@@ -46,7 +46,7 @@ public class HomePage {
public HomePage(WebDriver driver) {
this.driver = driver;
this.attributes = new ArrayList<Attribute>();
this.attributes = new ArrayList<>();
}
private static void get(WebDriver driver, String get) {
@@ -64,7 +64,7 @@ public class HomePage {
}
public List<Attribute> attributes() {
List<Attribute> rows = new ArrayList<Attribute>();
List<Attribute> rows = new ArrayList<>();
for (WebElement tr : this.trs) {
rows.add(new Attribute(tr));
}

View File

@@ -46,7 +46,7 @@ public class HomePage {
public HomePage(WebDriver driver) {
this.driver = driver;
this.attributes = new ArrayList<Attribute>();
this.attributes = new ArrayList<>();
}
private static void get(WebDriver driver, String get) {
@@ -64,7 +64,7 @@ public class HomePage {
}
public List<Attribute> attributes() {
List<Attribute> rows = new ArrayList<Attribute>();
List<Attribute> rows = new ArrayList<>();
for (WebElement tr : this.trs) {
rows.add(new Attribute(tr));
}

View File

@@ -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<String, String> helloUser(Principal principal) {
HashMap<String, String> result = new HashMap<String, String>();
HashMap<String, String> result = new HashMap<>();
result.put("username", principal.getName());
return result;
}

View File

@@ -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<Account> accounts = new ArrayList<Account>();
List<Account> accounts = new ArrayList<>();
Account currentAccount = null;
for (Map.Entry<String, String> entry : sessionIds.entrySet()) {
String alias = entry.getKey();

View File

@@ -46,7 +46,7 @@ public class HomePage {
public HomePage(WebDriver driver) {
this.driver = driver;
this.attributes = new ArrayList<Attribute>();
this.attributes = new ArrayList<>();
}
private static void get(WebDriver driver, String get) {
@@ -64,7 +64,7 @@ public class HomePage {
}
public List<Attribute> attributes() {
List<Attribute> rows = new ArrayList<Attribute>();
List<Attribute> rows = new ArrayList<>();
for (WebElement tr : this.trs) {
rows.add(new Attribute(tr));
}

View File

@@ -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<ExpiringSession> sessionRepository = new MapSessionRepository(
sessions);
SessionRepositoryFilter<ExpiringSession> filter = new SessionRepositoryFilter<ExpiringSession>(
SessionRepositoryFilter<ExpiringSession> filter = new SessionRepositoryFilter<>(
sessionRepository);
Dynamic fr = sc.addFilter("springSessionFilter", filter);
fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

View File

@@ -46,7 +46,7 @@ public class HomePage {
public HomePage(WebDriver driver) {
this.driver = driver;
this.attributes = new ArrayList<Attribute>();
this.attributes = new ArrayList<>();
}
private static void get(WebDriver driver, String get) {
@@ -64,7 +64,7 @@ public class HomePage {
}
public List<Attribute> attributes() {
List<Attribute> rows = new ArrayList<Attribute>();
List<Attribute> rows = new ArrayList<>();
for (WebElement tr : this.trs) {
rows.add(new Attribute(tr));
}

View File

@@ -46,7 +46,7 @@ public class HomePage {
public HomePage(WebDriver driver) {
this.driver = driver;
this.attributes = new ArrayList<Attribute>();
this.attributes = new ArrayList<>();
}
private static void get(WebDriver driver, String get) {
@@ -64,7 +64,7 @@ public class HomePage {
}
public List<Attribute> attributes() {
List<Attribute> rows = new ArrayList<Attribute>();
List<Attribute> rows = new ArrayList<>();
for (WebElement tr : this.trs) {
rows.add(new Attribute(tr));
}

View File

@@ -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<AbstractSessionEvent> {
private Map<String, AbstractSessionEvent> events = new HashMap<String, AbstractSessionEvent>();
private Map<String, Object> locks = new HashMap<String, Object>();
private Map<String, AbstractSessionEvent> events = new HashMap<>();
private Map<String, Object> locks = new HashMap<>();
public void onApplicationEvent(AbstractSessionEvent event) {
String sessionId = event.getSessionId();

View File

@@ -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<String, Object> sessionAttrs = new HashMap<String, Object>();
private Map<String, Object> 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<String, Object>(
this.sessionAttrs = new HashMap<>(
session.getAttributeNames().size());
for (String attrName : session.getAttributeNames()) {
Object attrValue = session.getAttribute(attrName);

View File

@@ -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<ExpiringSession>
* Creates an instance backed by a {@link java.util.concurrent.ConcurrentHashMap}.
*/
public MapSessionRepository() {
this(new ConcurrentHashMap<String, ExpiringSession>());
this(new ConcurrentHashMap<>());
}
/**

View File

@@ -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<HttpSessionListener> httpSessionListeners = new ArrayList<HttpSessionListener>();
private List<HttpSessionListener> httpSessionListeners = new ArrayList<>();
@PostConstruct
public void init() {
@@ -124,7 +124,7 @@ public class SpringHttpSessionConfiguration implements ApplicationContextAware {
@Bean
public <S extends ExpiringSession> SessionRepositoryFilter<? extends ExpiringSession> springSessionRepositoryFilter(
SessionRepository<S> sessionRepository) {
SessionRepositoryFilter<S> sessionRepositoryFilter = new SessionRepositoryFilter<S>(
SessionRepositoryFilter<S> sessionRepositoryFilter = new SessionRepositoryFilter<>(
sessionRepository);
sessionRepositoryFilter.setServletContext(this.servletContext);
if (this.httpSessionStrategy instanceof MultiHttpSessionStrategy) {

View File

@@ -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<Object> sessionIds = this.sessionRedisOperations.boundSetOps(principalKey)
.members();
Map<String, RedisSession> sessions = new HashMap<String, RedisSession>(
Map<String, RedisSession> 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<Object, Object> createDefaultTemplate(
RedisConnectionFactory connectionFactory) {
Assert.notNull(connectionFactory, "connectionFactory cannot be null");
RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
RedisTemplate<Object, Object> 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<String, Object> delta = new HashMap<String, Object>();
private Map<String, Object> delta = new HashMap<>();
private boolean isNew;
private String originalPrincipalName;
@@ -797,7 +797,7 @@ public class RedisOperationsSessionRepository implements
}
}
this.delta = new HashMap<String, Object>(this.delta.size());
this.delta = new HashMap<>(this.delta.size());
Long originalExpiration = this.originalLastAccessTime == null ? null
: this.originalLastAccessTime + TimeUnit.SECONDS

View File

@@ -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<Object, Object> sessionRedisTemplate(
RedisConnectionFactory connectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
if (this.defaultRedisSerializer != null) {

View File

@@ -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<MapSession> sessions = this.sessions.values(
Predicates.equal(PRINCIPAL_NAME_ATTRIBUTE, indexValue));
Map<String, HazelcastSession> sessionMap = new HashMap<String, HazelcastSession>(
Map<String, HazelcastSession> sessionMap = new HashMap<>(
sessions.size());
for (MapSession session : sessions) {
sessionMap.put(session.getId(), new HazelcastSession(session));

View File

@@ -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<String> attributeNames = new ArrayList<String>(session.getAttributeNames());
final List<String> attributeNames = new ArrayList<>(session.getAttributeNames());
JdbcOperationsSessionRepository.this.jdbcOperations.batchUpdate(
JdbcOperationsSessionRepository.this.createSessionAttributeQuery,
new BatchPreparedStatementSetter() {
@@ -551,7 +551,7 @@ public class JdbcOperationsSessionRepository implements
});
Map<String, JdbcSession> sessionMap = new HashMap<String, JdbcSession>(
Map<String, JdbcSession> sessionMap = new HashMap<>(
sessions.size());
for (ExpiringSession session : sessions) {
@@ -650,7 +650,7 @@ public class JdbcOperationsSessionRepository implements
private boolean changed;
private Map<String, Object> delta = new HashMap<String, Object>();
private Map<String, Object> delta = new HashMap<>();
JdbcSession() {
this.delegate = new MapSession();
@@ -767,7 +767,7 @@ public class JdbcOperationsSessionRepository implements
implements ResultSetExtractor<List<ExpiringSession>> {
public List<ExpiringSession> extractData(ResultSet rs) throws SQLException, DataAccessException {
List<ExpiringSession> sessions = new ArrayList<ExpiringSession>();
List<ExpiringSession> sessions = new ArrayList<>();
while (rs.next()) {
String id = rs.getString("SESSION_ID");
MapSession session;

View File

@@ -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<SessionInformation> getAllSessions(Object principal, boolean includeExpiredSessions) {
Collection<ExpiringSession> sessions =
this.sessionRepository.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, name(principal)).values();
List<SessionInformation> infos = new ArrayList<SessionInformation>();
List<SessionInformation> infos = new ArrayList<>();
for (ExpiringSession session : sessions) {
if (includeExpiredSessions || !Boolean.TRUE.equals(session.getAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR))) {
infos.add(new SpringSessionBackedSessionInformation(session, this.sessionRepository));

View File

@@ -237,7 +237,7 @@ public final class CookieHttpSessionStrategy
Set<String> sessionsWritten = (Set<String>) request
.getAttribute(SESSION_IDS_WRITTEN_ATTR);
if (sessionsWritten == null) {
sessionsWritten = new HashSet<String>();
sessionsWritten = new HashSet<>();
request.setAttribute(SESSION_IDS_WRITTEN_ATTR, sessionsWritten);
}
return sessionsWritten;
@@ -326,7 +326,7 @@ public final class CookieHttpSessionStrategy
List<String> cookieValues = this.cookieSerializer.readCookieValues(request);
String sessionCookieValue = cookieValues.isEmpty() ? ""
: cookieValues.iterator().next();
Map<String, String> result = new LinkedHashMap<String, String>();
Map<String, String> result = new LinkedHashMap<>();
StringTokenizer tokens = new StringTokenizer(sessionCookieValue,
this.deserializationDelimiter);
if (tokens.countTokens() == 1) {

View File

@@ -65,7 +65,7 @@ public class DefaultCookieSerializer implements CookieSerializer {
*/
public List<String> readCookieValues(HttpServletRequest request) {
Cookie[] cookies = request.getCookies();
List<String> matchingCookieValues = new ArrayList<String>();
List<String> matchingCookieValues = new ArrayList<>();
if (cookies != null) {
for (Cookie cookie : cookies) {
if (this.cookieName.equals(cookie.getName())) {

View File

@@ -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<ExpiringSession>(session,
HttpSession httpSession = new ExpiringSessionHttpSession<>(session,
this.context);
HttpSessionEvent httpSessionEvent = new HttpSessionEvent(httpSession);
return httpSessionEvent;

View File

@@ -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<S extends ExpiringSession>
}
// eagerly get session attributes in case implementation lazily loads them
Map<String, Object> attrs = new HashMap<String, Object>();
Map<String, Object> attrs = new HashMap<>();
Enumeration<String> iAttrNames = session.getAttributeNames();
while (iAttrNames.hasMoreElements()) {
String attrName = iAttrNames.nextElement();

View File

@@ -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<S extends
@Bean
@SuppressWarnings("unchecked")
public SessionRepositoryMessageInterceptor<S> sessionRepositoryInterceptor() {
return new SessionRepositoryMessageInterceptor<S>(this.sessionRepository);
return new SessionRepositoryMessageInterceptor<>(this.sessionRepository);
}
/**

View File

@@ -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<String, Map<String, WebSocketSession>> httpSessionIdToWsSessions = new ConcurrentHashMap<String, Map<String, WebSocketSession>>();
private final ConcurrentHashMap<String, Map<String, WebSocketSession>> httpSessionIdToWsSessions = new ConcurrentHashMap<>();
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof SessionDestroyedEvent) {
@@ -117,7 +117,7 @@ public final class WebSocketRegistryListener
Map<String, WebSocketSession> sessions = this.httpSessionIdToWsSessions
.get(httpSessionId);
if (sessions == null) {
sessions = new ConcurrentHashMap<String, WebSocketSession>();
sessions = new ConcurrentHashMap<>();
this.httpSessionIdToWsSessions.putIfAbsent(httpSessionId, sessions);
sessions = this.httpSessionIdToWsSessions.get(httpSessionId);
}

View File

@@ -469,7 +469,7 @@ public class RedisOperationsSessionRepositoryTests {
given(this.redisOperations.boundSetOps(anyString()))
.willReturn(this.boundSetOperations);
Set<Object> expiredIds = new HashSet<Object>(
Set<Object> 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<String, Object> result = new HashMap<String, Object>();
Map<String, Object> result = new HashMap<>();
if (objects == null) {
return result;
}

View File

@@ -309,7 +309,7 @@ public class HazelcastSessionRepositoryTests {
String principal = "username";
Authentication authentication = new UsernamePasswordAuthenticationToken(principal,
"notused", AuthorityUtils.createAuthorityList("ROLE_USER"));
List<MapSession> saved = new ArrayList<MapSession>(2);
List<MapSession> saved = new ArrayList<>(2);
MapSession saved1 = new MapSession();
saved1.setAttribute(SPRING_SECURITY_CONTEXT, authentication);
saved.add(saved1);

View File

@@ -493,7 +493,7 @@ public class JdbcOperationsSessionRepositoryTests {
String principal = "username";
Authentication authentication = new UsernamePasswordAuthenticationToken(principal,
"notused", AuthorityUtils.createAuthorityList("ROLE_USER"));
List<MapSession> saved = new ArrayList<MapSession>(2);
List<MapSession> saved = new ArrayList<>(2);
MapSession saved1 = new MapSession();
saved1.setAttribute(SPRING_SECURITY_CONTEXT, authentication);
saved.add(saved1);

View File

@@ -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<String, ExpiringSession> sessions = new LinkedHashMap<String, ExpiringSession>();
Map<String, ExpiringSession> 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);

View File

@@ -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<OncePerRequestFilter>();
this.invocations = new ArrayList<>();
this.filter = new OncePerRequestFilter() {
@Override
protected void doFilterInternal(HttpServletRequest request,

View File

@@ -88,9 +88,9 @@ public class SessionRepositoryFilterTests {
@Before
public void setup() throws Exception {
this.sessions = new HashMap<String, ExpiringSession>();
this.sessions = new HashMap<>();
this.sessionRepository = new MapSessionRepository(this.sessions);
this.filter = new SessionRepositoryFilter<ExpiringSession>(
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<ExpiringSession>(
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<ExpiringSession>(
this.filter = new SessionRepositoryFilter<>(
this.sessionRepository);
this.filter.setServletContext(expectedContext);
@@ -426,7 +426,7 @@ public class SessionRepositoryFilterTests {
return createSession();
}
};
this.filter = new SessionRepositoryFilter<ExpiringSession>(
this.filter = new SessionRepositoryFilter<>(
this.sessionRepository);
doFilter(new DoInFilter() {
@Override
@@ -1259,7 +1259,7 @@ public class SessionRepositoryFilterTests {
SessionRepository<ExpiringSession> sessionRepository = spy(
new MapSessionRepository());
this.filter = new SessionRepositoryFilter<ExpiringSession>(sessionRepository);
this.filter = new SessionRepositoryFilter<>(sessionRepository);
doFilter(new DoInFilter() {
@Override
@@ -1287,7 +1287,7 @@ public class SessionRepositoryFilterTests {
SessionRepository<ExpiringSession> sessionRepository = spy(
new MapSessionRepository());
this.filter = new SessionRepositoryFilter<ExpiringSession>(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<ExpiringSession>(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<ExpiringSession>(
this.filter = new SessionRepositoryFilter<>(
this.sessionRepository);
final String nonExistantSessionId = "nonExistantSessionId";
@@ -1425,7 +1425,7 @@ public class SessionRepositoryFilterTests {
}
private void nextRequest() throws Exception {
Map<String, Cookie> nameToCookie = new HashMap<String, Cookie>();
Map<String, Cookie> 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<Cookie>(nameToCookie.values())
Cookie[] nextRequestCookies = new ArrayList<>(nameToCookie.values())
.toArray(new Cookie[0]);
setupRequest();

View File

@@ -74,7 +74,7 @@ public class WebSocketRegistryListenerTests {
@Before
public void setup() {
this.sessionId = "session-id";
this.attributes = new HashMap<String, Object>();
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<String, Object> headers = new HashMap<String, Object>();
Map<String, Object> headers = new HashMap<>();
headers.put(SimpMessageHeaderAccessor.SESSION_ATTRIBUTES, this.attributes);
given(this.message.getHeaders()).willReturn(new MessageHeaders(headers));

View File

@@ -67,11 +67,11 @@ public class SessionRepositoryMessageInterceptorTests {
@Before
public void setup() {
this.interceptor = new SessionRepositoryMessageInterceptor<ExpiringSession>(
this.interceptor = new SessionRepositoryMessageInterceptor<>(
this.sessionRepository);
this.headers = SimpMessageHeaderAccessor.create();
this.headers.setSessionId("session");
this.headers.setSessionAttributes(new HashMap<String, Object>());
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<ExpiringSession>(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<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
assertThat(this.interceptor.beforeHandshake(request, null, null, attributes))
.isTrue();