本文整理汇总了Java中org.apache.commons.lang.exception.ExceptionUtils.getRootCause方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtils.getRootCause方法的具体用法?Java ExceptionUtils.getRootCause怎么用?Java ExceptionUtils.getRootCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.exception.ExceptionUtils
的用法示例。
在下文中一共展示了ExceptionUtils.getRootCause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInterrupt
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
protected boolean isInterrupt(Throwable e) {
if (!running) {
return true;
}
if (e instanceof InterruptedException || e instanceof ZkInterruptedException) {
return true;
}
if (ExceptionUtils.getRootCause(e) instanceof InterruptedException) {
return true;
}
return false;
}
示例2: processException
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
private boolean processException(YuGongContext context, Table table, RecordExtractor extractor, Throwable e) {
if (ExceptionUtils.getRootCause(e) instanceof InterruptedException) {
// interrupt事件,响应退出
logger.info("table[{}] is interrpt ,current status:{} !", table
.getFullName(), extractor.status());
return true;
} else if (OracleInstance.this.isStop()) {
return true;
} else {
logger.error("retry, something error happened. caused by {}",
ExceptionUtils.getFullStackTrace(e));
logger.info("table[{}] is error , current status:{} !", table
.getFullName(), extractor.status());
try {
Thread.sleep(retryInterval);
} catch (InterruptedException e1) {
exception = new YuGongException(e1);
Thread.currentThread().interrupt();
return true;
}
}
return false;
}
示例3: shouldRequireAliasedGraphVariablesInStrictTransactionMode
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldRequireAliasedGraphVariablesInStrictTransactionMode() throws Exception {
final Cluster cluster = Cluster.build().create();
final Client client = cluster.connect();
try {
client.submit("1+1").all().get();
fail("Should have tossed an exception because strict mode is on and no aliasing was performed");
} catch (Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertThat(root, instanceOf(ResponseException.class));
final ResponseException re = (ResponseException) root;
assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
}
cluster.close();
}
示例4: shouldReceiveFailureOnBadGryoSerialization
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldReceiveFailureOnBadGryoSerialization() throws Exception {
final Cluster cluster = Cluster.build("localhost").serializer(Serializers.GRYO_V1D0).create();
final Client client = cluster.connect();
try {
client.submit("java.awt.Color.RED").all().join();
fail("Should throw an exception.");
} catch (RuntimeException re) {
final Throwable root = ExceptionUtils.getRootCause(re);
assertThat(root.getMessage(), CoreMatchers.startsWith("Error during serialization: Class is not registered: java.awt.Color"));
// validate that we can still send messages to the server
assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
} finally {
cluster.close();
}
}
示例5: shouldFailIfSslEnabledOnServerButNotClient
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldFailIfSslEnabledOnServerButNotClient() throws Exception {
final Cluster cluster = Cluster.build().create();
final Client client = cluster.connect();
try {
client.submit("1+1").all().get();
fail("This should not succeed as the client did not enable SSL");
} catch(Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertEquals(TimeoutException.class, root.getClass());
assertThat(root.getMessage(), startsWith("Timed out while waiting for an available host"));
} finally {
cluster.close();
}
}
示例6: getAppenderLevel
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
public void getAppenderLevel() {
if (StringUtils.isNotEmpty(appenderNameField.getValue())) {
String appenderName = appenderNameField.getValue();
String threshold;
try {
threshold = jmxRemoteLoggingAPI.getAppenderThreshold(getSelectedConnection(), appenderName);
} catch (LogControlException | JmxControlException e) {
log.error("Error getting appender level", e);
Throwable rootCause = ExceptionUtils.getRootCause(e);
showNotification(getMessage("exception.logControl"), rootCause.getMessage(), NotificationType.ERROR);
return;
}
if (threshold != null)
appenderLevelField.setValue(LoggingHelper.getLevelFromString(threshold));
} else {
appenderLevelField.setValue(null);
showNotification(getMessage("appender.notSelected"), NotificationType.HUMANIZED);
}
}
示例7: shouldFailAuthenticateWithPlainTextNoCredentials
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldFailAuthenticateWithPlainTextNoCredentials() throws Exception {
final Cluster cluster = Cluster.build().create();
final Client client = cluster.connect();
try {
client.submit("1+1").all().get();
fail("This should not succeed as the client did not provide credentials");
} catch(Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertEquals(GSSException.class, root.getClass());
// removed this assert as the text of the message changes based on kerberos config - stupid kerberos
// assertThat(root.getMessage(), startsWith("Invalid name provided"));
} finally {
cluster.close();
}
}
示例8: shouldCompileStatic
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldCompileStatic() throws Exception {
// with no type checking this should pass
try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine()) {
assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"));
}
final CompileStaticCustomizerProvider provider = new CompileStaticCustomizerProvider();
try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(provider)) {
scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()");
fail("Should have failed type checking");
} catch (ScriptException se) {
final Throwable root = ExceptionUtils.getRootCause(se);
assertEquals(MultipleCompilationErrorsException.class, root.getClass());
assertThat(se.getMessage(), containsString("[Static type checking] - Cannot find matching method java.lang.Object#getRed(). Please check if the declared type is right and if the method exists."));
}
}
示例9: shouldRollbackOnEvalExceptionForManagedTransaction
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldRollbackOnEvalExceptionForManagedTransaction() throws Exception {
assumeNeo4jIsPresent();
final Cluster cluster = Cluster.build().create();
final Client client = cluster.connect(name.getMethodName(), true);
try {
client.submit("graph.addVertex(); throw new Exception('no worky')").all().get();
fail("Should have tossed the manually generated exception");
} catch (Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
ex.printStackTrace();
assertEquals("no worky", root.getMessage());
// just force a commit here of "something" in case there is something lingering
client.submit("graph.addVertex(); graph.tx().commit()").all().get();
}
// the transaction is managed so a rollback should have executed
assertEquals(1, client.submit("g.V().count()").all().get().get(0).getInt());
}
示例10: shouldReceiveFailureOnBadGraphSONSerialization
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldReceiveFailureOnBadGraphSONSerialization() throws Exception {
final Cluster cluster = Cluster.build("localhost").serializer(Serializers.GRAPHSON_V1D0).create();
final Client client = cluster.connect();
try {
client.submit("def class C { def C getC(){return this}}; new C()").all().join();
fail("Should throw an exception.");
} catch (RuntimeException re) {
final Throwable root = ExceptionUtils.getRootCause(re);
assertThat(root.getMessage(), CoreMatchers.startsWith("Error during serialization: Direct self-reference leading to cycle (through reference chain:"));
// validate that we can still send messages to the server
assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
} finally {
cluster.close();
}
}
示例11: shouldPromoteDefinedVarsInInterpreterModeWithNoBindings
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldPromoteDefinedVarsInInterpreterModeWithNoBindings() throws Exception {
final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeCustomizerProvider());
engine.eval("def addItUp = { x, y -> x + y }");
assertEquals(3, engine.eval("int xxx = 1 + 2"));
assertEquals(4, engine.eval("yyy = xxx + 1"));
assertEquals(7, engine.eval("def zzz = yyy + xxx"));
assertEquals(4, engine.eval("zzz - xxx"));
assertEquals("accessible-globally", engine.eval("if (yyy > 0) { def inner = 'should-stay-local'; outer = 'accessible-globally' }\n outer"));
assertEquals("accessible-globally", engine.eval("outer"));
try {
engine.eval("inner");
fail("Should not have been able to access 'inner'");
} catch (Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertThat(root, instanceOf(MissingPropertyException.class));
}
assertEquals(10, engine.eval("addItUp(zzz,xxx)"));
}
示例12: shouldEventuallySucceedOnSameServer
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldEventuallySucceedOnSameServer() throws Exception {
stopServer();
final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
final Client client = cluster.connect();
try {
client.submit("1+1").all().join().get(0).getInt();
fail("Should not have gone through because the server is not running");
} catch (Exception i) {
final Throwable root = ExceptionUtils.getRootCause(i);
assertThat(root, instanceOf(TimeoutException.class));
}
startServer();
// default reconnect time is 1 second so wait some extra time to be sure it has time to try to bring it
// back to life
TimeUnit.SECONDS.sleep(3);
assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
cluster.close();
}
示例13: shouldHidePartitionKeyForValueMap
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
public void shouldHidePartitionKeyForValueMap() {
final GraphTraversalSource gOverA = create(PartitionStrategy.build()
.includeMetaProperties(true)
.partitionKey(partition).writePartition("A").addReadPartition("A").create());
final Vertex v = gOverA.addV().property("any", "thing").next();
try {
gOverA.V(v).valueMap(partition).next();
fail("Should have thrown exception");
} catch (Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertThat(root.getMessage(), startsWith("Cannot explicitly request the partitionKey in the traversal"));
}
}
示例14: shouldFailWithScriptExecutionException
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldFailWithScriptExecutionException() throws Exception {
final Cluster cluster = Cluster.open();
final Client client = cluster.connect();
final ResultSet results = client.submit("1/0");
try {
results.all().join();
fail("Should have thrown exception over bad serialization");
} catch (Exception ex) {
final Throwable inner = ExceptionUtils.getRootCause(ex);
assertTrue(inner instanceof ResponseException);
assertThat(inner.getMessage(), endsWith("Division by zero"));
}
// should not die completely just because we had a bad serialization error. that kind of stuff happens
// from time to time, especially in the console if you're just exploring.
assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
cluster.close();
}
示例15: shouldFailAuthenticateWithPlainTextBadPassword
import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Test
public void shouldFailAuthenticateWithPlainTextBadPassword() throws Exception {
final Cluster cluster = Cluster.build().credentials("stephen", "bad").create();
final Client client = cluster.connect();
try {
client.submit("1+1").all().get();
fail("This should not succeed as the client did not provide valid credentials");
} catch(Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertEquals(ResponseException.class, root.getClass());
assertEquals("Username and/or password are incorrect", root.getMessage());
} finally {
cluster.close();
}
}