Source:
<code>private static <T> GridToStringClassDescriptor getClassDescriptor(Class<T> cls) { assert cls != null; String key = cls.getName() + System.identityHashCode(cls.getClassLoader()); GridToStringClassDescriptor cd; <START> cd = classCache.get(key); <END> if (cd == null) { cd = new GridToStringClassDescriptor(cls); for (Field f : cls.getDeclaredFields()) { boolean add = false; Class<?> type = f.getType(); final GridToStringInclude incFld = f.getAnnotation(GridToStringInclude.class); final GridToStringInclude incType = type.getAnnotation(GridToStringInclude.class); if (incFld != null || incType != null) { final boolean notSens = (incFld == null || !incFld.sensitive()) && (incType == null || !incType.sensitive()); add = notSens || INCLUDE_SENSITIVE; } else if (!f.isAnnotationPresent(GridToStringExclude.class) && !f.getType().isAnnotationPresent(GridToStringExclude.class)) { if ( Modifier.isPrivate(f.getModifiers()) && !Modifier.isStatic(f.getModifiers()) && Object.class != type && Serializable.class != type && Externalizable.class != type && !type.isArray() && !EventListener.class.isAssignableFrom(type) && !Map.class.isAssignableFrom(type) && !Collection.class.isAssignableFrom(type) && !InputStream.class.isAssignableFrom(type) && !OutputStream.class.isAssignableFrom(type) && !Thread.class.isAssignableFrom(type) && !Runnable.class.isAssignableFrom(type) && !Lock.class.isAssignableFrom(type) && !ReadWriteLock.class.isAssignableFrom(type) && !Condition.class.isAssignableFrom(type) ) add = true; } if (add) { GridToStringFieldDescriptor fd = new GridToStringFieldDescriptor(f.getName()); final GridToStringOrder annOrder = f.getAnnotation(GridToStringOrder.class); if (annOrder != null) fd.setOrder(annOrder.value()); cd.addField(fd); } } cd.sortFields(); classCache.put(key, cd); } return cd; }</code><technical_language>I suggest putIfAbsent</technical_language>

Target:
private static <T> GridToStringClassDescriptor getClassDescriptor(Class<T> cls) { assert cls != null; String key = cls.getName() + System.identityHashCode(cls.getClassLoader()); GridToStringClassDescriptor cd; cd = classCache.get(key); if (cd == null) { cd = new GridToStringClassDescriptor(cls); for (Field f : cls.getDeclaredFields()) { boolean add = false; Class<?> type = f.getType(); final GridToStringInclude incFld = f.getAnnotation(GridToStringInclude.class); final GridToStringInclude incType = type.getAnnotation(GridToStringInclude.class); if (incFld != null || incType != null) { final boolean notSens = (incFld == null || !incFld.sensitive()) && (incType == null || !incType.sensitive()); add = notSens || INCLUDE_SENSITIVE; } else if (!f.isAnnotationPresent(GridToStringExclude.class) && !f.getType().isAnnotationPresent(GridToStringExclude.class)) { if ( Modifier.isPrivate(f.getModifiers()) && !Modifier.isStatic(f.getModifiers()) && Object.class != type && Serializable.class != type && Externalizable.class != type && !type.isArray() && !EventListener.class.isAssignableFrom(type) && !Map.class.isAssignableFrom(type) && !Collection.class.isAssignableFrom(type) && !InputStream.class.isAssignableFrom(type) && !OutputStream.class.isAssignableFrom(type) && !Thread.class.isAssignableFrom(type) && !Runnable.class.isAssignableFrom(type) && !Lock.class.isAssignableFrom(type) && !ReadWriteLock.class.isAssignableFrom(type) && !Condition.class.isAssignableFrom(type) ) add = true; } if (add) { GridToStringFieldDescriptor fd = new GridToStringFieldDescriptor(f.getName()); final GridToStringOrder annOrder = f.getAnnotation(GridToStringOrder.class); if (annOrder != null) fd.setOrder(annOrder.value()); cd.addField(fd); } } cd.sortFields(); classCache.putIfAbsent(key, cd); } return cd; }