/** * Executes a method which has the potential to throw a {@link TemporaryLockingException} or a {@link PermanentLockingException}. * If the exception is thrown it is wrapped in a {@link GraknBackendException} so that the transaction can be retried. * * @param method The locking method to execute */ private <X> X executeLockingMethod(Supplier<X> method){ try { return method.get(); } catch (JanusGraphException e){ if(e.isCausedBy(TemporaryLockingException.class) || e.isCausedBy(PermanentLockingException.class)){ throw TemporaryWriteException.temporaryLock(e); } else { throw GraknBackendException.unknown(e); } } }