Source:
public final Optional<EquivalenceGraphUpdate> updateEquivalences(ResourceRef subject, Set<ResourceRef> assertedAdjacents, Set<Publisher> sources) throws WriteException { ImmutableSet<Id> newAdjacents = ImmutableSet.copyOf(Iterables.transform(assertedAdjacents, Identifiables.toId())); Set<Id> subjectAndAdjacents = MoreSets.add(newAdjacents, subject.getId()); Set<Id> transitiveSetsIds = null; try { LOG.debug("Thread is trying to enter synchronized block to lock graph IDs", Thread.currentThread().getName()); synchronized (lock()) { LOG.debug("Thread has entered synchronized block to lock graph IDs {}", Thread.currentThread().getName(), subjectAndAdjacents); while((transitiveSetsIds = tryLockAllIds(subjectAndAdjacents)) == null) { lock().unlock(subjectAndAdjacents); lock().wait(5000); LOG.debug("Thread attempting to lock IDs {}", Thread.currentThread().getName(), subjectAndAdjacents); } } LOG.debug("Thread has left synchronized block, having locked graph IDs", Thread.currentThread().getName()); Optional<EquivalenceGraphUpdate> updated = updateGraphs(subject, ImmutableSet.copyOf(assertedAdjacents), sources); if (updated.isPresent()) { sendUpdateMessage(subject, updated); } return updated; } catch(InterruptedException e) { log().error(String.format("%s: %s", subject, newAdjacents), e); unlock(subjectAndAdjacents, transitiveSetsIds); return Optional.absent(); } catch (StoreException e) { Throwables.propagateIfPossible(e, WriteException.class); throw new WriteException(e); } catch (CorruptEquivalenceGraphIndexException e) { cleanGraphAndIndex(e.getSubjectId()); unlock(subjectAndAdjacents, transitiveSetsIds); return updateEquivalences(subject, assertedAdjacents, sources); } finally { unlock(subjectAndAdjacents, transitiveSetsIds); } }

Target:
public final Optional<EquivalenceGraphUpdate> updateEquivalences(ResourceRef subject, Set<ResourceRef> assertedAdjacents, Set<Publisher> sources) throws WriteException { ImmutableSet<Id> newAdjacents = ImmutableSet.copyOf(Iterables.transform(assertedAdjacents, Identifiables.toId())); Set<Id> subjectAndAdjacents = MoreSets.add(newAdjacents, subject.getId()); Set<Id> transitiveSetsIds = null; try { LOG.debug("Thread is trying to enter synchronized block to lock graph IDs", Thread.currentThread().getName()); synchronized (lock()) { LOG.debug("Thread has entered synchronized block to lock graph IDs {}", Thread.currentThread().getName(), subjectAndAdjacents); while((transitiveSetsIds = tryLockAllIds(subjectAndAdjacents)) == null) { lock().unlock(subjectAndAdjacents); lock().wait(5000); LOG.debug("Thread attempting to lock IDs {}", Thread.currentThread().getName(), subjectAndAdjacents); } } LOG.debug("Thread has left synchronized block, having locked graph IDs", Thread.currentThread().getName()); Optional<EquivalenceGraphUpdate> updated = updateGraphs(subject, ImmutableSet.copyOf(assertedAdjacents), sources); if (updated.isPresent()) { sendUpdateMessage(subject, updated); } return updated; } catch(InterruptedException e) { log().error(String.format("%s: %s", subject, newAdjacents), e); return Optional.absent(); } catch (StoreException e) { Throwables.propagateIfPossible(e, WriteException.class); throw new WriteException(e); } catch (CorruptEquivalenceGraphIndexException e) { cleanGraphAndIndex(e.getSubjectId()); unlock(subjectAndAdjacents, transitiveSetsIds); return updateEquivalences(subject, assertedAdjacents, sources); } finally { unlock(subjectAndAdjacents, transitiveSetsIds); } }