<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Hi,</div>
<div><br>
</div>
<div>We have a system in production that is logging some exceptions. This is happening in DefaultOAuth2ProviderTokenService.clearExpiredTokens. I’ve been trying to track that down but so far no luck reproducing it on my development environment. Has anybody
seem this? Is it benign or something we should be concerned about? </div>
<div><br>
</div>
<div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>@Override</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>public void clearExpiredTokens() {</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>logger.info("Cleaning out all expired tokens");</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>Collection<OAuth2AccessTokenEntity> accessTokens = getExpiredAccessTokens();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>logger.info("Found " + accessTokens.size() + " expired access tokens");</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>for (OAuth2AccessTokenEntity oAuth2AccessTokenEntity : accessTokens) {</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>try {</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>revokeAccessToken(oAuth2AccessTokenEntity);</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>} catch (IllegalArgumentException e) {</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>//An ID token is deleted with its corresponding access token, but then the ID token is on the list of expired tokens as well and there is</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>//nothing in place to distinguish it from any other.</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>//An attempt to delete an already deleted token returns an error, stopping the cleanup dead. We need it to keep going.</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div>…</div>
</div>
<div><br>
</div>
<div>
<div>2015Aug27 16:38:49,564: ERROR: org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task.</div>
<div>java.lang.IllegalStateException: Expected single result, got 2</div>
<div> at org.mitre.util.jpa.JpaUtil.getSingleResult(JpaUtil.java:36)</div>
<div> at org.mitre.oauth2.repository.impl.JpaOAuth2TokenRepository.getAccessTokenByValue(JpaOAuth2TokenRepository.java:62)</div>
<div> at org.mitre.oauth2.repository.impl.JpaOAuth2TokenRepository.removeAccessToken(JpaOAuth2TokenRepository.java:79)</div>
<div> at org.mitre.oauth2.repository.impl.JpaOAuth2TokenRepository$$FastClassBySpringCGLIB$$145026dd.invoke(<generated>)</div>
<div> at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)</div>
<div> at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700)</div>
<div> at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)</div>
<div> at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)</div>
<div> at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)</div>
<div> at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)</div>
<div> at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)</div>
<div> at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633)</div>
<div> at org.mitre.oauth2.repository.impl.JpaOAuth2TokenRepository$$EnhancerBySpringCGLIB$$e7092f0b.removeAccessToken(<generated>)</div>
<div> at org.mitre.oauth2.service.impl.DefaultOAuth2ProviderTokenService.revokeAccessToken(DefaultOAuth2ProviderTokenService.java:380)</div>
<div> at org.mitre.oauth2.service.impl.DefaultOAuth2ProviderTokenService.clearExpiredTokens(DefaultOAuth2ProviderTokenService.java:411)</div>
<div> at sun.reflect.GeneratedMethodAccessor210.invoke(Unknown Source)</div>
<div> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)</div>
<div> at java.lang.reflect.Method.invoke(Unknown Source)</div>
<div> at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64)</div>
<div> at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)</div>
<div> at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)</div>
<div> at java.util.concurrent.FutureTask.runAndReset(Unknown Source)</div>
<div> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)</div>
<div> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)</div>
<div> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)</div>
<div> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)</div>
<div> at java.lang.Thread.run(Unknown Source)</div>
</div>
<div><br>
</div>
<div>Regards,</div>
<div>Luiz</div>
</body>
</html>