use of teammates.common.util.retry.MaximumRetriesExceededException in project teammates by TEAMMATES.
the class DataMigrationForFeedbackResponseCommentSearchDocument method invokePutDocumentsWithRetry.
/**
* Reflects private static method {@link SearchManager#putDocumentsWithRetry}.
*
* @throws PutException when only non-transient errors are encountered.
* @throws MaximumRetriesExceededException with list of failed {@link Document}s as final data and
* final {@link com.google.appengine.api.search.OperationResult}'s message as final message,
* if operation fails after maximum retries.
*/
private static void invokePutDocumentsWithRetry(String indexName, List<Document> documents) throws PutException, MaximumRetriesExceededException {
try {
Method method = SearchManager.class.getDeclaredMethod("putDocumentsWithRetry", String.class, List.class);
method.setAccessible(true);
method.invoke(null, indexName, documents);
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
Throwable originalException = e.getCause();
if (originalException instanceof PutException) {
throw (PutException) originalException;
} else if (originalException instanceof MaximumRetriesExceededException) {
throw (MaximumRetriesExceededException) originalException;
} else {
throw new RuntimeException(e);
}
}
}
Aggregations