Rename DEFAULT class member constant to DEFAULT_EVENT_ERROR_HANDLER.

Edit Javadoc.

Resolves gh-58.
This commit is contained in:
John Blum
2020-08-19 12:41:19 -07:00
parent 72812055a6
commit 01ebfadcbe
2 changed files with 11 additions and 8 deletions

View File

@@ -47,9 +47,9 @@ import org.springframework.util.Assert;
*/ */
public class RepositoryAsyncEventListener<T, ID> implements AsyncEventListener { public class RepositoryAsyncEventListener<T, ID> implements AsyncEventListener {
protected static final AsyncEventErrorHandler DEFAULT = eventError -> false; protected static final AsyncEventErrorHandler DEFAULT_EVENT_ERROR_HANDLER = eventError -> false;
private AsyncEventErrorHandler asyncEventErrorHandler = DEFAULT; private AsyncEventErrorHandler asyncEventErrorHandler = DEFAULT_EVENT_ERROR_HANDLER;
private final CrudRepository<T, ID> repository; private final CrudRepository<T, ID> repository;
@@ -96,19 +96,21 @@ public class RepositoryAsyncEventListener<T, ID> implements AsyncEventListener {
* Gets the configured {@link AsyncEventErrorHandler} used to handle errors that may occur when this listener * Gets the configured {@link AsyncEventErrorHandler} used to handle errors that may occur when this listener
* is invoked with a batch of {@link AsyncEvent AsyncEvents}. * is invoked with a batch of {@link AsyncEvent AsyncEvents}.
* *
* Defaults to an {@link AsyncEventErrorHandler} that always returns {@literal false} on any error.
*
* @return the configured {@link AsyncEventErrorHandler}; never {@literal null}. * @return the configured {@link AsyncEventErrorHandler}; never {@literal null}.
* @see AsyncEventErrorHandler * @see AsyncEventErrorHandler
*/ */
protected @NonNull AsyncEventErrorHandler getAsyncEventErrorHandler() { protected @NonNull AsyncEventErrorHandler getAsyncEventErrorHandler() {
return this.asyncEventErrorHandler != null ? this.asyncEventErrorHandler : DEFAULT; return this.asyncEventErrorHandler != null ? this.asyncEventErrorHandler : DEFAULT_EVENT_ERROR_HANDLER;
} }
/** /**
* Gets a reference to the configured Spring Data {@link CrudRepository} used by this {@link AsyncEventListener} * Gets a reference to the configured Spring Data {@link CrudRepository} used by this {@link AsyncEventListener}
* to perform data access operations to a backend, external data source asynchronously when triggered by a cache * to perform data access operations to a external, backend data source asynchronously when triggered by a cache
* operation. * operation.
* *
* @return a reference to the configured Spring Data {@link CrudRepository}. * @return a reference to the configured Spring Data {@link CrudRepository}; never {@literal null}.
* @see org.springframework.data.repository.CrudRepository * @see org.springframework.data.repository.CrudRepository
*/ */
protected @NonNull CrudRepository<T, ID> getRepository() { protected @NonNull CrudRepository<T, ID> getRepository() {
@@ -134,7 +136,8 @@ public class RepositoryAsyncEventListener<T, ID> implements AsyncEventListener {
* corresponding to the {@link AsyncEvent} {@link Operation}. * corresponding to the {@link AsyncEvent} {@link Operation}.
* *
* @param events {@link List} of {@link AsyncEvent AsyncEvents} to process. * @param events {@link List} of {@link AsyncEvent AsyncEvents} to process.
* @return a boolean value indicating whether all {@link AsyncEvent AsyncEvents} were processes successfully. * @return a boolean value indicating whether all {@link AsyncEvent AsyncEvents} were processed successfully
* by this listener.
* If any {@link AsyncEvent} fails to be processed (just one), then this method will return {@literal false}. * If any {@link AsyncEvent} fails to be processed (just one), then this method will return {@literal false}.
* If any {@link AsyncEvent} cannot be handled, then this method will return {@literal false}, even if other * If any {@link AsyncEvent} cannot be handled, then this method will return {@literal false}, even if other
* {@link AsyncEvent AsyncEvents} were successfully processed. * {@link AsyncEvent AsyncEvents} were successfully processed.

View File

@@ -103,7 +103,7 @@ public class RepositoryAsyncEventListenerUnitTests {
RepositoryAsyncEventListener<?, ?> listener = new RepositoryAsyncEventListener<>(mockRepository); RepositoryAsyncEventListener<?, ?> listener = new RepositoryAsyncEventListener<>(mockRepository);
assertThat(listener.getAsyncEventErrorHandler()).isEqualTo(RepositoryAsyncEventListener.DEFAULT); assertThat(listener.getAsyncEventErrorHandler()).isEqualTo(RepositoryAsyncEventListener.DEFAULT_EVENT_ERROR_HANDLER);
listener.setAsyncEventErrorHandler(mockAsyncEventErrorHandler); listener.setAsyncEventErrorHandler(mockAsyncEventErrorHandler);
@@ -111,7 +111,7 @@ public class RepositoryAsyncEventListenerUnitTests {
listener.setAsyncEventErrorHandler(null); listener.setAsyncEventErrorHandler(null);
assertThat(listener.getAsyncEventErrorHandler()).isEqualTo(RepositoryAsyncEventListener.DEFAULT); assertThat(listener.getAsyncEventErrorHandler()).isEqualTo(RepositoryAsyncEventListener.DEFAULT_EVENT_ERROR_HANDLER);
verifyNoInteractions(mockAsyncEventErrorHandler, mockRepository); verifyNoInteractions(mockAsyncEventErrorHandler, mockRepository);
} }