From bd6ae47d68b8f1d3e27ed57083ca012b70154e04 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Tue, 17 Jan 2017 04:09:46 +0900 Subject: [PATCH] Prevent unnecessary debug log message creation Closes gh-8001 --- .../oauth2/resource/UserInfoTokenServices.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServices.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServices.java index 479dccf8da2..a3c3445353e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServices.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServices.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -87,7 +87,9 @@ public class UserInfoTokenServices implements ResourceServerTokenServices { throws AuthenticationException, InvalidTokenException { Map map = getMap(this.userInfoEndpointUrl, accessToken); if (map.containsKey("error")) { - this.logger.debug("userinfo returned error: " + map.get("error")); + if (this.logger.isDebugEnabled()) { + this.logger.debug("userinfo returned error: " + map.get("error")); + } throw new InvalidTokenException(accessToken); } return extractAuthentication(map); @@ -123,7 +125,9 @@ public class UserInfoTokenServices implements ResourceServerTokenServices { @SuppressWarnings({ "unchecked" }) private Map getMap(String path, String accessToken) { - this.logger.debug("Getting user info from: " + path); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Getting user info from: " + path); + } try { OAuth2RestOperations restTemplate = this.restTemplate; if (restTemplate == null) {