• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ExceptionUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.threadly.util.ExceptionUtils的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtils类的具体用法?Java ExceptionUtils怎么用?Java ExceptionUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExceptionUtils类属于org.threadly.util包,在下文中一共展示了ExceptionUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: markGlobalFailure

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
public void markGlobalFailure() {
  if (! markedFailure.get() && markedFailure.compareAndSet(false, true)) {
    synchronized (failureListeners) {
      for (Runnable r :  failureListeners) {
        ExceptionUtils.runRunnable(r);
      }
      failureListeners.clear();
    }
    List<ListenableFuture<StepResult>> futures = this.futures.get();
    if (futures != null) {
      // try to short cut any steps we can
      // Sadly this is a duplicate from other cancels, but since we are not garunteed to be 
      // able to cancel here, we still need those points
      FutureUtils.cancelIncompleteFutures(futures, true);
    }
  }
}
 
开发者ID:threadly,项目名称:ambush,代码行数:19,代码来源:ExecutableScript.java


示例2: doClientWrite

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
private void doClientWrite(boolean doLocal) {
  if(isClosed()) {
    return;
  }
  int wrote = 0;
  try {
    wrote = channel.write(getWriteBuffer());
    if(wrote > 0) {
      reduceWrite(wrote);
      se.addWriteAmount(wrote);
    }
    if(!doLocal) {
      se.setClientOperations(TCPClient.this);
    }
  } catch(Exception e) {
    ExceptionUtils.handleException(e);
    close();
  }
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:20,代码来源:TCPClient.java


示例3: read

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
public int read() throws IOException {
  if(isClosed) {
    return -1;
  }
  synchronized(currentBB) {
    while(true) {
      if(currentBB.remaining() > 0) {
        return currentBB.get() & MergedByteBuffers.UNSIGNED_BYTE_MASK;
      } else {
        if(c.getReadBufferSize() > 0) {
          currentBB.add(c.getRead());
        } else if(isClosed) {
          return -1;
        } else {
          try {
            currentBB.wait(1000);
          } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            ExceptionUtils.handleException(e);
          }
        }
      }
    }
  }
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:27,代码来源:IOUtils.java


示例4: shutdownService

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
protected void shutdownService() {
  commonSelector.wakeup();
  for(final Client client: clients.values()) {
    IOUtils.closeQuietly(client);
  }
  for(final Server server: servers.values()) {
    IOUtils.closeQuietly(server);
  }
  if(commonSelector != null && commonSelector.isOpen()) {
    closeSelector(schedulerPool, commonSelector);
  }
  while(localNoThreadScheduler.hasTaskReadyToRun()) {
    try {
      localNoThreadScheduler.tick(null);
    } catch(Exception e) {
      ExceptionUtils.handleException(e);
    }
  }
  clients.clear();
  servers.clear();
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:23,代码来源:NoThreadSocketExecuter.java


示例5: runBenchmark

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
private static BenchmarkResult runBenchmark(String classpath, 
                                            Class<? extends AbstractBenchmark> benchmarkClass, 
                                            String executionArgs) {
  String[] command = {SHELL, "-c", 
                      JAVA_EXECUTE_CMD + "-cp " + classpath + ' ' + 
                        benchmarkClass.getName() + ' ' + executionArgs};
  System.gc();
  try {
    ExecResult runResult = runCommand(command);
    if (StringUtils.isNullOrEmpty(runResult.stdErr)) {
      int delimIndex = runResult.stdOut.indexOf(AbstractBenchmark.OUTPUT_DELIM);
      if (delimIndex > 0) {
        delimIndex += AbstractBenchmark.OUTPUT_DELIM.length();
        long runVal = Long.parseLong(runResult.stdOut.substring(delimIndex));
        return new BenchmarkResult(runVal);
      } else {
        return new BenchmarkResult("Invalid benchmark output: " + runResult.stdOut);
      }
    } else {
      return new BenchmarkResult(runResult.stdErr);
    }
  } catch (Exception e) {
    return new BenchmarkResult(ExceptionUtils.stackToString(e));
  }
}
 
开发者ID:threadly,项目名称:threadly_benchmarks,代码行数:26,代码来源:BenchmarkCollectionRunner.java


示例6: run

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
public void run() {
  while (isRunning()) {
    Runnable task = taskQueue.poll();
    // just reset status, we should only shutdown by having the service stopped
    Thread.interrupted();
    if (task != null) {
      if (parked) {
        parked = false;
      }
      ExceptionUtils.runRunnable(task);
    } else if (! parked) {
      // check neighbor worker to see if they need help
      task = checkNeighborWorker.taskQueue.poll();
      if (task != null) {
        ExceptionUtils.runRunnable(task);
      } else {
        parked = true;
      }
    } else {
      LockSupport.park();
    }
  }
}
 
开发者ID:threadly,项目名称:threadly,代码行数:25,代码来源:UnfairExecutor.java


示例7: run

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
public void run() {
  while (runningThread != null) {
    try {
      T next = getNext();
      
      acceptor.acceptConsumedItem(next);
    } catch (InterruptedException e) {
      stopIfRunning();
      // reset interrupted status
      Thread.currentThread().interrupt();
    } catch (Throwable t) {
      ExceptionUtils.handleException(t);
    }
  }
}
 
开发者ID:threadly,项目名称:threadly,代码行数:17,代码来源:BlockingQueueConsumer.java


示例8: runListener

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
/**
 * Invokes a single listener, if an executor is provided that listener is invoked on that 
 * executor, otherwise it runs in this thread.
 * 
 * @param listener Listener to run
 * @param executor Executor to run listener on, or null to run on calling thread
 * @param throwException {@code true} throws exceptions from runnable, {@code false} handles exceptions
 */
protected void runListener(Runnable listener, Executor executor, boolean throwException) {
  try {
    if (executor != null) {
      executor.execute(listener);
    } else {
      listener.run();
    }
  } catch (Throwable t) {
    if (throwException) {
      throw ExceptionUtils.makeRuntime(t);
    } else {
      ExceptionUtils.handleException(t);
    }
  }
}
 
开发者ID:threadly,项目名称:threadly,代码行数:24,代码来源:RunnableListenerHelper.java


示例9: setExceptionHandlerTest

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Test
public void setExceptionHandlerTest() {
  TestExceptionHandler teh = new TestExceptionHandler();
  ConfigurableThreadFactory ctf = new ConfigurableThreadFactory(teh);
  
  assertEquals(teh, ctf.defaultThreadlyExceptionHandler);
  
  final AtomicReference<ExceptionHandler> ehi = new AtomicReference<>(null);
  TestRunnable tr = new TestRunnable() {
    @Override
    public void handleRunStart() {
      ehi.set(ExceptionUtils.getExceptionHandler());
    }
  };
  Thread t = ctf.newThread(tr);
  t.start();
  tr.blockTillFinished();
  
  assertTrue(ehi.get() == teh);
}
 
开发者ID:threadly,项目名称:threadly,代码行数:21,代码来源:ConfigurableThreadFactoryTest.java


示例10: throwableFailureTest

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Test
public void throwableFailureTest() throws InterruptedException {
  Throwable failure = new Throwable();
  ListenableFutureAdapterTask<Object> adapter = 
      new ListenableFutureAdapterTask<>(FutureUtils.immediateFailureFuture(failure));
  
  adapter.run();

  assertTrue(adapter.isDone());
  try {
    adapter.get();
    fail("Exception shuld have thrown");
  } catch (ExecutionException e) {
    assertTrue(failure == ExceptionUtils.getRootCause(e));
  }
}
 
开发者ID:threadly,项目名称:threadly,代码行数:17,代码来源:ListenableFutureAdapterTaskTest.java


示例11: taskExceptionTest

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Test
public void taskExceptionTest() {
  Integer key = 1;
  TestExceptionHandler teh = new TestExceptionHandler();
  final RuntimeException testException = new SuppressedStackRuntimeException();
  ExceptionUtils.setDefaultExceptionHandler(teh);
  TestRunnable exceptionRunnable = new TestRuntimeFailureRunnable(testException);
  TestRunnable followRunnable = new TestRunnable();
  distributor.execute(key, exceptionRunnable);
  distributor.execute(key, followRunnable);
  exceptionRunnable.blockTillFinished();
  followRunnable.blockTillStarted();  // verify that it ran despite the exception
  
  assertEquals(1, teh.getCallCount());
  assertEquals(testException, teh.getLastThrowable());
}
 
开发者ID:threadly,项目名称:threadly,代码行数:17,代码来源:KeyDistributedExecutorTest.java


示例12: signalCompleteAnotherThreadTest

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Test
public void signalCompleteAnotherThreadTest() {
  TestRunnable waitRunnable = new TestRunnable() {
    @Override
    public void handleRunFinish() {
      try {
        verifier.waitForTest();
      } catch (Exception e) {
        throw ExceptionUtils.makeRuntime(e);
      }
    }
  };
  new Thread(waitRunnable).start();
  
  // should unblock thread
  verifier.signalComplete();
  
  waitRunnable.blockTillFinished(); // should return quickly
}
 
开发者ID:threadly,项目名称:threadly,代码行数:20,代码来源:AsyncVerifierTest.java


示例13: handleFiles

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
private Future<?> handleFiles(final List<File> fileList) {
  return scheduler.submit(new Runnable() {
    @Override
    public void run() {
      Iterator<File> it = fileList.iterator();
      while (it.hasNext()) {
        File f = it.next();
        Iterator<FileListenerInterface> lIt = listeners.iterator();
        while (lIt.hasNext()) {
          try {
            lIt.next().handleFile(f);
          } catch (Exception e) {
            ExceptionUtils.handleException(e);
          }
        }
      }
    }
  });
}
 
开发者ID:jentfoo,项目名称:JFileAnalyzer,代码行数:20,代码来源:FileCrawler.java


示例14: handleFile

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
public void handleFile(File file) {
  try {
    DigestResult dr = makeFileDigest(file);
    
    // duplicates should be rare, so we assume there is none
    List<File> dupFiles = new LinkedList<File>();
    List<File> existingList = digestToFile.putIfAbsent(dr, dupFiles);
    if (existingList != null) {
      dupFiles = existingList;
    }
    dupFiles.add(file);
    fileToDigest.put(file, dr);
  } catch (Exception e) {
    if (e instanceof FileNotFoundException) {
      // ignore
    } else {
      ExceptionUtils.handleException(e);
    }
  }
}
 
开发者ID:jentfoo,项目名称:JFileAnalyzer,代码行数:22,代码来源:DuplicateFileInspector.java


示例15: fileInArray

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
public static boolean fileInArray(File[] fileArray, File searchFile) {
  for (int i = 0; i < fileArray.length; i++) {
    try {
      if (fileArray[i].getCanonicalPath().equals(searchFile.getCanonicalPath())) {
        return true;
      }
    } catch (IOException e) {
      ExceptionUtils.handleException(e);
      
      if (fileArray[i].getAbsolutePath().equals(searchFile.getAbsolutePath())) {
        return true;
      }
    }
  }
  
  return false;
}
 
开发者ID:jentfoo,项目名称:XboxMediaProcessor,代码行数:18,代码来源:FileUtils.java


示例16: setStartHandler

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
public void setStartHandler(StepStartHandler handler) {
  if (this.handler != null && handler != null) {
    // TODO - do we need to handle multiple start handlers?  The cost is memory
    ExceptionUtils.handleException(new IllegalStateException("Pre-run condition already set"));
  }
  this.handler = handler;
}
 
开发者ID:threadly,项目名称:ambush,代码行数:9,代码来源:AbstractScriptBuilder.java


示例17: setupExceptionHandler

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
/**
 * Sets up a default {@link ExceptionHandlerInterface} so that if any uncaught exceptions occur, 
 * the script will display the exception and exit.  There should never be any uncaught 
 * exceptions, this likely would indicate a bug in Ambush. 
 */
protected static void setupExceptionHandler() {
  ExceptionUtils.setDefaultExceptionHandler(new ExceptionHandler() {
    @Override
    public void handleException(Throwable thrown) {
      synchronized (this) { // synchronized to prevent terminal corruption from multiple failures
        System.err.println("Unexpected uncaught exception: ");
        printFailureAndExit(thrown);
      }
    }
  });
}
 
开发者ID:threadly,项目名称:ambush,代码行数:17,代码来源:ScriptRunner.java


示例18: registerFailureNotification

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
public void registerFailureNotification(Runnable listener) {
  synchronized (failureListeners) {
    if (markedFailure.get()) {
      ExceptionUtils.runRunnable(listener);
    } else {
      failureListeners.add(listener);
    }
  }
}
 
开发者ID:threadly,项目名称:ambush,代码行数:11,代码来源:ExecutableScript.java


示例19: hasError

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
public void hasError(Throwable t) {
  ExceptionUtils.handleException(t);
  bodyFuture.completed(hr, responseWriter);
  bodyFuture = new BodyFuture();
  responseWriter = new ResponseWriter(this.client);
  
}
 
开发者ID:threadly,项目名称:litesockets-http,代码行数:9,代码来源:HTTPServer.java


示例20: run

import org.threadly.util.ExceptionUtils; //导入依赖的package包/类
@Override
public void run() {
  try {
    doParse();
  } catch (Exception e) {
    throw ExceptionUtils.makeRuntime(e);
  }
}
 
开发者ID:threadly,项目名称:heapDumpAnalyzer,代码行数:9,代码来源:HprofParser.java



注:本文中的org.threadly.util.ExceptionUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SyncResolver类代码示例发布时间:2022-05-22
下一篇:
Java DFSLocation类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap