本文整理汇总了Java中java.lang.reflect.UndeclaredThrowableException类的典型用法代码示例。如果您正苦于以下问题:Java UndeclaredThrowableException类的具体用法?Java UndeclaredThrowableException怎么用?Java UndeclaredThrowableException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UndeclaredThrowableException类属于java.lang.reflect包,在下文中一共展示了UndeclaredThrowableException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOptions
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
@Override
public List<TeasyElement> getOptions() {
try {
return wrappedSelect().getOptions()
.stream()
.map(option -> new DomTeasyElement(new TeasyElementData(option, By.tagName("option"))))
.collect(Collectors.toList());
} catch (UndeclaredThrowableException ignored) {
//TODO VF fix it in other places
//Sometimes this test fails in ie due to such exception
TestUtils.waitForSomeTime(3000, EXPLANATION_MESSAGE_FOR_WAIT);
return wrappedSelect().getOptions()
.stream()
.map(option -> new DomTeasyElement(new TeasyElementData(option, By.tagName("option"))))
.collect(Collectors.toList());
}
}
示例2: translateException
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
private Throwable translateException(Throwable cause) {
if (cause instanceof FastdfsException) {
return cause;
}
Throwable unwrap = cause;
for (; ; ) {
if (unwrap instanceof InvocationTargetException) {
unwrap = ((InvocationTargetException) unwrap).getTargetException();
continue;
}
if (unwrap instanceof UndeclaredThrowableException) {
unwrap = ((UndeclaredThrowableException) unwrap).getUndeclaredThrowable();
continue;
}
break;
}
return new FastdfsException("fastdfs operation error.", unwrap);
}
示例3: submitApplication
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
public static void submitApplication(
ApplicationSubmissionContext appContext, UserDescriptor user) throws Throwable {
UserGroupInformation ugi =
UserGroupInformation.createRemoteUser(user.getName());
// Need to start a new YarnClient for a new UGI, since its internal Hadoop RPC
// reuse the UGI after YarnClient.start().
try {
ugi.doAs((PrivilegedExceptionAction<Void>) () -> {
YarnClient yarnClient = YarnClient.createYarnClient();
yarnClient.init(conf);
yarnClient.start();
yarnClient.submitApplication(appContext);
yarnClient.stop();
return null;
});
} catch (UndeclaredThrowableException e) {
throw e.getCause();
}
}
示例4: handleReflectionException
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
/**
* Handle the given reflection exception. Should only be called if no
* checked exception is expected to be thrown by the target method.
* <p>Throws the underlying RuntimeException or Error in case of an
* InvocationTargetException with such a root cause. Throws an
* IllegalStateException with an appropriate message or
* UndeclaredThrowableException otherwise.
* @param ex the reflection exception to handle
*/
public static void handleReflectionException(Exception ex) {
if (ex instanceof NoSuchMethodException) {
throw new IllegalStateException("Method not found: " + ex.getMessage());
}
if (ex instanceof IllegalAccessException) {
throw new IllegalStateException("Could not access method: " + ex.getMessage());
}
if (ex instanceof InvocationTargetException) {
handleInvocationTargetException((InvocationTargetException) ex);
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new UndeclaredThrowableException(ex);
}
示例5: _handleRenderException
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
private void _handleRenderException(
RuntimeException re) throws IOException
{
if (re instanceof UndeclaredThrowableException)
{
// Our UnsynchronizedPrintWriter catches IOExceptions and
// rethrows these wrapped in UndeclaredThrowableExceptions. If we
// catch any UndeclaredThrowableExceptions which have an IOExceptions
// as the root cause, let's just rethrow the original
// IOException so that the original stack trace will be
// preserved.
Throwable rootCause = ((UndeclaredThrowableException)re).getCause();
if (rootCause instanceof IOException)
throw ((IOException)rootCause);
}
throw re;
}
示例6: getXMLReader
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
/**
* Returns an implementation of the SAX2 XMLReader interface.
*/
public XMLReader getXMLReader()
{
try
{
return _SAX_PARSER_FACTORY.newSAXParser().getXMLReader();
}
catch (ParserConfigurationException pce)
{
_LOG.severe(pce);
}
catch (SAXException saxe)
{
throw new UndeclaredThrowableException(saxe);
}
catch (Error e)
{
_LOG.severe(e);
}
return null;
}
示例7: handleException
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
/**
* Handles a Throwable; the exception is swallowed after being logged.
*/
static public void handleException(
UIXRenderingContext context,
Throwable throwable)
{
if (throwable == null)
throw new NullPointerException("throwable is null");
if (throwable instanceof ThreadDeath)
{
throw ((ThreadDeath)throwable);
}
else if (throwable instanceof RuntimeException)
{
handleException(context, (RuntimeException)throwable);
}
else
{
handleException(context, new UndeclaredThrowableException(throwable));
}
}
示例8: _getTargetType
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
private Class<?> _getTargetType()
{
if (_class == null)
{
try
{
_class = ClassLoaderUtils.loadClass(_javaType);
}
catch (ClassNotFoundException e)
{
throw new UndeclaredThrowableException(e);
}
}
return _class;
}
示例9: instantiate
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
public Renderer instantiate()
{
try
{
Class<?> classInstance = ClassLoaderUtils.loadClass(_className);
return (Renderer) classInstance.newInstance();
}
catch (ClassNotFoundException cnfe)
{
_showInstantiationError(cnfe);
throw new UndeclaredThrowableException( cnfe,
"Instantiation of UIX Components Renderer failed, class " +
_className + " not found.");
}
catch (IllegalAccessException iae)
{
_showInstantiationError(iae);
}
catch (InstantiationException ie)
{
_showInstantiationError(ie);
}
return null;
}
示例10: translateException
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
private Throwable translateException(Throwable cause) {
if (cause instanceof FastdfsException) {
return cause;
}
Throwable unwrap = cause;
for (;;) {
if (unwrap instanceof InvocationTargetException) {
unwrap = ((InvocationTargetException) unwrap).getTargetException();
continue;
}
if (unwrap instanceof UndeclaredThrowableException) {
unwrap = ((UndeclaredThrowableException) unwrap).getUndeclaredThrowable();
continue;
}
break;
}
return new FastdfsException("fastdfs operation error.", unwrap);
}
示例11: hmac_sha
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
/**
* This method uses the JCE to provide the crypto algorithm.
* HMAC computes a Hashed Message Authentication Code with the
* crypto hash algorithm as a parameter.
*
* @param crypto the crypto algorithm (HmacSHA1, HmacSHA256,
* HmacSHA512)
* @param keyBytes the bytes to use for the HMAC key
* @param text the message or text to be authenticated
*/
private static byte[] hmac_sha(String crypto, byte[] keyBytes,
byte[] text) {
try {
Mac hmac;
hmac = Mac.getInstance(crypto);
SecretKeySpec macKey =
new SecretKeySpec(keyBytes, "RAW");
hmac.init(macKey);
return hmac.doFinal(text);
} catch (GeneralSecurityException gse) {
gse.printStackTrace();
throw new UndeclaredThrowableException(gse);
}
}
示例12: unregisterAppAttempt
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
public void unregisterAppAttempt(final FinishApplicationMasterRequest req,
boolean waitForStateRunning) throws Exception {
if (waitForStateRunning) {
waitForState(RMAppAttemptState.RUNNING);
}
if (ugi == null) {
ugi = UserGroupInformation.createRemoteUser(attemptId.toString());
Token<AMRMTokenIdentifier> token =
context.getRMApps()
.get(attemptId.getApplicationId())
.getRMAppAttempt(attemptId).getAMRMToken();
ugi.addTokenIdentifier(token.decodeIdentifier());
}
try {
ugi.doAs(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
amRMProtocol.finishApplicationMaster(req);
return null;
}
});
} catch (UndeclaredThrowableException e) {
throw (Exception) e.getCause();
}
}
示例13: startTimelineClient
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
@VisibleForTesting
void startTimelineClient(final Configuration conf)
throws YarnException, IOException, InterruptedException {
try {
appSubmitterUgi.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED,
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) {
// Creating the Timeline Client
timelineClient = TimelineClient.createTimelineClient();
timelineClient.init(conf);
timelineClient.start();
} else {
timelineClient = null;
LOG.warn("Timeline service is not enabled");
}
return null;
}
});
} catch (UndeclaredThrowableException e) {
throw new YarnException(e.getCause());
}
}
示例14: doAs
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
/**
* Run the given action as the user, potentially throwing an exception.
* @param <T> the return type of the run method
* @param action the method to execute
* @return the value from the run method
* @throws IOException if the action throws an IOException
* @throws Error if the action throws an Error
* @throws RuntimeException if the action throws a RuntimeException
* @throws InterruptedException if the action throws an InterruptedException
* @throws UndeclaredThrowableException if the action throws something else
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public <T> T doAs(PrivilegedExceptionAction<T> action
) throws IOException, InterruptedException {
try {
logPrivilegedAction(subject, action);
return Subject.doAs(subject, action);
} catch (PrivilegedActionException pae) {
Throwable cause = pae.getCause();
if (LOG.isDebugEnabled()) {
LOG.debug("PrivilegedActionException as:" + this + " cause:" + cause);
}
if (cause instanceof IOException) {
throw (IOException) cause;
} else if (cause instanceof Error) {
throw (Error) cause;
} else if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else if (cause instanceof InterruptedException) {
throw (InterruptedException) cause;
} else {
throw new UndeclaredThrowableException(cause);
}
}
}
示例15: handleReflectionException
import java.lang.reflect.UndeclaredThrowableException; //导入依赖的package包/类
/**
* Handle the given reflection exception. Should only be called if no checked exception is expected to be thrown by
* the target method.
* <p>
* Throws the underlying RuntimeException or Error in case of an InvocationTargetException with such a root cause.
* Throws an IllegalStateException with an appropriate message else.
*
* @param ex
* the reflection exception to handle
*/
public static void handleReflectionException(Exception ex) {
if (ex instanceof NoSuchMethodException) {
throw new IllegalStateException("Method not found: " + ex.getMessage());
}
if (ex instanceof IllegalAccessException) {
throw new IllegalStateException("Could not access method: " + ex.getMessage());
}
if (ex instanceof InvocationTargetException) {
handleInvocationTargetException((InvocationTargetException) ex);
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new UndeclaredThrowableException(ex);
}