當前位置: 首頁>>代碼示例>>Java>>正文


Java UndeclaredThrowableException類代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:WileyLabs,項目名稱:teasy,代碼行數:18,代碼來源:SelectImpl.java

示例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);
}
 
開發者ID:rodbate,項目名稱:fastdfs-spring-boot,代碼行數:24,代碼來源:FastdfsHandler.java

示例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();
  }
}
 
開發者ID:Microsoft,項目名稱:pai,代碼行數:20,代碼來源:HadoopUtils.java

示例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);
}
 
開發者ID:drinkjava2,項目名稱:jDialects,代碼行數:25,代碼來源:ReflectionUtils.java

示例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;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:19,代碼來源:UIXComponentUINode.java

示例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;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:25,代碼來源:JaxpXMLProvider.java

示例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));
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:24,代碼來源:DataBoundValue.java

示例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;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:17,代碼來源:ConvertBoundValue.java

示例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;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:26,代碼來源:ClassRendererInstantiator.java

示例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);
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:24,代碼來源:FastdfsHandler.java

示例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);

    }
}
 
開發者ID:privacyidea,項目名稱:privacyidea-authenticator,代碼行數:26,代碼來源:OTPGenerator.java

示例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();
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:MockAM.java

示例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());
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:ApplicationMaster.java

示例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);
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:37,代碼來源:UserGroupInformation.java

示例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);
}
 
開發者ID:xsonorg,項目名稱:tangyuan2,代碼行數:26,代碼來源:ReflectionUtils.java


注:本文中的java.lang.reflect.UndeclaredThrowableException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。