Remove use of Assert#notNull from core components

Fixes gh-820
This commit is contained in:
Vedran Pavic
2017-07-05 17:04:03 +02:00
parent 04b4fe3e3b
commit 47a7a35aa4
3 changed files with 10 additions and 7 deletions

View File

@@ -20,8 +20,6 @@ import java.time.Duration;
import java.time.Instant;
import java.util.Set;
import org.springframework.util.Assert;
/**
* Provides a way to identify a user in an agnostic way. This allows the session to be
* used by an HttpSession, WebSocket Session, or even non web related sessions.
@@ -60,7 +58,10 @@ public interface Session {
@SuppressWarnings("unchecked")
default <T> T getRequiredAttribute(String name) {
T result = getAttribute(name);
Assert.notNull(result, "Required attribute '" + name + "' is missing.");
if (result == null) {
throw new IllegalArgumentException(
"Required attribute '" + name + "' is missing.");
}
return result;
}

View File

@@ -33,7 +33,6 @@ import javax.servlet.http.HttpServletResponseWrapper;
import org.springframework.session.Session;
import org.springframework.session.web.http.CookieSerializer.CookieValue;
import org.springframework.util.Assert;
/**
* A {@link HttpSessionStrategy} that uses a cookie to obtain the session from.
@@ -293,7 +292,9 @@ public final class CookieHttpSessionStrategy
* @param cookieSerializer the cookieSerializer to set. Cannot be null.
*/
public void setCookieSerializer(CookieSerializer cookieSerializer) {
Assert.notNull(cookieSerializer, "cookieSerializer cannot be null");
if (cookieSerializer == null) {
throw new IllegalArgumentException("cookieSerializer cannot be null");
}
this.cookieSerializer = cookieSerializer;
}

View File

@@ -20,7 +20,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.session.Session;
import org.springframework.util.Assert;
/**
* A {@link HttpSessionStrategy} that uses a header to obtain the session from.
@@ -79,7 +78,9 @@ public class HeaderHttpSessionStrategy implements HttpSessionStrategy {
* @param headerName the name of the header to obtain the session id from.
*/
public void setHeaderName(String headerName) {
Assert.notNull(headerName, "headerName cannot be null");
if (headerName == null) {
throw new IllegalArgumentException("headerName cannot be null");
}
this.headerName = headerName;
}