Refactor the o.s.d.g.listener.StubErrorHandler class.

Implement java.lang.Iterable.

Resolves gh-296.
This commit is contained in:
John Blum
2021-07-21 13:21:14 -07:00
parent a9d8dfc33e
commit a584b4066c

View File

@@ -16,20 +16,30 @@
package org.springframework.data.gemfire.listener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.springframework.util.ErrorHandler;
/**
* Spring {@link ErrorHandler} for testing.
*
* @author Costin Leau
* @author John Blum
* @see org.springframework.util.ErrorHandler
*/
public class StubErrorHandler implements ErrorHandler {
public class StubErrorHandler implements ErrorHandler, Iterable<Throwable> {
public List<Throwable> throwables = new ArrayList<Throwable>();
public final List<Throwable> throwables = new ArrayList<>();
public void handleError(Throwable t) {
throwables.add(t);
@Override
public void handleError(Throwable throwable) {
this.throwables.add(throwable);
}
@Override
public Iterator<Throwable> iterator() {
return Collections.unmodifiableList(this.throwables).iterator();
}
}