Author: fschumacher Date: Sun Mar 13 11:39:54 2016 New Revision: 1734789 URL: http://svn.apache.org/viewvc?rev=1734789&view=rev Log: Convert usage of Map#putIfAbsent to java 7
Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java?rev=1734789&r1=1734788&r2=1734789&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java Sun Mar 13 11:39:54 2016 @@ -113,14 +113,15 @@ public final class CustomObjectInputStre } if (reportedClasses == null) { reportedClasses = Collections.newSetFromMap(new ConcurrentHashMap<String,Boolean>()); - Set<String> original; synchronized (reportedClassCache) { - original = reportedClassCache.putIfAbsent(classLoader, reportedClasses); - } - if (original != null) { - // Concurrent attempts to create the new Set. Make sure all - // threads use the first successfully added Set. - reportedClasses = original; + Set<String> original = reportedClassCache.get(classLoader); + if (original == null) { + reportedClassCache.put(classLoader, reportedClasses); + } else { + // Concurrent attempts to create the new Set. Make sure all + // threads use the first successfully added Set. + reportedClasses = original; + } } } this.reportedClasses = reportedClasses; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org