Add missing @Override

This commit is contained in:
Vedran Pavic
2017-10-27 08:33:45 +02:00
parent 5df555cd53
commit f8583bb02f
49 changed files with 273 additions and 0 deletions

View File

@@ -71,6 +71,7 @@ public class MapReactiveSessionRepository implements ReactiveSessionRepository<M
this.defaultMaxInactiveInterval = defaultMaxInactiveInterval;
}
@Override
public Mono<Void> save(MapSession session) {
return Mono.fromRunnable(() -> {
if (!session.getId().equals(session.getOriginalId())) {
@@ -81,6 +82,7 @@ public class MapReactiveSessionRepository implements ReactiveSessionRepository<M
});
}
@Override
public Mono<MapSession> findById(String id) {
// @formatter:off
return Mono.defer(() -> Mono.justOrEmpty(this.sessions.get(id))
@@ -90,10 +92,12 @@ public class MapReactiveSessionRepository implements ReactiveSessionRepository<M
// @formatter:on
}
@Override
public Mono<Void> deleteById(String id) {
return Mono.fromRunnable(() -> this.sessions.remove(id));
}
@Override
public Mono<MapSession> createSession() {
return Mono.defer(() -> {
MapSession result = new MapSession();

View File

@@ -107,14 +107,17 @@ public final class MapSession implements Session, Serializable {
this.maxInactiveInterval = session.getMaxInactiveInterval();
}
@Override
public void setLastAccessedTime(Instant lastAccessedTime) {
this.lastAccessedTime = lastAccessedTime;
}
@Override
public Instant getCreationTime() {
return this.creationTime;
}
@Override
public String getId() {
return this.id;
}
@@ -127,24 +130,29 @@ public final class MapSession implements Session, Serializable {
this.originalId = originalId;
}
@Override
public String changeSessionId() {
String changedId = generateId();
setId(changedId);
return changedId;
}
@Override
public Instant getLastAccessedTime() {
return this.lastAccessedTime;
}
@Override
public void setMaxInactiveInterval(Duration interval) {
this.maxInactiveInterval = interval;
}
@Override
public Duration getMaxInactiveInterval() {
return this.maxInactiveInterval;
}
@Override
public boolean isExpired() {
return isExpired(Instant.now());
}
@@ -156,15 +164,18 @@ public final class MapSession implements Session, Serializable {
return now.minus(this.maxInactiveInterval).compareTo(this.lastAccessedTime) >= 0;
}
@Override
@SuppressWarnings("unchecked")
public <T> T getAttribute(String attributeName) {
return (T) this.sessionAttrs.get(attributeName);
}
@Override
public Set<String> getAttributeNames() {
return this.sessionAttrs.keySet();
}
@Override
public void setAttribute(String attributeName, Object attributeValue) {
if (attributeValue == null) {
removeAttribute(attributeName);
@@ -174,6 +185,7 @@ public final class MapSession implements Session, Serializable {
}
}
@Override
public void removeAttribute(String attributeName) {
this.sessionAttrs.remove(attributeName);
}
@@ -198,10 +210,12 @@ public final class MapSession implements Session, Serializable {
this.id = id;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Session && this.id.equals(((Session) obj).getId());
}
@Override
public int hashCode() {
return this.id.hashCode();
}

View File

@@ -69,6 +69,7 @@ public class MapSessionRepository implements SessionRepository<MapSession> {
this.defaultMaxInactiveInterval = defaultMaxInactiveInterval;
}
@Override
public void save(MapSession session) {
if (!session.getId().equals(session.getOriginalId())) {
this.sessions.remove(session.getOriginalId());
@@ -77,6 +78,7 @@ public class MapSessionRepository implements SessionRepository<MapSession> {
this.sessions.put(session.getId(), new MapSession(session));
}
@Override
public MapSession findById(String id) {
Session saved = this.sessions.get(id);
if (saved == null) {
@@ -89,10 +91,12 @@ public class MapSessionRepository implements SessionRepository<MapSession> {
return new MapSession(saved);
}
@Override
public void deleteById(String id) {
this.sessions.remove(id);
}
@Override
public MapSession createSession() {
MapSession result = new MapSession();
if (this.defaultMaxInactiveInterval != null) {

View File

@@ -55,12 +55,14 @@ public class SpringSessionBackedSessionRegistry<S extends Session>
this.sessionRepository = sessionRepository;
}
@Override
public List<Object> getAllPrincipals() {
throw new UnsupportedOperationException("SpringSessionBackedSessionRegistry does "
+ "not support retrieving all principals, since Spring Session provides "
+ "no way to obtain that information");
}
@Override
public List<SessionInformation> getAllSessions(Object principal,
boolean includeExpiredSessions) {
Collection<S> sessions = this.sessionRepository.findByIndexNameAndIndexValue(
@@ -77,6 +79,7 @@ public class SpringSessionBackedSessionRegistry<S extends Session>
return infos;
}
@Override
public SessionInformation getSessionInformation(String sessionId) {
S session = this.sessionRepository.findById(sessionId);
if (session != null) {
@@ -89,18 +92,21 @@ public class SpringSessionBackedSessionRegistry<S extends Session>
/*
* This is a no-op, as we don't administer sessions ourselves.
*/
@Override
public void refreshLastRequest(String sessionId) {
}
/*
* This is a no-op, as we don't administer sessions ourselves.
*/
@Override
public void registerNewSession(String sessionId, Object principal) {
}
/*
* This is a no-op, as we don't administer sessions ourselves.
*/
@Override
public void removeSessionInformation(String sessionId) {
}

View File

@@ -60,16 +60,19 @@ public class SpringSessionRememberMeServices
private String sessionAttrToDeleteOnLoginFail = HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY;
@Override
public final Authentication autoLogin(HttpServletRequest request,
HttpServletResponse response) {
return null;
}
@Override
public final void loginFail(HttpServletRequest request,
HttpServletResponse response) {
logout(request);
}
@Override
public final void loginSuccess(HttpServletRequest request,
HttpServletResponse response, Authentication successfulAuthentication) {
if (!this.alwaysRemember
@@ -126,6 +129,7 @@ public class SpringSessionRememberMeServices
this.validitySeconds = validitySeconds;
}
@Override
public void logout(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) {
logout(request);

View File

@@ -107,6 +107,7 @@ public abstract class AbstractHttpSessionApplicationInitializer
this.configurationClasses = configurationClasses;
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
beforeSessionRepositoryFilter(servletContext);
if (this.configurationClasses != null) {

View File

@@ -63,6 +63,7 @@ public class DefaultCookieSerializer implements CookieSerializer {
* @see org.springframework.session.web.http.CookieSerializer#readCookieValues(javax.
* servlet.http.HttpServletRequest)
*/
@Override
public List<String> readCookieValues(HttpServletRequest request) {
Cookie[] cookies = request.getCookies();
List<String> matchingCookieValues = new ArrayList<>();
@@ -91,6 +92,7 @@ public class DefaultCookieSerializer implements CookieSerializer {
* @see org.springframework.session.web.http.CookieWriter#writeCookieValue(org.
* springframework.session.web.http.CookieWriter.CookieValue)
*/
@Override
public void writeCookieValue(CookieValue cookieValue) {
HttpServletRequest request = cookieValue.getRequest();
HttpServletResponse response = cookieValue.getResponse();

View File

@@ -55,74 +55,90 @@ class HttpSessionAdapter<S extends Session> implements HttpSession {
return this.session;
}
@Override
public long getCreationTime() {
checkState();
return this.session.getCreationTime().toEpochMilli();
}
@Override
public String getId() {
return this.session.getId();
}
@Override
public long getLastAccessedTime() {
checkState();
return this.session.getLastAccessedTime().toEpochMilli();
}
@Override
public ServletContext getServletContext() {
return this.servletContext;
}
@Override
public void setMaxInactiveInterval(int interval) {
this.session.setMaxInactiveInterval(Duration.ofSeconds(interval));
}
@Override
public int getMaxInactiveInterval() {
return (int) this.session.getMaxInactiveInterval().getSeconds();
}
@Override
public HttpSessionContext getSessionContext() {
return NOOP_SESSION_CONTEXT;
}
@Override
public Object getAttribute(String name) {
checkState();
return this.session.getAttribute(name);
}
@Override
public Object getValue(String name) {
return getAttribute(name);
}
@Override
public Enumeration<String> getAttributeNames() {
checkState();
return Collections.enumeration(this.session.getAttributeNames());
}
@Override
public String[] getValueNames() {
checkState();
Set<String> attrs = this.session.getAttributeNames();
return attrs.toArray(new String[0]);
}
@Override
public void setAttribute(String name, Object value) {
checkState();
this.session.setAttribute(name, value);
}
@Override
public void putValue(String name, Object value) {
setAttribute(name, value);
}
@Override
public void removeAttribute(String name) {
checkState();
this.session.removeAttribute(name);
}
@Override
public void removeValue(String name) {
removeAttribute(name);
}
@Override
public void invalidate() {
checkState();
this.invalidated = true;
@@ -132,6 +148,7 @@ class HttpSessionAdapter<S extends Session> implements HttpSession {
this.old = !isNew;
}
@Override
public boolean isNew() {
checkState();
return !this.old;
@@ -145,20 +162,24 @@ class HttpSessionAdapter<S extends Session> implements HttpSession {
}
private static final HttpSessionContext NOOP_SESSION_CONTEXT = new HttpSessionContext() {
@Override
public HttpSession getSession(String sessionId) {
return null;
}
@Override
public Enumeration<String> getIds() {
return EMPTY_ENUMERATION;
}
};
private static final Enumeration<String> EMPTY_ENUMERATION = new Enumeration<String>() {
@Override
public boolean hasMoreElements() {
return false;
}
@Override
public String nextElement() {
throw new NoSuchElementException("a");
}

View File

@@ -244,187 +244,224 @@ abstract class OnCommittedResponseWrapper extends HttpServletResponseWrapper {
this.delegate = delegate;
}
@Override
public void flush() {
doOnResponseCommitted();
this.delegate.flush();
}
@Override
public void close() {
doOnResponseCommitted();
this.delegate.close();
}
@Override
public int hashCode() {
return this.delegate.hashCode();
}
@Override
public boolean equals(Object obj) {
return this.delegate.equals(obj);
}
@Override
public String toString() {
return getClass().getName() + "[delegate=" + this.delegate.toString() + "]";
}
@Override
public boolean checkError() {
return this.delegate.checkError();
}
@Override
public void write(int c) {
trackContentLength(c);
this.delegate.write(c);
}
@Override
public void write(char[] buf, int off, int len) {
checkContentLength(len);
this.delegate.write(buf, off, len);
}
@Override
public void write(char[] buf) {
trackContentLength(buf);
this.delegate.write(buf);
}
@Override
public void write(String s, int off, int len) {
checkContentLength(len);
this.delegate.write(s, off, len);
}
@Override
public void write(String s) {
trackContentLength(s);
this.delegate.write(s);
}
@Override
public void print(boolean b) {
trackContentLength(b);
this.delegate.print(b);
}
@Override
public void print(char c) {
trackContentLength(c);
this.delegate.print(c);
}
@Override
public void print(int i) {
trackContentLength(i);
this.delegate.print(i);
}
@Override
public void print(long l) {
trackContentLength(l);
this.delegate.print(l);
}
@Override
public void print(float f) {
trackContentLength(f);
this.delegate.print(f);
}
@Override
public void print(double d) {
trackContentLength(d);
this.delegate.print(d);
}
@Override
public void print(char[] s) {
trackContentLength(s);
this.delegate.print(s);
}
@Override
public void print(String s) {
trackContentLength(s);
this.delegate.print(s);
}
@Override
public void print(Object obj) {
trackContentLength(obj);
this.delegate.print(obj);
}
@Override
public void println() {
trackContentLengthLn();
this.delegate.println();
}
@Override
public void println(boolean x) {
trackContentLength(x);
trackContentLengthLn();
this.delegate.println(x);
}
@Override
public void println(char x) {
trackContentLength(x);
trackContentLengthLn();
this.delegate.println(x);
}
@Override
public void println(int x) {
trackContentLength(x);
trackContentLengthLn();
this.delegate.println(x);
}
@Override
public void println(long x) {
trackContentLength(x);
trackContentLengthLn();
this.delegate.println(x);
}
@Override
public void println(float x) {
trackContentLength(x);
trackContentLengthLn();
this.delegate.println(x);
}
@Override
public void println(double x) {
trackContentLength(x);
trackContentLengthLn();
this.delegate.println(x);
}
@Override
public void println(char[] x) {
trackContentLength(x);
trackContentLengthLn();
this.delegate.println(x);
}
@Override
public void println(String x) {
trackContentLength(x);
trackContentLengthLn();
this.delegate.println(x);
}
@Override
public void println(Object x) {
trackContentLength(x);
trackContentLengthLn();
this.delegate.println(x);
}
@Override
public PrintWriter printf(String format, Object... args) {
return this.delegate.printf(format, args);
}
@Override
public PrintWriter printf(Locale l, String format, Object... args) {
return this.delegate.printf(l, format, args);
}
@Override
public PrintWriter format(String format, Object... args) {
return this.delegate.format(format, args);
}
@Override
public PrintWriter format(Locale l, String format, Object... args) {
return this.delegate.format(l, format, args);
}
@Override
public PrintWriter append(CharSequence csq) {
checkContentLength(csq.length());
return this.delegate.append(csq);
}
@Override
public PrintWriter append(CharSequence csq, int start, int end) {
checkContentLength(end - start);
return this.delegate.append(csq, start, end);
}
@Override
public PrintWriter append(char c) {
trackContentLength(c);
return this.delegate.append(c);
@@ -446,121 +483,144 @@ abstract class OnCommittedResponseWrapper extends HttpServletResponseWrapper {
this.delegate = delegate;
}
@Override
public void write(int b) throws IOException {
trackContentLength(b);
this.delegate.write(b);
}
@Override
public void flush() throws IOException {
doOnResponseCommitted();
this.delegate.flush();
}
@Override
public void close() throws IOException {
doOnResponseCommitted();
this.delegate.close();
}
@Override
public int hashCode() {
return this.delegate.hashCode();
}
@Override
public boolean equals(Object obj) {
return this.delegate.equals(obj);
}
@Override
public void print(boolean b) throws IOException {
trackContentLength(b);
this.delegate.print(b);
}
@Override
public void print(char c) throws IOException {
trackContentLength(c);
this.delegate.print(c);
}
@Override
public void print(double d) throws IOException {
trackContentLength(d);
this.delegate.print(d);
}
@Override
public void print(float f) throws IOException {
trackContentLength(f);
this.delegate.print(f);
}
@Override
public void print(int i) throws IOException {
trackContentLength(i);
this.delegate.print(i);
}
@Override
public void print(long l) throws IOException {
trackContentLength(l);
this.delegate.print(l);
}
@Override
public void print(String s) throws IOException {
trackContentLength(s);
this.delegate.print(s);
}
@Override
public void println() throws IOException {
trackContentLengthLn();
this.delegate.println();
}
@Override
public void println(boolean b) throws IOException {
trackContentLength(b);
trackContentLengthLn();
this.delegate.println(b);
}
@Override
public void println(char c) throws IOException {
trackContentLength(c);
trackContentLengthLn();
this.delegate.println(c);
}
@Override
public void println(double d) throws IOException {
trackContentLength(d);
trackContentLengthLn();
this.delegate.println(d);
}
@Override
public void println(float f) throws IOException {
trackContentLength(f);
trackContentLengthLn();
this.delegate.println(f);
}
@Override
public void println(int i) throws IOException {
trackContentLength(i);
trackContentLengthLn();
this.delegate.println(i);
}
@Override
public void println(long l) throws IOException {
trackContentLength(l);
trackContentLengthLn();
this.delegate.println(l);
}
@Override
public void println(String s) throws IOException {
trackContentLength(s);
trackContentLengthLn();
this.delegate.println(s);
}
@Override
public void write(byte[] b) throws IOException {
trackContentLength(b);
this.delegate.write(b);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
checkContentLength(len);
this.delegate.write(b, off, len);
}
@Override
public String toString() {
return getClass().getName() + "[delegate=" + this.delegate.toString() + "]";
}

View File

@@ -55,6 +55,7 @@ abstract class OncePerRequestFilter implements Filter {
* @throws ServletException if request is not HTTP request
* @throws IOException in case of I/O operation exception
*/
@Override
public final void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws ServletException, IOException {
@@ -104,9 +105,11 @@ abstract class OncePerRequestFilter implements Filter {
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException;
@Override
public void init(FilterConfig config) {
}
@Override
public void destroy() {
}
}

View File

@@ -55,6 +55,7 @@ public class SessionEventHttpSessionListenerAdapter
* @see org.springframework.context.ApplicationListener#onApplicationEvent(org.
* springframework.context.ApplicationEvent)
*/
@Override
public void onApplicationEvent(AbstractSessionEvent event) {
if (this.listeners.isEmpty()) {
return;
@@ -86,6 +87,7 @@ public class SessionEventHttpSessionListenerAdapter
* org.springframework.web.context.ServletContextAware#setServletContext(javax.servlet
* .ServletContext)
*/
@Override
public void setServletContext(ServletContext servletContext) {
this.context = servletContext;
}

View File

@@ -73,10 +73,12 @@ public class SpringSessionWebSessionStore<S extends Session> implements WebSessi
this.clock = clock;
}
@Override
public Mono<WebSession> createWebSession() {
return this.sessions.createSession().map(this::createSession);
}
@Override
public Mono<WebSession> updateLastAccessTime(WebSession session) {
@SuppressWarnings("unchecked")
SpringSessionWebSession springSessionWebSession = (SpringSessionWebSession) session;
@@ -294,19 +296,23 @@ public class SpringSessionWebSessionStore<S extends Session> implements WebSessi
private class SessionValues extends AbstractCollection<Object> {
@Override
public Iterator<Object> iterator() {
return new Iterator<Object>() {
private Iterator<Entry<String, Object>> i = entrySet().iterator();
@Override
public boolean hasNext() {
return this.i.hasNext();
}
@Override
public Object next() {
return this.i.next().getValue();
}
@Override
public void remove() {
this.i.remove();
}
@@ -314,18 +320,22 @@ public class SpringSessionWebSessionStore<S extends Session> implements WebSessi
};
}
@Override
public int size() {
return SpringSessionMap.this.size();
}
@Override
public boolean isEmpty() {
return SpringSessionMap.this.isEmpty();
}
@Override
public void clear() {
SpringSessionMap.this.clear();
}
@Override
public boolean contains(Object v) {
return SpringSessionMap.this.containsValue(v);
}

View File

@@ -89,6 +89,7 @@ public abstract class AbstractSessionWebSocketMessageBrokerConfigurer<S extends
registration.interceptors(sessionRepositoryInterceptor());
}
@Override
public final void registerStompEndpoints(StompEndpointRegistry registry) {
if (registry instanceof WebMvcStompEndpointRegistry) {
WebMvcStompEndpointRegistry mvcRegistry = (WebMvcStompEndpointRegistry) registry;
@@ -141,6 +142,7 @@ public abstract class AbstractSessionWebSocketMessageBrokerConfigurer<S extends
this.interceptor = interceptor;
}
@Override
public StompWebSocketEndpointRegistration addEndpoint(String... paths) {
StompWebSocketEndpointRegistration endpoints = this.registry
.addEndpoint(paths);
@@ -148,14 +150,17 @@ public abstract class AbstractSessionWebSocketMessageBrokerConfigurer<S extends
return endpoints;
}
@Override
public void setOrder(int order) {
this.registry.setOrder(order);
}
@Override
public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
this.registry.setUrlPathHelper(urlPathHelper);
}
@Override
public WebMvcStompEndpointRegistry setErrorHandler(
StompSubProtocolErrorHandler errorHandler) {
return this.registry.setErrorHandler(errorHandler);

View File

@@ -60,6 +60,7 @@ public final class WebSocketConnectHandlerDecoratorFactory
this.eventPublisher = eventPublisher;
}
@Override
public WebSocketHandler decorate(WebSocketHandler handler) {
return new SessionWebSocketHandler(handler);
}

View File

@@ -57,6 +57,7 @@ public final class WebSocketRegistryListener
private final ConcurrentHashMap<String, Map<String, WebSocketSession>> httpSessionIdToWsSessions = new ConcurrentHashMap<>();
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof SessionDestroyedEvent) {
SessionDestroyedEvent e = (SessionDestroyedEvent) event;

View File

@@ -131,6 +131,7 @@ public final class SessionRepositoryMessageInterceptor<S extends Session>
return super.preSend(message, channel);
}
@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response,
WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
if (request instanceof ServletServerHttpRequest) {
@@ -143,6 +144,7 @@ public final class SessionRepositoryMessageInterceptor<S extends Session>
return true;
}
@Override
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response,
WebSocketHandler wsHandler, Exception exception) {
}

View File

@@ -130,50 +130,62 @@ public class MapSessionTests {
static class CustomSession implements Session {
@Override
public Instant getCreationTime() {
return Instant.EPOCH;
}
@Override
public String changeSessionId() {
throw new UnsupportedOperationException();
}
@Override
public String getId() {
return "id";
}
@Override
public void setLastAccessedTime(Instant lastAccessedTime) {
throw new UnsupportedOperationException();
}
@Override
public Instant getLastAccessedTime() {
return Instant.EPOCH;
}
@Override
public void setMaxInactiveInterval(Duration interval) {
}
@Override
public Duration getMaxInactiveInterval() {
return Duration.ZERO;
}
@Override
public <T> T getAttribute(String attributeName) {
return null;
}
@Override
public Set<String> getAttributeNames() {
return null;
}
@Override
public void setAttribute(String attributeName, Object attributeValue) {
}
@Override
public void removeAttribute(String attributeName) {
}
@Override
public boolean isExpired() {
return false;
}

View File

@@ -1436,6 +1436,7 @@ public class SessionRepositoryFilterTests {
private static class SessionRepositoryFilterDefaultOrder implements Ordered {
@Override
public int getOrder() {
return SessionRepositoryFilter.DEFAULT_ORDER;
}

View File

@@ -288,6 +288,7 @@ public class SessionRepositoryMessageInterceptorTests {
static class AlmostNowMatcher implements ArgumentMatcher<Instant> {
@Override
public boolean matches(Instant argument) {
long now = System.currentTimeMillis();
long delta = now - argument.toEpochMilli();