Example usage for java.lang Thread setDefaultUncaughtExceptionHandler

List of usage examples for java.lang Thread setDefaultUncaughtExceptionHandler

Introduction

In this page you can find the example usage for java.lang Thread setDefaultUncaughtExceptionHandler.

Prototype

public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh) 

Source Link

Document

Set the default handler invoked when a thread abruptly terminates due to an uncaught exception, and no other handler has been defined for that thread.

Usage

From source file:com.altcanvas.twitspeak.TwitSpeakActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    systemDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler(new TopExceptionHandler(this));

    setContentView(R.layout.main);/*from   w  w w  .  j av  a 2  s.  c o  m*/

    boolean hasStackTrace = checkStackTrace();
    if (!hasStackTrace)
        continueOnCreate();
}

From source file:cc.metapro.openct.utils.CrashHandler.java

private void init(OpenCT context) {
    mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler(this);
    mContext = context;//from   www  .  ja v a 2 s  . c o m
}

From source file:org.akvo.flow.service.ApkUpdateService.java

@Override
protected void onHandleIntent(Intent intent) {
    Thread.setDefaultUncaughtExceptionHandler(PersistentUncaughtExceptionHandler.getInstance());
    checkUpdates();
}

From source file:org.apache.hadoop.hdfs.TestFileCreationEmpty.java

/**
 * This test creates three empty files and lets their leases expire.
 * This triggers release of the leases. 
 * The empty files are supposed to be closed by that 
 * without causing ConcurrentModificationException.
 *//*from  www .  j ava2 s  . c  o m*/
public void testLeaseExpireEmptyFiles() throws Exception {
    final Thread.UncaughtExceptionHandler oldUEH = Thread.getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            if (e instanceof ConcurrentModificationException) {
                LeaseManager.LOG.error("t=" + t, e);
                isConcurrentModificationException = true;
            }
        }
    });

    LOG.info("testLeaseExpireEmptyFiles start");
    final long leasePeriod = 1000;
    final int DATANODE_NUM = 3;

    final Configuration conf = new HdfsConfiguration();
    conf.setInt(DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY, 1000);
    conf.setInt(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1);

    // create cluster
    MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(DATANODE_NUM).build();
    try {
        cluster.waitActive();
        DistributedFileSystem dfs = (DistributedFileSystem) cluster.getFileSystem();

        // create a new file.
        TestFileCreation.createFile(dfs, new Path("/foo"), DATANODE_NUM);
        TestFileCreation.createFile(dfs, new Path("/foo2"), DATANODE_NUM);
        TestFileCreation.createFile(dfs, new Path("/foo3"), DATANODE_NUM);

        // set the soft and hard limit to be 1 second so that the
        // namenode triggers lease recovery
        cluster.setLeasePeriod(leasePeriod, leasePeriod);
        // wait for the lease to expire
        try {
            Thread.sleep(5 * leasePeriod);
        } catch (InterruptedException e) {
        }

        assertFalse(isConcurrentModificationException);
    } finally {
        Thread.setDefaultUncaughtExceptionHandler(oldUEH);
        cluster.shutdown();
    }
}

From source file:com.gloriouseggroll.LastFMAPI.java

private LastFMAPI() {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());
}

From source file:org.sejda.cli.SejdaConsole.java

public SejdaConsole(String[] rawArguments, TaskExecutionAdapter taskExecutionAdapter) {
    Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler());
    this.arguments = new RawArguments(rawArguments.clone());
    this.taskExecutionAdapter = taskExecutionAdapter;
}

From source file:de.schildbach.wallet.util.CrashReporter.java

public static void init(final File cacheDir) {
    backgroundTracesFile = new File(cacheDir, BACKGROUND_TRACES_FILENAME);
    crashTraceFile = new File(cacheDir, CRASH_TRACE_FILENAME);

    Thread.setDefaultUncaughtExceptionHandler(
            new ExceptionHandler(Thread.getDefaultUncaughtExceptionHandler()));
}

From source file:com.illusionaryone.TwitchTMIv1.java

private TwitchTMIv1() {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());
}

From source file:com.illusionaryone.GitHubAPIv3.java

private GitHubAPIv3() {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());
}

From source file:com.illusionaryone.BTTVAPIv2.java

private BTTVAPIv2() {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());
}