Source:
<code>public Object proceedSave(ProceedingJoinPoint proceedingJoinPoint) { Collection<Object> entities = convertFirstArgToCollection(proceedingJoinPoint); for (Object entity : entities) { try { for (Field field : entity.getClass().getDeclaredFields()) { if (field.isAnnotationPresent(SecretValue.class)) { LOGGER.debug("Found SecretValue annotation on {}", field); field.setAccessible(true); Secret value = (Secret) field.get(entity); if (value != null && value.getRaw() != null && value.getSecret() == null) { String accountId = findAccountId(entity); String path = String.format("%s/%s/%s/%s-%s", accountId, entity.getClass().getSimpleName().toLowerCase(), field.getName().toLowerCase(), UUID.randomUUID().toString(), Long.toHexString(System.currentTimeMillis())); String secret = secretService.put(path, value.getRaw()); LOGGER.debug("Field: '{}' is saved at path: {}", field.getName(), path); field.set(entity, new SecretProxy(secretService, secret)); } } } } catch (IllegalArgumentException e) { <START> LOGGER.error("Given entity isn't instance of AccountIdAwareResource. Secret is not deleted!", e); <END> throw new SecretOperationException(e); } catch (Exception e) { LOGGER.warn("Looks like something went wrong with Secret store. Secret is not deleted!", e); throw new SecretOperationException(e); } } Object proceed; try { proceed = proceedingJoinPoint.proceed(); } catch (RuntimeException re) { LOGGER.warn("Failed to invoke repository save", re); throw re; } catch (Throwable throwable) { LOGGER.error("Failed to invoke repository save", throwable); throw new SecretOperationException(throwable); } return proceed; }</code><technical_language>Nit: replace hardwired class name AccountIdAwareResource.class.getSimpleName() a lines in findAccountId()</technical_language>

Target:
public Object proceedSave(ProceedingJoinPoint proceedingJoinPoint) { Collection<Object> entities = convertFirstArgToCollection(proceedingJoinPoint); for (Object entity : entities) { try { for (Field field : entity.getClass().getDeclaredFields()) { if (field.isAnnotationPresent(SecretValue.class)) { LOGGER.debug("Found SecretValue annotation on {}", field); field.setAccessible(true); Secret value = (Secret) field.get(entity); if (value != null && value.getRaw() != null && value.getSecret() == null) { String accountId = findAccountId(entity); String path = String.format("%s/%s/%s/%s-%s", accountId, entity.getClass().getSimpleName().toLowerCase(), field.getName().toLowerCase(), UUID.randomUUID().toString(), Long.toHexString(System.currentTimeMillis())); String secret = secretService.put(path, value.getRaw()); LOGGER.debug("Field: '{}' is saved at path: {}", field.getName(), path); field.set(entity, new SecretProxy(secretService, secret)); } } } } catch (IllegalArgumentException e) { LOGGER.error("Given entity isn't instance of {}. Secret is not updated!", AccountIdAwareResource.class.getSimpleName(), e); throw new SecretOperationException(e.getMessage()); } catch (Exception e) { LOGGER.warn("Looks like something went wrong with Secret store. Secret is not updated!", e); throw new SecretOperationException(e.getMessage()); } } Object proceed; try { proceed = proceedingJoinPoint.proceed(); } catch (RuntimeException re) { LOGGER.warn("Failed to invoke repository save", re); throw re; } catch (Throwable throwable) { LOGGER.error("Failed to invoke repository save", throwable); throw new SecretOperationException(throwable); } return proceed; }