Source:
<code>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); <START> unlock(subjectAndAdjacents, transitiveSetsIds); <END> 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); } }</code><technical_language>need call unlock() here. finally block executed return</technical_language>

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); } }