Lock lock = getAndLock(id);
CacheValue cacheKey = new StringValue(id);
try {
// do not overwrite document in cache if the
// existing one in the cache is newer
NodeDocument cached = nodesCache.getIfPresent(cacheKey);
if (cached != null && cached != NodeDocument.NULL) {
// check mod count
Number cachedModCount = cached.getModCount();
Number modCount = doc.getModCount();
if (cachedModCount == null || modCount == null) {
throw new IllegalStateException("Missing " + Document.MOD_COUNT);
}
if (modCount.longValue() > cachedModCount.longValue()) {