Remove synchronized on method updateUsageForId for API token usage stat
* Update ApiTokenStats.java
remove the synchronized on method updateUsageForId if token usage stats diabled
* Update ApiTokenPropertyConfiguration.java
change the default value for api token usage stats to false
* Update ApiTokenPropertyConfiguration.java
change default value to true
@@ -133,11 +133,16 @@ public class ApiTokenStats implements Saveable {
/**
* Will trigger the save
*/
- public synchronized @Nonnull SingleTokenStats updateUsageForId(@Nonnull String tokenUuid) {
+ public @Nonnull SingleTokenStats updateUsageForId(@Nonnull String tokenUuid) {
if(areStatsDisabled()){
return new SingleTokenStats(tokenUuid);
}
+ return updateUsageForIdIfNeeded(tokenUuid);
+ }
+
+
+ private synchronized SingleTokenStats updateUsageForIdIfNeeded(@Nonnull String tokenUuid) {
SingleTokenStats stats = findById(tokenUuid)
.orElseGet(() -> {
SingleTokenStats result = new SingleTokenStats(tokenUuid);
