как можно оптимизировать метод @Override @Retryable( maxAttemptsExpression =…
- User
как можно оптимизировать метод @Override @Retryable( maxAttemptsExpression = "{application.tarantool.retryDelay}") ) public boolean personExistsByMdmCode(String mdmId, int requestType) { int attemptCount = RetrySynchronizationManager.getContext().getRetryCount(); try { List entities = handbookDao.findPerson(mdmId); if (requestType != CALCULATE.getValue() && entities.isEmpty()) { throw new TarantoolEntityNotFoundException("Person" + ENTITY_NOT_FOUND); } return !entities.isEmpty(); } catch (TarantoolEntityNotFoundException e) { log.error(RETRY_ATTEMPT_MESSAGE, attemptCount); if (attemptCount < tarantoolProperties.getRetryAttempts() - 1) { throw e; } else { return false; } } catch (Exception e) { log.error(RETRY_ATTEMPT_MESSAGE, attemptCount); throw new HandbookException(TARANTOOL_REQUEST_ERROR + e.getMessage()); } }
- Assistant
Оптимизация метода может быть выполнена несколькими способами. Основные аспекты, на которые стоит обратить внимание, включают улучшение обработки ошибок и уменьшение повторений в коде. Вот переработанная версия метода с некоторыми улучшениями: