Skip to content

Commit 3148a7d

Browse files
committed
Reduce logging severity in TokenEndpoint
Issue spring-atticgh-1232
1 parent cc4c0a5 commit 3148a7d

File tree

1 file changed

+15
-15
lines changed
  • spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/endpoint

1 file changed

+15
-15
lines changed

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/endpoint/TokenEndpoint.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616

1717
package org.springframework.security.oauth2.provider.endpoint;
1818

19-
import java.security.Principal;
20-
import java.util.Arrays;
21-
import java.util.Collections;
22-
import java.util.HashSet;
23-
import java.util.Map;
24-
import java.util.Set;
25-
2619
import org.springframework.http.HttpHeaders;
2720
import org.springframework.http.HttpMethod;
2821
import org.springframework.http.HttpStatus;
@@ -50,6 +43,13 @@
5043
import org.springframework.web.bind.annotation.RequestMethod;
5144
import org.springframework.web.bind.annotation.RequestParam;
5245

46+
import java.security.Principal;
47+
import java.util.Arrays;
48+
import java.util.Collections;
49+
import java.util.HashSet;
50+
import java.util.Map;
51+
import java.util.Set;
52+
5353
/**
5454
* <p>
5555
* Endpoint for token requests as described in the OAuth2 spec. Clients post requests with a <code>grant_type</code>
@@ -157,32 +157,32 @@ protected String getClientId(Principal principal) {
157157

158158
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
159159
public ResponseEntity<OAuth2Exception> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) throws Exception {
160-
if (logger.isErrorEnabled()) {
161-
logger.error("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
160+
if (logger.isInfoEnabled()) {
161+
logger.info("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
162162
}
163163
return getExceptionTranslator().translate(e);
164164
}
165165

166166
@ExceptionHandler(Exception.class)
167167
public ResponseEntity<OAuth2Exception> handleException(Exception e) throws Exception {
168-
if (logger.isErrorEnabled()) {
169-
logger.error("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
168+
if (logger.isWarnEnabled()) {
169+
logger.warn("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
170170
}
171171
return getExceptionTranslator().translate(e);
172172
}
173173

174174
@ExceptionHandler(ClientRegistrationException.class)
175175
public ResponseEntity<OAuth2Exception> handleClientRegistrationException(Exception e) throws Exception {
176-
if (logger.isErrorEnabled()) {
177-
logger.error("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
176+
if (logger.isWarnEnabled()) {
177+
logger.warn("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
178178
}
179179
return getExceptionTranslator().translate(new BadClientCredentialsException());
180180
}
181181

182182
@ExceptionHandler(OAuth2Exception.class)
183183
public ResponseEntity<OAuth2Exception> handleException(OAuth2Exception e) throws Exception {
184-
if (logger.isErrorEnabled()) {
185-
logger.error("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
184+
if (logger.isWarnEnabled()) {
185+
logger.warn("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
186186
}
187187
return getExceptionTranslator().translate(e);
188188
}

0 commit comments

Comments
 (0)