@Test void testRetryContextWithoutTransaction() throws Throwable { TransactionSynchronizationManager.setActualTransactionActive(true); try { RdbmsRetryOperationsInterceptor operationsInterceptor = new RdbmsRetryOperationsInterceptor(); MethodInvocation methodInvocation = mock(MethodInvocation.class); assertThatThrownBy(() -> operationsInterceptor.invoke(methodInvocation)) .isInstanceOf(RetryException.class) .hasMessageContaining("An active transaction was found"); } finally { TransactionSynchronizationManager.setActualTransactionActive(false); } }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { Object result; if (!isRetryContextOperationActive()) { assertNoTransactionActive(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Starting a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } result = super.invoke(invocation); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Finished a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } } else { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Participating in existing retry operation"); } result = invocation.proceed(); } return result; }
RdbmsRetryOperationsInterceptor extends RetryOperationsInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable { Object result; if (!isRetryContextOperationActive()) { assertNoTransactionActive(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Starting a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } result = super.invoke(invocation); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Finished a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } } else { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Participating in existing retry operation"); } result = invocation.proceed(); } return result; } }
RdbmsRetryOperationsInterceptor extends RetryOperationsInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable { Object result; if (!isRetryContextOperationActive()) { assertNoTransactionActive(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Starting a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } result = super.invoke(invocation); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Finished a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } } else { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Participating in existing retry operation"); } result = invocation.proceed(); } return result; }  }
RdbmsRetryOperationsInterceptor extends RetryOperationsInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable { Object result; if (!isRetryContextOperationActive()) { assertNoTransactionActive(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Starting a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } result = super.invoke(invocation); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Finished a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } } else { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Participating in existing retry operation"); } result = invocation.proceed(); } return result; }  @Override Object invoke(MethodInvocation invocation); }
RdbmsRetryOperationsInterceptor extends RetryOperationsInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable { Object result; if (!isRetryContextOperationActive()) { assertNoTransactionActive(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Starting a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } result = super.invoke(invocation); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Finished a new Retry Interceptor for {}", (invocation != null ? invocation.getMethod() : null)); } } else { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Participating in existing retry operation"); } result = invocation.proceed(); } return result; }  @Override Object invoke(MethodInvocation invocation);  }