Skip to content
This repository was archived by the owner on Nov 11, 2019. It is now read-only.

Commit 5f17032

Browse files
committed
Restore Removed Throws Clauses
In a recent clean-up, certain exceptions were removed from various throws clauses. This PR re-introduces throws clauses that are important for one of the following reasons: 1. It's a method on a public interface 2. It's a method clearly designed for inheritance, for example, a method stub, an abstract method, or indicated as such in the docs. Fixes spring-projectsgh-7541
1 parent a4430aa commit 5f17032

File tree

13 files changed

+28
-19
lines changed

13 files changed

+28
-19
lines changed

config/src/main/java/org/springframework/security/config/annotation/AbstractConfiguredSecurityBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ protected final O doBuild() throws Exception {
343343
* method. Subclasses may override this method to hook into the lifecycle without
344344
* using a {@link SecurityConfigurer}.
345345
*/
346-
protected void beforeInit() {
346+
protected void beforeInit() throws Exception {
347347
}
348348

349349
/**

config/src/main/java/org/springframework/security/config/annotation/authentication/builders/AuthenticationManagerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public AuthenticationManagerBuilder authenticationProvider(
228228
}
229229

230230
@Override
231-
protected ProviderManager performBuild() {
231+
protected ProviderManager performBuild() throws Exception {
232232
if (!isConfigured()) {
233233
logger.debug("No authenticationProviders and no parentAuthenticationManager defined. Returning null.");
234234
return null;

config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public void init(final WebSecurity web) throws Exception {
331331
* Override this method to configure {@link WebSecurity}. For example, if you wish to
332332
* ignore certain requests.
333333
*/
334-
public void configure(WebSecurity web) {
334+
public void configure(WebSecurity web) throws Exception {
335335
}
336336

337337
/**

core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ protected Authentication createSuccessAuthentication(Object principal,
228228
return result;
229229
}
230230

231-
protected void doAfterPropertiesSet() {
231+
protected void doAfterPropertiesSet() throws Exception {
232232
}
233233

234234
public UserCache getUserCache() {

core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationCallbackHandler.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
package org.springframework.security.authentication.jaas;
1818

19-
import org.springframework.security.core.Authentication;
20-
19+
import java.io.IOException;
2120
import javax.security.auth.callback.Callback;
21+
import javax.security.auth.callback.UnsupportedCallbackException;
22+
23+
import org.springframework.security.core.Authentication;
2224

2325
/**
2426
* The JaasAuthenticationCallbackHandler is similar to the
@@ -58,5 +60,6 @@ public interface JaasAuthenticationCallbackHandler {
5860
* @param auth The Authentication object currently being authenticated.
5961
*
6062
*/
61-
void handle(Callback callback, Authentication auth);
63+
void handle(Callback callback, Authentication auth) throws IOException,
64+
UnsupportedCallbackException;
6265
}

remoting/src/main/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public class AuthenticationSimpleHttpInvokerRequestExecutor extends
5858
* @param contentLength the length of the content to send
5959
*
6060
*/
61-
protected void doPrepareConnection(HttpURLConnection con, int contentLength) {
61+
protected void doPrepareConnection(HttpURLConnection con, int contentLength)
62+
throws IOException {
6263
}
6364

6465
/**

web/src/main/java/org/springframework/security/web/access/channel/ChannelEntryPoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.springframework.security.web.access.channel;
1818

1919
import java.io.IOException;
20-
20+
import javax.servlet.ServletException;
2121
import javax.servlet.http.HttpServletRequest;
2222
import javax.servlet.http.HttpServletResponse;
2323

@@ -47,5 +47,5 @@ public interface ChannelEntryPoint {
4747
*
4848
*/
4949
void commence(HttpServletRequest request, HttpServletResponse response)
50-
throws IOException;
50+
throws IOException, ServletException;
5151
}

web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ protected boolean requiresAuthentication(HttpServletRequest request,
280280
* @throws AuthenticationException if authentication fails.
281281
*/
282282
public abstract Authentication attemptAuthentication(HttpServletRequest request,
283-
HttpServletResponse response) throws AuthenticationException, IOException;
283+
HttpServletResponse response) throws AuthenticationException, IOException,
284+
ServletException;
284285

285286
/**
286287
* Default behaviour for successful authentication.

web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
package org.springframework.security.web.authentication;
1717

1818
import java.io.IOException;
19-
19+
import javax.servlet.ServletException;
2020
import javax.servlet.http.HttpServletRequest;
2121
import javax.servlet.http.HttpServletResponse;
2222

2323
import org.apache.commons.logging.Log;
2424
import org.apache.commons.logging.LogFactory;
25+
2526
import org.springframework.security.core.Authentication;
2627
import org.springframework.security.web.DefaultRedirectStrategy;
2728
import org.springframework.security.web.RedirectStrategy;
@@ -78,7 +79,7 @@ protected AbstractAuthenticationTargetUrlRequestHandler() {
7879
* The redirect will not be performed if the response has already been committed.
7980
*/
8081
protected void handle(HttpServletRequest request, HttpServletResponse response,
81-
Authentication authentication) throws IOException {
82+
Authentication authentication) throws IOException, ServletException {
8283
String targetUrl = determineTargetUrl(request, response, authentication);
8384

8485
if (response.isCommitted()) {

web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ protected String buildRedirectUrlToLoginPage(HttpServletRequest request,
211211
* Builds a URL to redirect the supplied request to HTTPS. Used to redirect the
212212
* current request to HTTPS, before doing a forward to the login page.
213213
*/
214-
protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request) {
214+
protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request)
215+
throws IOException, ServletException {
215216

216217
int serverPort = portResolver.getServerPort(request);
217218
Integer httpsPort = portMapper.lookupHttpsPort(serverPort);

web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ private boolean authenticationIsRequired(String username) {
244244
}
245245

246246
protected void onSuccessfulAuthentication(HttpServletRequest request,
247-
HttpServletResponse response, Authentication authResult) {
247+
HttpServletResponse response, Authentication authResult) throws IOException {
248248
}
249249

250250
protected void onUnsuccessfulAuthentication(HttpServletRequest request,
251-
HttpServletResponse response, AuthenticationException failed) {
251+
HttpServletResponse response, AuthenticationException failed) throws IOException {
252252
}
253253

254254
protected AuthenticationEntryPoint getAuthenticationEntryPoint() {

web/src/main/java/org/springframework/security/web/session/InvalidSessionStrategy.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
*/
1616
package org.springframework.security.web.session;
1717

18+
import java.io.IOException;
19+
import javax.servlet.ServletException;
1820
import javax.servlet.http.HttpServletRequest;
1921
import javax.servlet.http.HttpServletResponse;
20-
import java.io.IOException;
2122

2223
/**
2324
* Determines the behaviour of the {@code SessionManagementFilter} when an invalid session
@@ -28,6 +29,6 @@
2829
public interface InvalidSessionStrategy {
2930

3031
void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse response)
31-
throws IOException;
32+
throws IOException, ServletException;
3233

3334
}

web/src/main/java/org/springframework/security/web/session/SessionInformationExpiredStrategy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.springframework.security.web.session;
1717

1818
import java.io.IOException;
19+
import javax.servlet.ServletException;
1920

2021
/**
2122
* Determines the behaviour of the {@code ConcurrentSessionFilter} when an expired session
@@ -28,5 +29,5 @@
2829
public interface SessionInformationExpiredStrategy {
2930

3031
void onExpiredSessionDetected(SessionInformationExpiredEvent event)
31-
throws IOException;
32+
throws IOException, ServletException;
3233
}

0 commit comments

Comments
 (0)