Remove unnecessary throws declaration

This commit is contained in:
Vedran Pavic
2019-07-02 19:21:07 +02:00
parent 0731e7f2d0
commit 1ca9daccb4
26 changed files with 91 additions and 114 deletions

View File

@@ -23,7 +23,6 @@ import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterRegistration.Dynamic;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.springframework.context.ApplicationContext;
import org.springframework.core.Conventions;
@@ -105,7 +104,7 @@ public abstract class AbstractHttpSessionApplicationInitializer implements WebAp
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
public void onStartup(ServletContext servletContext) {
beforeSessionRepositoryFilter(servletContext);
if (this.configurationClasses != null) {
AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();

View File

@@ -125,7 +125,7 @@ public final class SessionRepositoryMessageInterceptor<S extends Session>
@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,
Map<String, Object> attributes) throws Exception {
Map<String, Object> attributes) {
if (request instanceof ServletServerHttpRequest) {
ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
HttpSession session = servletRequest.getServletRequest().getSession(false);

View File

@@ -47,7 +47,7 @@ class CookieHttpSessionIdResolverTests {
private Session session;
@BeforeEach
void setup() throws Exception {
void setup() {
this.cookieName = "SESSION";
this.session = new MapSession();
this.request = new MockHttpServletRequest();
@@ -56,19 +56,19 @@ class CookieHttpSessionIdResolverTests {
}
@Test
void getRequestedSessionIdNull() throws Exception {
void getRequestedSessionIdNull() {
assertThat(this.strategy.resolveSessionIds(this.request)).isEmpty();
}
@Test
void getRequestedSessionIdNotNull() throws Exception {
void getRequestedSessionIdNotNull() {
setSessionCookie(this.session.getId());
assertThat(this.strategy.resolveSessionIds(this.request))
.isEqualTo(Collections.singletonList(this.session.getId()));
}
@Test
void getRequestedSessionIdNotNullCustomCookieName() throws Exception {
void getRequestedSessionIdNotNullCustomCookieName() {
setCookieName("CUSTOM");
setSessionCookie(this.session.getId());
assertThat(this.strategy.resolveSessionIds(this.request))
@@ -76,13 +76,13 @@ class CookieHttpSessionIdResolverTests {
}
@Test
void onNewSession() throws Exception {
void onNewSession() {
this.strategy.setSessionId(this.request, this.response, this.session.getId());
assertThat(getSessionId()).isEqualTo(this.session.getId());
}
@Test
void onNewSessionTwiceSameId() throws Exception {
void onNewSessionTwiceSameId() {
this.strategy.setSessionId(this.request, this.response, this.session.getId());
this.strategy.setSessionId(this.request, this.response, this.session.getId());
@@ -90,7 +90,7 @@ class CookieHttpSessionIdResolverTests {
}
@Test
void onNewSessionTwiceNewId() throws Exception {
void onNewSessionTwiceNewId() {
Session newSession = new MapSession();
this.strategy.setSessionId(this.request, this.response, this.session.getId());
@@ -104,7 +104,7 @@ class CookieHttpSessionIdResolverTests {
}
@Test
void onNewSessionCookiePath() throws Exception {
void onNewSessionCookiePath() {
this.request.setContextPath("/somethingunique");
this.strategy.setSessionId(this.request, this.response, this.session.getId());
@@ -113,20 +113,20 @@ class CookieHttpSessionIdResolverTests {
}
@Test
void onNewSessionCustomCookieName() throws Exception {
void onNewSessionCustomCookieName() {
setCookieName("CUSTOM");
this.strategy.setSessionId(this.request, this.response, this.session.getId());
assertThat(getSessionId()).isEqualTo(this.session.getId());
}
@Test
void onDeleteSession() throws Exception {
void onDeleteSession() {
this.strategy.expireSession(this.request, this.response);
assertThat(getSessionId()).isEmpty();
}
@Test
void onDeleteSessionCookiePath() throws Exception {
void onDeleteSessionCookiePath() {
this.request.setContextPath("/somethingunique");
this.strategy.expireSession(this.request, this.response);
@@ -135,7 +135,7 @@ class CookieHttpSessionIdResolverTests {
}
@Test
void onDeleteSessionCustomCookieName() throws Exception {
void onDeleteSessionCustomCookieName() {
setCookieName("CUSTOM");
this.strategy.expireSession(this.request, this.response);
assertThat(getSessionId()).isEmpty();

View File

@@ -1061,7 +1061,7 @@ class OnCommittedResponseWrapperTests {
}
@Test
void contentLengthDoesNotCommit() throws IOException {
void contentLengthDoesNotCommit() {
String body = "something";
this.response.setContentLength(body.length());

View File

@@ -96,7 +96,7 @@ class SessionRepositoryFilterTests {
private MockFilterChain chain;
@BeforeEach
void setup() throws Exception {
void setup() {
MockitoAnnotations.initMocks(this);
this.sessions = new HashMap<>();
this.sessionRepository = new MapSessionRepository(this.sessions);
@@ -1141,8 +1141,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
String actualId = wrappedRequest.getRequestedSessionId();
assertThat(actualId).isEqualTo(expectedId);
}
@@ -1176,8 +1175,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
wrappedRequest.getSession();
}
});
@@ -1194,8 +1192,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
wrappedRequest.getSession().getId();
}
});
@@ -1207,8 +1204,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
wrappedRequest.getSession().invalidate();
}
});
@@ -1223,8 +1219,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
wrappedRequest.getSession().getId();
}
});
@@ -1235,8 +1230,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
}
});
@@ -1252,8 +1246,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
wrappedRequest.getSession().getId();
}
});
@@ -1263,8 +1256,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
}
});
@@ -1279,8 +1271,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
}
});
@@ -1298,8 +1289,7 @@ class SessionRepositoryFilterTests {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
throws IOException {
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) {
}
});
@@ -1505,7 +1495,7 @@ class SessionRepositoryFilterTests {
this.chain = new MockFilterChain();
}
private void nextRequest() throws Exception {
private void nextRequest() {
Map<String, Cookie> nameToCookie = new HashMap<>();
if (this.request.getCookies() != null) {
for (Cookie cookie : this.request.getCookies()) {

View File

@@ -154,7 +154,7 @@ class WebSocketRegistryListenerTests {
}
@Test
void onApplicationEventConnectDisconnectNullSession() throws Exception {
void onApplicationEventConnectDisconnectNullSession() {
this.listener.onApplicationEvent(this.connect);
this.attributes.clear();

View File

@@ -222,14 +222,14 @@ class SessionRepositoryMessageInterceptorTests {
}
@Test
void beforeHandshakeNotServletServerHttpRequest() throws Exception {
void beforeHandshakeNotServletServerHttpRequest() {
assertThat(this.interceptor.beforeHandshake(null, null, null, null)).isTrue();
verifyZeroInteractions(this.sessionRepository);
}
@Test
void beforeHandshakeNullSession() throws Exception {
void beforeHandshakeNullSession() {
ServletServerHttpRequest request = new ServletServerHttpRequest(new MockHttpServletRequest());
assertThat(this.interceptor.beforeHandshake(request, null, null, null)).isTrue();
@@ -237,7 +237,7 @@ class SessionRepositoryMessageInterceptorTests {
}
@Test
void beforeHandshakeSession() throws Exception {
void beforeHandshakeSession() {
MockHttpServletRequest httpRequest = new MockHttpServletRequest();
HttpSession httpSession = httpRequest.getSession();
ServletServerHttpRequest request = new ServletServerHttpRequest(httpRequest);