Do not catch throwable
Today throughout the codebase, catch throwable is used with reckless abandon. This is dangerous because the throwable could be a fatal virtual machine error resulting from an internal error in the JVM, or an out of memory error or a stack overflow error that leaves the virtual machine in an unstable and unpredictable state. This commit removes catch throwable from the codebase and removes the temptation to use it by modifying listener APIs to receive instances of Exception instead of the top-level Throwable. Relates elastic/elasticsearch#2694 Original commit: elastic/x-pack-elasticsearch@7ecdd7d978
This commit is contained in:
parent
29cf28bbde
commit
1cd53c41e2
|
@ -165,14 +165,15 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
public void testScriptConditionThrowException() throws Exception {
|
||||
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
|
||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(
|
||||
new ScriptCondition(Script.inline("assert false").build()), logger, scriptService);
|
||||
new ScriptCondition(Script.inline("null.foo").build()), logger, scriptService);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
|
||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||
ScriptCondition.Result result = condition.execute(ctx);
|
||||
assertThat(result, notNullValue());
|
||||
assertThat(result.status(), is(Condition.Result.Status.FAILURE));
|
||||
assertThat(result.reason(), notNullValue());
|
||||
assertThat(result.reason(), containsString("Assertion"));
|
||||
assertThat(result.reason(), containsString("NullPointerException"));
|
||||
assertThat(result.reason(), containsString("Cannot get property 'foo' on null object"));
|
||||
}
|
||||
|
||||
public void testScriptConditionReturnObject() throws Exception {
|
||||
|
|
|
@ -509,7 +509,7 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
@ -711,13 +711,13 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
logger.error("unable to execute the graph query", t);
|
||||
listener.onFailure(t);
|
||||
} catch (Exception e) {
|
||||
logger.error("unable to execute the graph query", e);
|
||||
listener.onFailure(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -270,11 +270,10 @@ public class GraphTests extends ESSingleNodeTestCase {
|
|||
try {
|
||||
GraphExploreResponse response = grb.get();
|
||||
if (response.getShardFailures().length > 0) {
|
||||
throw ((ShardSearchFailure) response.getShardFailures()[0]).getCause();
|
||||
expectedError = response.getShardFailures()[0].getCause();
|
||||
}
|
||||
} catch (Throwable rte) {
|
||||
} catch (Exception rte) {
|
||||
expectedError = rte;
|
||||
|
||||
}
|
||||
assertNotNull(expectedError);
|
||||
String message = expectedError.toString();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class TransportDeleteLicenseAction extends TransportMasterNodeAction<Dele
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -61,7 +61,7 @@ public class TransportPutLicenseAction extends TransportMasterNodeAction<PutLice
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -427,8 +427,8 @@ public class LicensesService extends AbstractLifecycleComponent implements Clust
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String source, @Nullable Throwable t) {
|
||||
logger.error("unexpected failure during [{}]", t, source);
|
||||
public void onFailure(String source, @Nullable Exception e) {
|
||||
logger.error("unexpected failure during [{}]", e, source);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -88,8 +88,8 @@ public abstract class AbstractLicensesIntegrationTestCase extends ESIntegTestCas
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String source, @Nullable Throwable t) {
|
||||
logger.error("error on metaData cleanup after test", t);
|
||||
public void onFailure(String source, @Nullable Exception e) {
|
||||
logger.error("error on metaData cleanup after test", e);
|
||||
}
|
||||
});
|
||||
latch.await();
|
||||
|
|
|
@ -146,7 +146,7 @@ public class TestUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -157,7 +157,7 @@ public class LicensesAcknowledgementTests extends ESSingleNodeTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ public class LicensesManagerServiceTests extends ESSingleNodeTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -84,7 +84,7 @@ public class MonitoringBulkResponse extends ActionResponse {
|
|||
}
|
||||
|
||||
Error(StreamInput in) throws IOException {
|
||||
this(in.<Throwable>readThrowable());
|
||||
this(in.readException());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -114,8 +114,8 @@ public class TransportMonitoringBulkAction extends HandledTransportAction<Monito
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
listener.onResponse(new MonitoringBulkResponse(buildTookInMillis(startTimeNanos), new MonitoringBulkResponse.Error(t)));
|
||||
public void onFailure(Exception e) {
|
||||
listener.onResponse(new MonitoringBulkResponse(buildTookInMillis(startTimeNanos), new MonitoringBulkResponse.Error(e)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -204,8 +204,8 @@ public class AgentService extends AbstractLifecycleComponent {
|
|||
} catch (InterruptedException e) {
|
||||
logger.trace("interrupted");
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (Throwable t) {
|
||||
logger.error("background thread had an uncaught exception", t);
|
||||
} catch (Exception e) {
|
||||
logger.error("background thread had an uncaught exception", e);
|
||||
}
|
||||
}
|
||||
logger.debug("worker shutdown");
|
||||
|
|
|
@ -59,9 +59,6 @@ import java.util.Map;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class HttpExporter extends Exporter {
|
||||
|
||||
public static final String TYPE = "http";
|
||||
|
@ -664,9 +661,9 @@ public class HttpExporter extends Exporter {
|
|||
}
|
||||
} catch (InterruptedException e) {
|
||||
// ignore, if closed, good....
|
||||
} catch (Throwable t) {
|
||||
} catch (Exception e) {
|
||||
logger.debug("error in keep alive thread, shutting down (will be restarted after a successful connection has been " +
|
||||
"made) {}", ExceptionsHelper.detailedMessage(t));
|
||||
"made) {}", ExceptionsHelper.detailedMessage(e));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -211,8 +211,8 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
logger.error("failed to update monitoring index template [{}]", throwable, template);
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("failed to update monitoring index template [{}]", e, template);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("failed to delete indices", e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -179,8 +179,8 @@ public class CleanerService extends AbstractLifecycleComponent {
|
|||
for (Listener listener : listeners) {
|
||||
try {
|
||||
listener.onCleanUpIndices(retention);
|
||||
} catch (Throwable t) {
|
||||
logger.error("listener failed to clean indices", t);
|
||||
} catch (Exception e) {
|
||||
logger.error("listener failed to clean indices", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,8 +209,8 @@ public class CleanerService extends AbstractLifecycleComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
logger.error("failed to clean indices", t);
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("failed to clean indices", e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,9 +81,9 @@ public class MonitoringBulkTests extends MonitoringIntegTestCase {
|
|||
|
||||
threads[i] = new Thread(new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
logger.error("unexpected error in exporting thread", t);
|
||||
exceptions.add(t);
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("unexpected error in exporting thread", e);
|
||||
exceptions.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -152,8 +152,8 @@ public class TransportMonitoringBulkActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String source, Throwable t) {
|
||||
fail("unexpected exception: " + t);
|
||||
public void onFailure(String source, Exception e) {
|
||||
fail("unexpected exception: " + e);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -296,9 +296,9 @@ public class ExportersTests extends ESTestCase {
|
|||
logger.debug("--> exporting thread [{}] exports {} documents", threadNum, threadDocs);
|
||||
threads[i] = new Thread(new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
logger.error("unexpected error in exporting thread", t);
|
||||
exceptions.add(t);
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("unexpected error in exporting thread", e);
|
||||
exceptions.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,7 +76,7 @@ public class SecurityLifecycleService extends AbstractComponent implements Clust
|
|||
if (nativeUserStore.canStart(event.state(), master)) {
|
||||
threadPool.generic().execute(new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
logger.error("failed to start native user store service", throwable);
|
||||
assert false : "security lifecycle services startup failed";
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class SecurityLifecycleService extends AbstractComponent implements Clust
|
|||
if (nativeRolesStore.canStart(event.state(), master)) {
|
||||
threadPool.generic().execute(new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
logger.error("failed to start native roles store services", throwable);
|
||||
assert false : "security lifecycle services startup failed";
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class SecurityLifecycleService extends AbstractComponent implements Clust
|
|||
threadPool.generic().execute(new AbstractRunnable() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
logger.error("failed to start index audit trail services", throwable);
|
||||
assert false : "security lifecycle services startup failed";
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ public class SecurityTemplateService extends AbstractComponent implements Cluste
|
|||
if (createTemplate && templateCreationPending.compareAndSet(false, true)) {
|
||||
threadPool.generic().execute(new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
logger.warn("failed to create security index template", t);
|
||||
public void onFailure(Exception e) {
|
||||
logger.warn("failed to create security index template", e);
|
||||
templateCreationPending.set(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,6 @@ import java.util.function.Predicate;
|
|||
|
||||
import static org.elasticsearch.xpack.security.support.Exceptions.authorizationError;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class SecurityActionFilter extends AbstractComponent implements ActionFilter {
|
||||
|
||||
private static final Predicate<String> LICENSE_EXPIRATION_ACTION_MATCHER = HealthAndStatsPrivilege.INSTANCE.predicate();
|
||||
|
@ -109,8 +106,8 @@ public class SecurityActionFilter extends AbstractComponent implements ActionFil
|
|||
} else {
|
||||
chain.proceed(task, action, request, listener);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
listener.onFailure(t);
|
||||
} catch (Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +228,7 @@ public class SecurityActionFilter extends AbstractComponent implements ActionFil
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
if (threadContext != null) {
|
||||
threadContext.restore();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TransportDeleteRoleAction extends HandledTransportAction<DeleteRole
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
listener.onFailure(t);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -77,7 +77,7 @@ public class TransportGetRolesAction extends HandledTransportAction<GetRolesRequ
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
logger.error("failed to retrieve role [{}]", t, rolename);
|
||||
listener.onFailure(t);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class TransportGetRolesAction extends HandledTransportAction<GetRolesRequ
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
logger.error("failed to retrieve role [{}]", t,
|
||||
Strings.arrayToDelimitedString(request.names(), ","));
|
||||
listener.onFailure(t);
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TransportPutRoleAction extends HandledTransportAction<PutRoleReques
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
listener.onFailure(t);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore;
|
||||
import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm;
|
||||
import org.elasticsearch.xpack.security.user.AnonymousUser;
|
||||
import org.elasticsearch.xpack.security.user.SystemUser;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -50,7 +49,7 @@ public class TransportChangePasswordAction extends HandledTransportAction<Change
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -54,7 +54,7 @@ public class TransportDeleteUserAction extends HandledTransportAction<DeleteUser
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -78,7 +78,7 @@ public class TransportGetUsersAction extends HandledTransportAction<GetUsersRequ
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("failed to retrieve user [{}]", e, username);
|
||||
listener.onFailure(e);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class TransportGetUsersAction extends HandledTransportAction<GetUsersRequ
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("failed to retrieve user [{}]", e,
|
||||
Strings.arrayToDelimitedString(request.usernames(), ","));
|
||||
listener.onFailure(e);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class TransportPutUserAction extends HandledTransportAction<PutUserReques
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("failed to put user [{}]", e, request.username());
|
||||
listener.onFailure(e);
|
||||
}
|
||||
|
|
|
@ -886,7 +886,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
|
|||
INDEX_TEMPLATE_NAME);
|
||||
threadPool.generic().execute(new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
logger.error("failed to update security audit index template [{}]", throwable, INDEX_TEMPLATE_NAME);
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
if (t instanceof IndexNotFoundException) {
|
||||
logger.trace("failed to retrieve user [{}] since security index does not exist", username);
|
||||
// We don't invoke the onFailure listener here, instead
|
||||
|
@ -228,7 +228,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
// attempt to clear scroll response
|
||||
if (lastResponse != null && lastResponse.getScrollId() != null) {
|
||||
clearScrollResponse(lastResponse.getScrollId());
|
||||
|
@ -260,7 +260,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
if (t instanceof IndexNotFoundException) {
|
||||
logger.trace("failed to retrieve user [{}] since security index does not exist", t, username);
|
||||
} else {
|
||||
|
@ -287,7 +287,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
if (t instanceof IndexNotFoundException) {
|
||||
logger.trace("could not retrieve user [{}] because security index does not exist", t, user);
|
||||
} else {
|
||||
|
@ -334,7 +334,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
Throwable cause = e;
|
||||
if (e instanceof ElasticsearchException) {
|
||||
cause = ExceptionsHelper.unwrapCause(e);
|
||||
|
@ -368,7 +368,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
@ -410,7 +410,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
Throwable cause = e;
|
||||
if (e instanceof ElasticsearchException) {
|
||||
cause = ExceptionsHelper.unwrapCause(e);
|
||||
|
@ -455,7 +455,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
@ -479,7 +479,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
@ -550,9 +550,9 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
if (state.compareAndSet(State.STARTED, State.STOPPING)) {
|
||||
try {
|
||||
userPoller.stop();
|
||||
} catch (Throwable t) {
|
||||
} catch (Exception e) {
|
||||
state.set(State.FAILED);
|
||||
throw t;
|
||||
throw e;
|
||||
} finally {
|
||||
state.set(State.STOPPED);
|
||||
}
|
||||
|
@ -594,10 +594,10 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
return securityIndexExists;
|
||||
}
|
||||
|
||||
char[] reservedUserPassword(String username) throws Throwable {
|
||||
char[] reservedUserPassword(String username) throws Exception {
|
||||
assert started();
|
||||
final AtomicReference<char[]> passwordHash = new AtomicReference<>();
|
||||
final AtomicReference<Throwable> failure = new AtomicReference<>();
|
||||
final AtomicReference<Exception> failure = new AtomicReference<>();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
client.prepareGet(SecurityTemplateService.SECURITY_INDEX_NAME, RESERVED_USER_DOC_TYPE, username)
|
||||
.execute(new LatchedActionListener<>(new ActionListener<GetResponse>() {
|
||||
|
@ -615,7 +615,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
if (e instanceof IndexNotFoundException) {
|
||||
logger.trace("could not retrieve built in user [{}] password since security index does not exist", e, username);
|
||||
} else {
|
||||
|
@ -634,7 +634,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
failure.set(e);
|
||||
}
|
||||
|
||||
Throwable failureCause = failure.get();
|
||||
Exception failureCause = failure.get();
|
||||
if (failureCause != null) {
|
||||
// if there is any sort of failure we need to throw an exception to prevent the fallback to the default password...
|
||||
throw failureCause;
|
||||
|
@ -651,7 +651,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
// Not really much to do here except for warn about it...
|
||||
logger.warn("failed to clear scroll [{}]", t, scrollId);
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("unable to clear realm cache for user [{}]", e, username);
|
||||
ElasticsearchException exception = new ElasticsearchException("clearing the cache for [" + username
|
||||
+ "] failed. please clear the realm cache manually", e);
|
||||
|
@ -838,21 +838,22 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
}
|
||||
|
||||
// call listeners
|
||||
Throwable th = null;
|
||||
RuntimeException ex = null;
|
||||
for (ChangeListener listener : listeners) {
|
||||
try {
|
||||
listener.onUsersChanged(changedUsers);
|
||||
} catch (Throwable t) {
|
||||
th = ExceptionsHelper.useOrSuppress(th, t);
|
||||
} catch (Exception e) {
|
||||
if (ex == null) ex = new RuntimeException("exception while notifying listeners");
|
||||
ex.addSuppressed(e);
|
||||
}
|
||||
}
|
||||
|
||||
ExceptionsHelper.reThrowIfNotNull(th);
|
||||
if (ex != null) throw ex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
logger.error("error occurred while checking the native users for changes", t);
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("error occurred while checking the native users for changes", e);
|
||||
}
|
||||
|
||||
private boolean isStopped() {
|
||||
|
|
|
@ -131,7 +131,7 @@ public class ReservedRealm extends CachingUsernamePasswordRealm {
|
|||
return DEFAULT_PASSWORD_HASH;
|
||||
}
|
||||
return passwordHash;
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to retrieve password hash for reserved user [{}]", e, username);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -37,9 +37,6 @@ import static java.util.Collections.emptyMap;
|
|||
import static java.util.Collections.unmodifiableMap;
|
||||
import static org.elasticsearch.xpack.security.support.SecurityFiles.openAtomicMoveWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class FileUserPasswdStore {
|
||||
|
||||
private final ESLogger logger;
|
||||
|
@ -111,8 +108,8 @@ public class FileUserPasswdStore {
|
|||
static Map<String, char[]> parseFileLenient(Path path, ESLogger logger) {
|
||||
try {
|
||||
return parseFile(path, logger);
|
||||
} catch (Throwable t) {
|
||||
logger.error("failed to parse users file [{}]. skipping/removing all users...", t, path.toAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to parse users file [{}]. skipping/removing all users...", e, path.toAbsolutePath());
|
||||
return emptyMap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,9 +37,6 @@ import static java.util.Collections.emptyMap;
|
|||
import static java.util.Collections.unmodifiableMap;
|
||||
import static org.elasticsearch.xpack.security.support.SecurityFiles.openAtomicMoveWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class FileUserRolesStore {
|
||||
|
||||
private static final Pattern USERS_DELIM = Pattern.compile("\\s*,\\s*");
|
||||
|
@ -103,8 +100,8 @@ public class FileUserRolesStore {
|
|||
static Map<String, String[]> parseFileLenient(Path path, ESLogger logger) {
|
||||
try {
|
||||
return parseFile(path, logger);
|
||||
} catch (Throwable t) {
|
||||
logger.error("failed to parse users_roles file [{}]. skipping/removing all entries...", t, path.toAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to parse users_roles file [{}]. skipping/removing all entries...", e, path.toAbsolutePath());
|
||||
return emptyMap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ public class DnRoleMapper {
|
|||
public static Map<DN, Set<String>> parseFileLenient(Path path, ESLogger logger, String realmType, String realmName) {
|
||||
try {
|
||||
return parseFile(path, logger, realmType, realmName);
|
||||
} catch (Throwable t) {
|
||||
logger.error("failed to parse role mappings file [{}]. skipping/removing all mappings...", t, path.toAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to parse role mappings file [{}]. skipping/removing all mappings...", e, path.toAbsolutePath());
|
||||
return emptyMap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,6 @@ import static java.util.Collections.emptySet;
|
|||
import static java.util.Collections.unmodifiableMap;
|
||||
import static org.elasticsearch.xpack.security.Security.setting;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class FileRolesStore extends AbstractLifecycleComponent implements RolesStore {
|
||||
|
||||
public static final Setting<String> ROLES_FILE_SETTING =
|
||||
|
@ -288,8 +285,8 @@ public class FileRolesStore extends AbstractLifecycleComponent implements RolesS
|
|||
try {
|
||||
permissions = parseFile(file, logger, settings);
|
||||
logger.info("updated roles (roles file [{}] changed)", file.toAbsolutePath());
|
||||
} catch (Throwable t) {
|
||||
logger.error("could not reload roles file [{}]. Current roles remain unmodified", t, file.toAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
logger.error("could not reload roles file [{}]. Current roles remain unmodified", e, file.toAbsolutePath());
|
||||
return;
|
||||
}
|
||||
listener.onRefresh();
|
||||
|
|
|
@ -231,7 +231,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
// attempt to clear the scroll request
|
||||
if (lastResponse != null && lastResponse.getScrollId() != null) {
|
||||
clearScollRequest(lastResponse.getScrollId());
|
||||
|
@ -277,7 +277,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("failed to delete role from the index", e);
|
||||
listener.onFailure(e);
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("failed to put role [{}]", e, request.name());
|
||||
listener.onFailure(e);
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
if (t instanceof IndexNotFoundException) {
|
||||
logger.trace("failed to retrieve role [{}] since security index does not exist", t, roleId);
|
||||
} else {
|
||||
|
@ -403,7 +403,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(Exception t) {
|
||||
// Not really much to do here except for warn about it...
|
||||
logger.warn("failed to clear scroll [{}] after retrieving roles", t, scrollId);
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("unable to clear cache for role [{}]", e, role);
|
||||
ElasticsearchException exception = new ElasticsearchException("clearing the cache for [" + role
|
||||
+ "] failed. please clear the role cache manually", e);
|
||||
|
@ -568,8 +568,8 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
logger.error("error occurred while checking the native roles for changes", t);
|
||||
public void onFailure(Exception e) {
|
||||
logger.error("error occurred while checking the native roles for changes", e);
|
||||
}
|
||||
|
||||
private boolean isStopped() {
|
||||
|
|
|
@ -12,13 +12,12 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Setting.Property;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.xpack.security.authc.support.CharArrays;
|
||||
import org.elasticsearch.watcher.FileChangesListener;
|
||||
import org.elasticsearch.watcher.FileWatcher;
|
||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.security.authc.support.CharArrays;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
|
@ -28,6 +27,7 @@ import javax.crypto.Mac;
|
|||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -45,12 +45,9 @@ import java.util.Objects;
|
|||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.elasticsearch.xpack.security.authc.support.SecuredString.constantTimeEquals;
|
||||
import static org.elasticsearch.xpack.security.Security.setting;
|
||||
import static org.elasticsearch.xpack.security.authc.support.SecuredString.constantTimeEquals;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class InternalCryptoService extends AbstractLifecycleComponent implements CryptoService {
|
||||
|
||||
public static final String KEY_ALGO = "HmacSHA512";
|
||||
|
@ -232,8 +229,8 @@ public class InternalCryptoService extends AbstractLifecycleComponent implements
|
|||
base64RandomKey = pieces[2];
|
||||
receivedSignature = pieces[3].substring(0, length);
|
||||
text = pieces[3].substring(length);
|
||||
} catch (Throwable t) {
|
||||
logger.error("error occurred while parsing signed text", t);
|
||||
} catch (Exception e) {
|
||||
logger.error("error occurred while parsing signed text", e);
|
||||
throw new IllegalArgumentException("tampered signed text");
|
||||
}
|
||||
|
||||
|
@ -270,8 +267,8 @@ public class InternalCryptoService extends AbstractLifecycleComponent implements
|
|||
if (constantTimeEquals(sig, receivedSignature)) {
|
||||
return text;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error("error occurred while verifying signed text", t);
|
||||
} catch (Exception e) {
|
||||
logger.error("error occurred while verifying signed text", e);
|
||||
throw new IllegalStateException("error while verifying the signed text");
|
||||
}
|
||||
|
||||
|
@ -543,29 +540,20 @@ public class InternalCryptoService extends AbstractLifecycleComponent implements
|
|||
}
|
||||
|
||||
private void callListeners(SecretKey oldSystemKey, SecretKey oldEncryptionKey) {
|
||||
Throwable th = null;
|
||||
RuntimeException ex = null;
|
||||
for (Listener listener : listeners) {
|
||||
try {
|
||||
listener.onKeyChange(oldSystemKey, oldEncryptionKey);
|
||||
} catch (Throwable t) {
|
||||
if (th == null) {
|
||||
th = t;
|
||||
} else {
|
||||
th.addSuppressed(t);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (ex == null) ex = new RuntimeException("exception calling key change listeners");
|
||||
ex.addSuppressed(e);
|
||||
}
|
||||
}
|
||||
|
||||
// all listeners were notified now rethrow
|
||||
if (th != null) {
|
||||
logger.error("called all key change listeners but one or more exceptions was thrown", th);
|
||||
if (th instanceof RuntimeException) {
|
||||
throw (RuntimeException) th;
|
||||
} else if (th instanceof Error) {
|
||||
throw (Error) th;
|
||||
} else {
|
||||
throw new RuntimeException(th);
|
||||
}
|
||||
if (ex != null) {
|
||||
logger.error("called all key change listeners but one or more exceptions was thrown", ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,8 +123,8 @@ public abstract class AbstractSSLService extends AbstractComponent {
|
|||
sslEngine.setEnabledCipherSuites(supportedCiphers(sslEngine.getSupportedCipherSuites(), ciphers, false));
|
||||
} catch (ElasticsearchException e) {
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
throw new IllegalArgumentException("failed loading cipher suites [" + Arrays.asList(ciphers) + "]", t);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("failed loading cipher suites [" + Arrays.asList(ciphers) + "]", e);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -49,8 +49,8 @@ public class SelfReschedulingRunnable extends AbstractRunnable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
logger.warn("failed to run scheduled task", t);
|
||||
public void onFailure(Exception e) {
|
||||
logger.warn("failed to run scheduled task", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,8 +34,8 @@ public class SecurityClientTransportService extends TransportService {
|
|||
try {
|
||||
clientFilter.outbound(action, request);
|
||||
super.sendRequest(node, action, request, options, handler);
|
||||
} catch (Throwable t) {
|
||||
handler.handleException(new TransportException("failed sending request", t));
|
||||
} catch (Exception e) {
|
||||
handler.handleException(new TransportException("failed sending request", e));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,6 @@ import static org.elasticsearch.xpack.security.transport.netty.SecurityNettyTran
|
|||
import static org.elasticsearch.xpack.security.transport.netty.SecurityNettyTransport.PROFILE_CLIENT_AUTH_SETTING;
|
||||
import static org.elasticsearch.xpack.security.transport.netty.SecurityNettyTransport.SSL_SETTING;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class SecurityServerTransportService extends TransportService {
|
||||
|
||||
public static final String SETTING_NAME = "xpack.security.type";
|
||||
|
@ -81,16 +78,16 @@ public class SecurityServerTransportService extends TransportService {
|
|||
try {
|
||||
clientFilter.outbound(action, request);
|
||||
super.sendRequest(node, action, request, options, new ContextRestoreResponseHandler<>(original, handler));
|
||||
} catch (Throwable t) {
|
||||
handler.handleException(new TransportException("failed sending request", t));
|
||||
} catch (Exception e) {
|
||||
handler.handleException(new TransportException("failed sending request", e));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
clientFilter.outbound(action, request);
|
||||
super.sendRequest(node, action, request, options, handler);
|
||||
} catch (Throwable t) {
|
||||
handler.handleException(new TransportException("failed sending request", t));
|
||||
} catch (Exception e) {
|
||||
handler.handleException(new TransportException("failed sending request", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,8 +191,8 @@ public class SecurityServerTransportService extends TransportService {
|
|||
RequestContext context = new RequestContext(request, threadContext);
|
||||
RequestContext.setCurrent(context);
|
||||
handler.messageReceived(request, channel, task);
|
||||
} catch (Throwable t) {
|
||||
channel.sendResponse(t);
|
||||
} catch (Exception e) {
|
||||
channel.sendResponse(e);
|
||||
} finally {
|
||||
RequestContext.removeCurrent();
|
||||
}
|
||||
|
|
|
@ -26,14 +26,12 @@ import org.jboss.netty.channel.ChannelHandlerContext;
|
|||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelPipelineFactory;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelHandler;
|
||||
import org.jboss.netty.handler.ssl.SslHandler;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLParameters;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.xpack.security.Security.featureEnabledSetting;
|
||||
|
@ -113,7 +111,7 @@ public class SecurityNettyTransport extends NettyTransport {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Channel channel, Throwable e) {
|
||||
protected void onException(Channel channel, Exception e) {
|
||||
if (isNotSslRecordException(e)) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("received plaintext traffic on a encrypted channel, closing connection {}", e, channel);
|
||||
|
|
|
@ -146,7 +146,7 @@ public class ClearRealmsCacheTests extends SecurityIntegTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
error.set(e);
|
||||
latch.countDown();
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class TransportDeleteRoleActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -96,7 +96,7 @@ public class TransportDeleteRoleActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -108,7 +108,7 @@ public class TransportDeleteRoleActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testException() {
|
||||
final Throwable t = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException());
|
||||
final Exception e = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException());
|
||||
final String roleName = randomFrom("admin", "dept_a", "restricted");
|
||||
NativeRolesStore rolesStore = mock(NativeRolesStore.class);
|
||||
TransportDeleteRoleAction action = new TransportDeleteRoleAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class),
|
||||
|
@ -124,7 +124,7 @@ public class TransportDeleteRoleActionTests extends ESTestCase {
|
|||
Object[] args = invocation.getArguments();
|
||||
assert args.length == 2;
|
||||
ActionListener<Boolean> listener = (ActionListener<Boolean>) args[1];
|
||||
listener.onFailure(t);
|
||||
listener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
}).when(rolesStore).deleteRole(eq(request), any(ActionListener.class));
|
||||
|
@ -138,14 +138,14 @@ public class TransportDeleteRoleActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(responseRef.get(), is(nullValue()));
|
||||
assertThat(throwableRef.get(), is(notNullValue()));
|
||||
assertThat(throwableRef.get(), is(sameInstance(t)));
|
||||
assertThat(throwableRef.get(), is(sameInstance(e)));
|
||||
verify(rolesStore, times(1)).deleteRole(eq(request), any(ActionListener.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class TransportGetRolesActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -158,7 +158,7 @@ public class TransportGetRolesActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -251,7 +251,7 @@ public class TransportGetRolesActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -273,7 +273,7 @@ public class TransportGetRolesActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testException() {
|
||||
final Throwable t = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException());
|
||||
final Exception e = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException());
|
||||
final List<RoleDescriptor> storeRoleDescriptors = randomRoleDescriptors();
|
||||
NativeRolesStore rolesStore = mock(NativeRolesStore.class);
|
||||
SecurityContext context = mock(SecurityContext.class);
|
||||
|
@ -290,7 +290,7 @@ public class TransportGetRolesActionTests extends ESTestCase {
|
|||
Object[] args = invocation.getArguments();
|
||||
assert args.length == 2;
|
||||
ActionListener<RoleDescriptor> listener = (ActionListener<RoleDescriptor>) args[1];
|
||||
listener.onFailure(t);
|
||||
listener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
}).when(rolesStore).getRoleDescriptor(eq(request.names()[0]), any(ActionListener.class));
|
||||
|
@ -301,7 +301,7 @@ public class TransportGetRolesActionTests extends ESTestCase {
|
|||
Object[] args = invocation.getArguments();
|
||||
assert args.length == 2;
|
||||
ActionListener<List<RoleDescriptor>> listener = (ActionListener<List<RoleDescriptor>>) args[1];
|
||||
listener.onFailure(t);
|
||||
listener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
}).when(rolesStore).getRoleDescriptors(aryEq(request.names()), any(ActionListener.class));
|
||||
|
@ -316,13 +316,13 @@ public class TransportGetRolesActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(throwableRef.get(), is(notNullValue()));
|
||||
assertThat(throwableRef.get(), is(t));
|
||||
assertThat(throwableRef.get(), is(e));
|
||||
assertThat(responseRef.get(), is(nullValue()));
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class TransportPutRoleActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -97,7 +97,7 @@ public class TransportPutRoleActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -109,7 +109,7 @@ public class TransportPutRoleActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testException() {
|
||||
final Throwable t = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException());
|
||||
final Exception e = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException());
|
||||
final String roleName = randomFrom("admin", "dept_a", "restricted");
|
||||
NativeRolesStore rolesStore = mock(NativeRolesStore.class);
|
||||
TransportPutRoleAction action = new TransportPutRoleAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class),
|
||||
|
@ -124,7 +124,7 @@ public class TransportPutRoleActionTests extends ESTestCase {
|
|||
Object[] args = invocation.getArguments();
|
||||
assert args.length == 3;
|
||||
ActionListener<Boolean> listener = (ActionListener<Boolean>) args[2];
|
||||
listener.onFailure(t);
|
||||
listener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
}).when(rolesStore).putRole(eq(request), any(RoleDescriptor.class), any(ActionListener.class));
|
||||
|
@ -138,14 +138,14 @@ public class TransportPutRoleActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(responseRef.get(), is(nullValue()));
|
||||
assertThat(throwableRef.get(), is(notNullValue()));
|
||||
assertThat(throwableRef.get(), is(sameInstance(t)));
|
||||
assertThat(throwableRef.get(), is(sameInstance(e)));
|
||||
verify(rolesStore, times(1)).putRole(eq(request), any(RoleDescriptor.class), any(ActionListener.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class TransportAuthenticateActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -72,7 +72,7 @@ public class TransportAuthenticateActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -99,7 +99,7 @@ public class TransportAuthenticateActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -68,7 +68,7 @@ public class TransportChangePasswordActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -97,7 +97,7 @@ public class TransportChangePasswordActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -135,7 +135,7 @@ public class TransportChangePasswordActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -152,13 +152,13 @@ public class TransportChangePasswordActionTests extends ESTestCase {
|
|||
ChangePasswordRequest request = new ChangePasswordRequest();
|
||||
request.username(user.principal());
|
||||
request.passwordHash(Hasher.BCRYPT.hash(new SecuredString("changeme".toCharArray())));
|
||||
final Throwable t = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException(), new RuntimeException());
|
||||
final Exception e = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException(), new RuntimeException());
|
||||
doAnswer(new Answer() {
|
||||
public Void answer(InvocationOnMock invocation) {
|
||||
Object[] args = invocation.getArguments();
|
||||
assert args.length == 2;
|
||||
ActionListener<Void> listener = (ActionListener<Void>) args[1];
|
||||
listener.onFailure(t);
|
||||
listener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
}).when(usersStore).changePassword(eq(request), any(ActionListener.class));
|
||||
|
@ -174,14 +174,14 @@ public class TransportChangePasswordActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(responseRef.get(), is(nullValue()));
|
||||
assertThat(throwableRef.get(), is(notNullValue()));
|
||||
assertThat(throwableRef.get(), sameInstance(t));
|
||||
assertThat(throwableRef.get(), sameInstance(e));
|
||||
verify(usersStore, times(1)).changePassword(eq(request), any(ActionListener.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TransportDeleteUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -90,7 +90,7 @@ public class TransportDeleteUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -118,7 +118,7 @@ public class TransportDeleteUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -156,7 +156,7 @@ public class TransportDeleteUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -168,7 +168,7 @@ public class TransportDeleteUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testException() {
|
||||
final Throwable t = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException(), new RuntimeException());
|
||||
final Exception e = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException(), new RuntimeException());
|
||||
final User user = new User("joe");
|
||||
NativeUsersStore usersStore = mock(NativeUsersStore.class);
|
||||
TransportDeleteUserAction action = new TransportDeleteUserAction(Settings.EMPTY, mock(ThreadPool.class),
|
||||
|
@ -180,7 +180,7 @@ public class TransportDeleteUserActionTests extends ESTestCase {
|
|||
Object[] args = invocation.getArguments();
|
||||
assert args.length == 2;
|
||||
ActionListener<Boolean> listener = (ActionListener<Boolean>) args[1];
|
||||
listener.onFailure(t);
|
||||
listener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
}).when(usersStore).deleteUser(eq(request), any(ActionListener.class));
|
||||
|
@ -194,14 +194,14 @@ public class TransportDeleteUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(responseRef.get(), is(nullValue()));
|
||||
assertThat(throwableRef.get(), is(notNullValue()));
|
||||
assertThat(throwableRef.get(), sameInstance(t));
|
||||
assertThat(throwableRef.get(), sameInstance(e));
|
||||
verify(usersStore, times(1)).deleteUser(eq(request), any(ActionListener.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class TransportGetUsersActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -116,7 +116,7 @@ public class TransportGetUsersActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -147,7 +147,7 @@ public class TransportGetUsersActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -185,7 +185,7 @@ public class TransportGetUsersActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -242,7 +242,7 @@ public class TransportGetUsersActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -261,7 +261,7 @@ public class TransportGetUsersActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testException() {
|
||||
final Throwable t = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException(), new ValidationException());
|
||||
final Exception e = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException(), new ValidationException());
|
||||
final List<User> storeUsers =
|
||||
randomFrom(Collections.singletonList(new User("joe")), Arrays.asList(new User("jane"), new User("fred")), randomUsers());
|
||||
final String[] storeUsernames = storeUsers.stream().map(User::principal).collect(Collectors.toList()).toArray(Strings.EMPTY_ARRAY);
|
||||
|
@ -277,7 +277,7 @@ public class TransportGetUsersActionTests extends ESTestCase {
|
|||
Object[] args = invocation.getArguments();
|
||||
assert args.length == 2;
|
||||
ActionListener<List<User>> listener = (ActionListener<List<User>>) args[1];
|
||||
listener.onFailure(t);
|
||||
listener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
}).when(usersStore).getUsers(aryEq(storeUsernames), any(ActionListener.class));
|
||||
|
@ -288,7 +288,7 @@ public class TransportGetUsersActionTests extends ESTestCase {
|
|||
Object[] args = invocation.getArguments();
|
||||
assert args.length == 2;
|
||||
ActionListener<User> listener = (ActionListener<User>) args[1];
|
||||
listener.onFailure(t);
|
||||
listener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
}).when(usersStore).getUser(eq(storeUsernames[0]), any(ActionListener.class));
|
||||
|
@ -303,13 +303,13 @@ public class TransportGetUsersActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(throwableRef.get(), is(notNullValue()));
|
||||
assertThat(throwableRef.get(), is(sameInstance(t)));
|
||||
assertThat(throwableRef.get(), is(sameInstance(e)));
|
||||
assertThat(responseRef.get(), is(nullValue()));
|
||||
if (request.usernames().length == 1) {
|
||||
verify(usersStore, times(1)).getUser(eq(request.usernames()[0]), any(ActionListener.class));
|
||||
|
|
|
@ -67,7 +67,7 @@ public class TransportPutUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -95,7 +95,7 @@ public class TransportPutUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -124,7 +124,7 @@ public class TransportPutUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -167,7 +167,7 @@ public class TransportPutUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
@ -179,7 +179,7 @@ public class TransportPutUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testException() {
|
||||
final Throwable t = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException(), new ValidationException());
|
||||
final Exception e = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException(), new ValidationException());
|
||||
final User user = new User("joe");
|
||||
NativeUsersStore usersStore = mock(NativeUsersStore.class);
|
||||
TransportPutUserAction action = new TransportPutUserAction(Settings.EMPTY, mock(ThreadPool.class),
|
||||
|
@ -192,7 +192,7 @@ public class TransportPutUserActionTests extends ESTestCase {
|
|||
Object[] args = invocation.getArguments();
|
||||
assert args.length == 2;
|
||||
ActionListener<Boolean> listener = (ActionListener<Boolean>) args[1];
|
||||
listener.onFailure(t);
|
||||
listener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
}).when(usersStore).putUser(eq(request), any(ActionListener.class));
|
||||
|
@ -206,14 +206,14 @@ public class TransportPutUserActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
throwableRef.set(e);
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(responseRef.get(), is(nullValue()));
|
||||
assertThat(throwableRef.get(), is(notNullValue()));
|
||||
assertThat(throwableRef.get(), sameInstance(t));
|
||||
assertThat(throwableRef.get(), sameInstance(e));
|
||||
verify(usersStore, times(1)).putUser(eq(request), any(ActionListener.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.security.audit;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.inject.Guice;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
|
@ -15,20 +14,17 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.xpack.security.audit.logfile.LoggingAuditTrail;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.local.LocalTransport;
|
||||
import org.elasticsearch.xpack.security.audit.logfile.LoggingAuditTrail;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AuditTrailModuleTests extends ESTestCase {
|
||||
public void testEnabled() throws Exception {
|
||||
Settings settings = Settings.builder()
|
||||
|
@ -93,7 +89,7 @@ public class AuditTrailModuleTests extends ESTestCase {
|
|||
try {
|
||||
Guice.createInjector(settingsModule, new AuditTrailModule(settings));
|
||||
fail("Expect initialization to fail when an unknown audit trail output is configured");
|
||||
} catch (Throwable t) {
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,9 +49,6 @@ import static org.mockito.Mockito.spy;
|
|||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class FileUserRolesStoreTests extends ESTestCase {
|
||||
private Settings settings;
|
||||
private Environment env;
|
||||
|
@ -217,8 +214,8 @@ public class FileUserRolesStoreTests extends ESTestCase {
|
|||
try {
|
||||
FileUserRolesStore.parseFile(file, logger);
|
||||
fail("expected a parse failure");
|
||||
} catch (Throwable t) {
|
||||
this.logger.info("expected", t);
|
||||
} catch (Exception e) {
|
||||
this.logger.info("expected", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,9 +56,9 @@ public class LdapSessionFactoryTests extends LdapTestCase {
|
|||
ldapServer.setProcessingDelayMillis(500L);
|
||||
try (LdapSession session = sessionFactory.session(user, userPass)) {
|
||||
fail("expected connection timeout error here");
|
||||
} catch (Throwable t) {
|
||||
assertThat(t, instanceOf(ElasticsearchSecurityException.class));
|
||||
assertThat(t.getCause().getMessage(), containsString("A client-side timeout was encountered while waiting "));
|
||||
} catch (Exception e) {
|
||||
assertThat(e, instanceOf(ElasticsearchSecurityException.class));
|
||||
assertThat(e.getCause().getMessage(), containsString("A client-side timeout was encountered while waiting "));
|
||||
} finally {
|
||||
ldapServer.setProcessingDelayMillis(0L);
|
||||
}
|
||||
|
@ -85,11 +85,11 @@ public class LdapSessionFactoryTests extends LdapTestCase {
|
|||
long start = System.currentTimeMillis();
|
||||
try (LdapSession session = sessionFactory.session(user, userPass)) {
|
||||
fail("expected connection timeout error here");
|
||||
} catch (Throwable t) {
|
||||
} catch (Exception e) {
|
||||
long time = System.currentTimeMillis() - start;
|
||||
assertThat(time, lessThan(10000L));
|
||||
assertThat(t, instanceOf(IOException.class));
|
||||
assertThat(t.getCause().getCause().getMessage(), containsString("within the configured timeout of"));
|
||||
assertThat(e, instanceOf(IOException.class));
|
||||
assertThat(e.getCause().getCause().getMessage(), containsString("within the configured timeout of"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SelfReschedulingRunnableTests extends ESTestCase {
|
|||
final ThreadPool threadPool = mock(ThreadPool.class);
|
||||
final AbstractRunnable runnable = new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,7 +88,7 @@ public class SelfReschedulingRunnableTests extends ESTestCase {
|
|||
final CountDownLatch pauseLatch = new CountDownLatch(1);
|
||||
final AbstractRunnable runnable = new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -195,7 +195,7 @@ public class SelfReschedulingRunnableTests extends ESTestCase {
|
|||
final AtomicInteger runCounter = new AtomicInteger(0);
|
||||
final AbstractRunnable runnable = new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
failureCounter.incrementAndGet();
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ public class SelfReschedulingRunnableTests extends ESTestCase {
|
|||
final CountDownLatch stopCalledLatch = new CountDownLatch(1);
|
||||
final AbstractRunnable runnable = new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
throw new IllegalStateException("we should never be in this method!");
|
||||
}
|
||||
|
||||
|
|
|
@ -192,13 +192,13 @@ public class HandshakeWaitingHandlerTests extends ESTestCase {
|
|||
try {
|
||||
serverBootstrap.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), randomPort));
|
||||
break;
|
||||
} catch (Throwable t) {
|
||||
if (t.getCause() instanceof BindException) {
|
||||
} catch (Exception e) {
|
||||
if (e.getCause() instanceof BindException) {
|
||||
logger.error("Tried to bind to port [{}], going to retry", randomPort);
|
||||
randomPort = randomIntBetween(49000, 65500);
|
||||
}
|
||||
if (tries >= maxTries) {
|
||||
throw new RuntimeException("Failed to start server bootstrap [" + tries + "] times, stopping", t);
|
||||
throw new RuntimeException("Failed to start server bootstrap [" + tries + "] times, stopping", e);
|
||||
}
|
||||
tries++;
|
||||
}
|
||||
|
|
|
@ -28,9 +28,6 @@ import java.util.Arrays;
|
|||
|
||||
import static org.elasticsearch.common.io.FileSystemUtils.isAccessibleDirectory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class XPackExtensionsService {
|
||||
private final Settings settings;
|
||||
|
||||
|
@ -186,7 +183,7 @@ public class XPackExtensionsService {
|
|||
"Settings instance");
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
throw new ElasticsearchException("Failed to load extension class [" + extClass.getName() + "]", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public class TransportXPackInfoActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
error.set(e);
|
||||
latch.countDown();
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public class WatcherLifeCycleService extends AbstractComponent implements Cluste
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
public void onFailure(Exception throwable) {
|
||||
logger.warn("updating manually stopped isn't acked", throwable);
|
||||
latch.countDown();
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ public class WatcherLifeCycleService extends AbstractComponent implements Cluste
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String source, Throwable throwable) {
|
||||
public void onFailure(String source, Exception throwable) {
|
||||
latch.countDown();
|
||||
logger.warn("couldn't update watcher metadata [{}]", throwable, source);
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ public class ExecutionService extends AbstractComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
Throwable cause = ExceptionsHelper.unwrapCause(e);
|
||||
if (cause instanceof EsRejectedExecutionException) {
|
||||
logger.debug("failed to store watch records due to overloaded threadpool [{}]", ExceptionsHelper.detailedMessage(e));
|
||||
|
|
|
@ -125,7 +125,7 @@ public class TriggeredWatchStore extends AbstractComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
@ -149,7 +149,7 @@ public class TriggeredWatchStore extends AbstractComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
@ -183,7 +183,7 @@ public class TriggeredWatchStore extends AbstractComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -42,8 +42,8 @@ public final class SearchRequestEquivalence {
|
|||
r2.writeTo(output1);
|
||||
byte[] bytes2 = BytesReference.toBytes(output1.bytes());
|
||||
return Arrays.equals(bytes1, bytes2);
|
||||
} catch (Throwable t) {
|
||||
throw illegalState("could not compare search requests", t);
|
||||
} catch (Exception e) {
|
||||
throw illegalState("could not compare search requests", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,9 +85,9 @@ public class TransportGetWatchAction extends WatcherTransportAction<GetWatchRequ
|
|||
listener.onFailure(e);
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
logger.error("failed to get watch [{}]", t, request.getId());
|
||||
throw t;
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to get watch [{}]", e, request.getId());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -332,8 +332,8 @@ public class ManualExecutionTests extends AbstractWatcherIntegrationTestCase {
|
|||
WatchRecord record = executionService.execute(ctxBuilder.build());
|
||||
assertThat(record, notNullValue());
|
||||
assertThat(record.state(), is(ExecutionState.NOT_EXECUTED_WATCH_MISSING));
|
||||
} catch (Throwable t) {
|
||||
throw new ElasticsearchException("Failure mode execution of [{}] failed in an unexpected way", t, watchId);
|
||||
} catch (Exception e) {
|
||||
throw new ElasticsearchException("Failure mode execution of [{}] failed in an unexpected way", e, watchId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue