Polishing
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.server.adapter;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.server.handler;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.server.session;
|
||||
|
||||
import java.time.Duration;
|
||||
@@ -45,7 +46,7 @@ public class CookieWebSessionIdResolver implements WebSessionIdResolver {
|
||||
* @param cookieName the cookie name
|
||||
*/
|
||||
public void setCookieName(String cookieName) {
|
||||
Assert.hasText(cookieName, "'cookieName' must not be empty.");
|
||||
Assert.hasText(cookieName, "'cookieName' must not be empty");
|
||||
this.cookieName = cookieName;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.server.session;
|
||||
|
||||
import java.util.List;
|
||||
@@ -24,7 +25,6 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebSession;
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation of {@link WebSessionManager} delegating to a
|
||||
* {@link WebSessionIdResolver} for session id resolution and to a
|
||||
@@ -47,7 +47,7 @@ public class DefaultWebSessionManager implements WebSessionManager {
|
||||
* @param sessionIdResolver the resolver to use
|
||||
*/
|
||||
public void setSessionIdResolver(WebSessionIdResolver sessionIdResolver) {
|
||||
Assert.notNull(sessionIdResolver, "WebSessionIdResolver is required.");
|
||||
Assert.notNull(sessionIdResolver, "WebSessionIdResolver is required");
|
||||
this.sessionIdResolver = sessionIdResolver;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class DefaultWebSessionManager implements WebSessionManager {
|
||||
* @param sessionStore the persistence strategy to use
|
||||
*/
|
||||
public void setSessionStore(WebSessionStore sessionStore) {
|
||||
Assert.notNull(sessionStore, "WebSessionStore is required.");
|
||||
Assert.notNull(sessionStore, "WebSessionStore is required");
|
||||
this.sessionStore = sessionStore;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@ public class DefaultWebSessionManager implements WebSessionManager {
|
||||
}
|
||||
|
||||
private Mono<Void> save(ServerWebExchange exchange, WebSession session) {
|
||||
|
||||
List<String> ids = getSessionIdResolver().resolveSessionIds(exchange);
|
||||
|
||||
if (!session.isStarted() || session.isExpired()) {
|
||||
@@ -107,4 +106,5 @@ public class DefaultWebSessionManager implements WebSessionManager {
|
||||
|
||||
return session.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.server.session;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -46,7 +47,7 @@ public class HeaderWebSessionIdResolver implements WebSessionIdResolver {
|
||||
* @param headerName the header name
|
||||
*/
|
||||
public void setHeaderName(String headerName) {
|
||||
Assert.hasText(headerName, "'headerName' must not be empty.");
|
||||
Assert.hasText(headerName, "'headerName' must not be empty");
|
||||
this.headerName = headerName;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -89,9 +89,7 @@ public class InMemoryWebSessionStore implements WebSessionStore {
|
||||
|
||||
@Override
|
||||
public Mono<WebSession> retrieveSession(String id) {
|
||||
|
||||
Instant currentTime = Instant.now(this.clock);
|
||||
|
||||
if (!this.sessions.isEmpty() && !currentTime.isBefore(this.nextExpirationCheckTime)) {
|
||||
checkExpiredSessions(currentTime);
|
||||
}
|
||||
@@ -159,13 +157,11 @@ public class InMemoryWebSessionStore implements WebSessionStore {
|
||||
|
||||
private final AtomicReference<State> state = new AtomicReference<>(State.NEW);
|
||||
|
||||
|
||||
public InMemoryWebSession() {
|
||||
this.creationTime = Instant.now(getClock());
|
||||
this.lastAccessTime = this.creationTime;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id.get();
|
||||
@@ -259,6 +255,7 @@ public class InMemoryWebSessionStore implements WebSessionStore {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private enum State { NEW, STARTED, EXPIRED }
|
||||
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.server.session;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
|
||||
/**
|
||||
* Contract for session id resolution strategies. Allows for session id
|
||||
* resolution through the request and for sending the session id or expiring
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.server.session;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.server.session;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -61,4 +62,5 @@ public interface WebSessionStore {
|
||||
* @return the session with the updated last access time
|
||||
*/
|
||||
Mono<WebSession> updateLastAccessTime(WebSession webSession);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user