private Topic createCodeReviewWithLockHandling(Topic topic, TopicDto topicDto) throws NotFoundException { for (int i = 0; i < UserController.LOGIN_TRIES_AFTER_LOCK; i++) { try { return topicModificationService.createTopic(topic, topicDto.getBodyText()); } catch (HibernateOptimisticLockingFailureException e) { } } try { return topicModificationService.createTopic(topic, topicDto.getBodyText()); } catch (HibernateOptimisticLockingFailureException e) { LOGGER.error( "User has been optimistically locked and can't be reread {} times. Username: {}", UserController.LOGIN_TRIES_AFTER_LOCK, userService.getCurrentUser().getUsername()); throw e; } }