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 GraknServerException . unknown ( e ) ; } } }
Executes a method which has the potential to throw a TemporaryLockingException or a PermanentLockingException . If the exception is thrown it is wrapped in a GraknServerException so that the transaction can be retried .