java.lang.Thread.UncaughtExceptionHandler#uncaughtException ( )源码实例Demo

下面列出了java.lang.Thread.UncaughtExceptionHandler#uncaughtException ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: TopThreadGroup.java
@Override
public void uncaughtException(Thread t, Throwable e) {
    if (!(e instanceof ThreadDeath)) {
        UncaughtExceptionHandler h = Thread.getDefaultUncaughtExceptionHandler();
        if (h != null) {
            h.uncaughtException(t, e);
            return;
        }
        
        if (e instanceof VirtualMachineError) {
            // Try as hard as possible to get a stack trace from e.g. StackOverflowError
            e.printStackTrace();
        }
        System.err.flush();
        Exceptions.printStackTrace(e);
    }
    else {
        super.uncaughtException(t, e);
    }
}
 
源代码2 项目: pumpernickel   文件: AbstractListFilter.java
/**
 * Fire all ChangeListeners.
 * <p>
 * This should be called when the filter has fundamentally changed what
 * it may accept. For example: if this filter is based on text in a text field,
 * then every time that text field is changed we should call this method
 */
public void fireChangeListeners() {
	for (ChangeListener changeListener : changeListeners
			.toArray(new ChangeListener[changeListeners.size()])) {
		try {
			changeListener.stateChanged(new ChangeEvent(this));
		} catch (Exception e) {
			UncaughtExceptionHandler u = getUncaughtExceptionHandler();
			if (u != null) {
				u.uncaughtException(Thread.currentThread(), e);
			} else {
				e.printStackTrace();
			}
		}
	}
}
 
源代码3 项目: Augendiagnose   文件: Application.java
/**
 * Define custom ExceptionHandler which takes action on OutOfMemoryError.
 */
private void setExceptionHandler() {
	final UncaughtExceptionHandler defaultExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();

	UncaughtExceptionHandler customExceptionHandler =
			new UncaughtExceptionHandler() {
				@Override
				public void uncaughtException(final Thread thread, final Throwable ex) {
					if (ex instanceof OutOfMemoryError) {
						// Store info about OutOfMemoryError
						PreferenceUtil.setSharedPreferenceBoolean(R.string.key_internal_outofmemoryerror, true);
					}

					// re-throw critical exception further to the os
					defaultExceptionHandler.uncaughtException(thread, ex);
				}
			};

	Thread.setDefaultUncaughtExceptionHandler(customExceptionHandler);
}
 
源代码4 项目: firebase-admin-java   文件: DefaultRunLoop.java
private void handleExceptionInternal(Throwable e) {
  UncaughtExceptionHandler exceptionHandler;
  exceptionHandler = getExceptionHandler();
  try {
    if (exceptionHandler != null) {
      exceptionHandler.uncaughtException(Thread.currentThread(), e);
    }
  } finally {
    handleException(e);
  }
}
 
@Override
public void uncaughtException(Thread t, Throwable e) {
  try {
    UncaughtExceptionHandler delegate;
    synchronized (this) {
      delegate = exceptionHandler;
    }
    if (delegate != null) {
      delegate.uncaughtException(t, e);
    }
  } finally {
    logger.error("Event handler threw an exception", e);
  }
}
 
源代码6 项目: letv   文件: jt.java
private void a(Thread thread, Throwable th) {
    for (UncaughtExceptionHandler uncaughtException : c()) {
        try {
            uncaughtException.uncaughtException(thread, th);
        } catch (Throwable th2) {
        }
    }
}
 
源代码7 项目: pumpernickel   文件: ContainerProperties.java
/**
 * Convert a String representation to an Object
 * 
 * @param toStringValue
 *            the serialized String value
 * @param componentType
 *            the type of object that is returned.
 * @param handler
 *            a handler to notify if something goes wrong
 * @return the Object represented by the argument String.
 */
protected Object convert(String toStringValue, Class<?> componentType,
		UncaughtExceptionHandler handler) {
	if (String.class.equals(componentType))
		return toStringValue;
	if (Boolean.class.equals(componentType)
			|| Boolean.TYPE.equals(componentType))
		return Boolean.parseBoolean(toStringValue);
	if (Integer.class.equals(componentType)
			|| Integer.TYPE.equals(componentType))
		return Integer.parseInt(toStringValue);
	if (Short.class.equals(componentType)
			|| Short.TYPE.equals(componentType))
		return Short.parseShort(toStringValue);
	if (Long.class.equals(componentType) || Long.TYPE.equals(componentType))
		return Long.parseLong(toStringValue);
	if (Character.class.equals(componentType)
			|| Character.TYPE.equals(componentType))
		return toStringValue.charAt(0);
	if (Byte.class.equals(componentType) || Byte.TYPE.equals(componentType))
		return Byte.parseByte(toStringValue);
	if (Float.class.equals(componentType)
			|| Float.TYPE.equals(componentType))
		return Float.parseFloat(toStringValue);
	if (Double.class.equals(componentType)
			|| Double.TYPE.equals(componentType))
		return Double.parseDouble(toStringValue);
	if (BigInteger.class.equals(componentType))
		return new BigInteger(toStringValue);
	if (BigDecimal.class.equals(componentType))
		return new BigDecimal(toStringValue);
	if (File.class.equals(componentType))
		return new File(toStringValue);
	handler.uncaughtException(
			Thread.currentThread(),
			new UnsupportedEncodingException(
					"ContainerProperties cannot parse "
							+ componentType.getCanonicalName()));
	return null;
}
 
@Override
public void uncaughtException(Thread thread, Throwable throwable) {
  synchronized (list) {
    for (UncaughtExceptionHandler handler : list) {
      handler.uncaughtException(thread, throwable);
    }
  }
}
 
源代码9 项目: RxJava3-preview   文件: RxJavaCommonPlugins.java
static void uncaught(@NonNull Throwable error) {
    Thread currentThread = Thread.currentThread();
    UncaughtExceptionHandler handler = currentThread.getUncaughtExceptionHandler();
    handler.uncaughtException(currentThread, error);
}