use of org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace in project bisq-desktop by bisq-network.
the class BisqApp method init.
// NOTE: This method is not called on the JavaFX Application Thread.
@Override
public void init() throws Exception {
String logPath = Paths.get(bisqEnvironment.getProperty(AppOptionKeys.APP_DATA_DIR_KEY), "bisq").toString();
Log.setup(logPath);
log.info("Log files under: " + logPath);
Utilities.printSysInfo();
Log.setLevel(Level.toLevel(bisqEnvironment.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY)));
UserThread.setExecutor(Platform::runLater);
UserThread.setTimerClass(UITimer.class);
shutDownHandler = this::stop;
// setup UncaughtExceptionHandler
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
// Might come from another thread
if (throwable.getCause() != null && throwable.getCause().getCause() != null && throwable.getCause().getCause() instanceof BlockStoreException) {
log.error(throwable.getMessage());
} else if (throwable instanceof ClassCastException && "sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData".equals(throwable.getMessage())) {
log.warn(throwable.getMessage());
} else {
log.error("Uncaught Exception from thread " + Thread.currentThread().getName());
log.error("throwableMessage= " + throwable.getMessage());
log.error("throwableClass= " + throwable.getClass());
log.error("Stack trace:\n" + ExceptionUtils.getStackTrace(throwable));
throwable.printStackTrace();
UserThread.execute(() -> showErrorPopup(throwable, false));
}
};
Thread.setDefaultUncaughtExceptionHandler(handler);
Thread.currentThread().setUncaughtExceptionHandler(handler);
try {
Utilities.checkCryptoPolicySetup();
} catch (NoSuchAlgorithmException | LimitedKeyStrengthException e) {
e.printStackTrace();
UserThread.execute(() -> showErrorPopup(e, true));
}
Security.addProvider(new BouncyCastleProvider());
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();
Res.setBaseCurrencyCode(currencyCode);
Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName());
CurrencyUtil.setBaseCurrencyCode(currencyCode);
Capabilities.setSupportedCapabilities(new ArrayList<>(Arrays.asList(Capabilities.Capability.TRADE_STATISTICS.ordinal(), Capabilities.Capability.TRADE_STATISTICS_2.ordinal(), Capabilities.Capability.ACCOUNT_AGE_WITNESS.ordinal(), Capabilities.Capability.COMP_REQUEST.ordinal(), Capabilities.Capability.VOTE.ordinal())));
}
use of org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace in project cuba by cuba-platform.
the class PersistenceManager method refreshStatistics.
@Authenticated
@Override
public String refreshStatistics(String entityName) {
if (StringUtils.isBlank(entityName))
return "Pass an entity name (MetaClass name, e.g. sec$User) or 'all' to refresh statistics for all entities.\n" + "Be careful, it can take very long time.";
try {
log.info("Refreshing statistics for " + entityName);
Consumer<MetaClass> refreshStatisticsForEntity = mc -> {
MetaClass originalMetaClass = metadata.getExtendedEntities().getOriginalOrThisMetaClass(mc);
Class javaClass = originalMetaClass.getJavaClass();
Table annotation = (Table) javaClass.getAnnotation(Table.class);
if (annotation != null) {
persistenceManager.refreshStatisticsForEntity(originalMetaClass.getName());
}
};
if ("all".equals(entityName)) {
for (MetaClass metaClass : metadata.getSession().getClasses()) {
refreshStatisticsForEntity.accept(metaClass);
}
} else {
MetaClass metaClass = metadata.getSession().getClass(entityName);
if (metaClass == null)
return "MetaClass not found: " + entityName;
refreshStatisticsForEntity.accept(metaClass);
}
return "Done";
} catch (Exception e) {
log.error("refreshStatistics error", e);
return ExceptionUtils.getStackTrace(e);
}
}
use of org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace in project sqlg by pietermartin.
the class GraphStrategy method apply.
void apply() {
final Step<?, ?> startStep = traversal.getStartStep();
if (!(startStep instanceof GraphStep)) {
return;
}
final GraphStep originalGraphStep = (GraphStep) startStep;
if (this.sqlgGraph.features().supportsBatchMode() && this.sqlgGraph.tx().isInNormalBatchMode()) {
this.sqlgGraph.tx().flush();
}
if (originalGraphStep.getIds().length > 0) {
Object id = originalGraphStep.getIds()[0];
if (id != null) {
Class clazz = id.getClass();
if (!Stream.of(originalGraphStep.getIds()).allMatch(i -> clazz.isAssignableFrom(i.getClass())))
throw Graph.Exceptions.idArgsMustBeEitherIdOrElement();
}
}
if (this.canNotBeOptimized()) {
this.logger.debug("gremlin not optimized due to path or tree step. " + this.traversal.toString() + "\nPath to gremlin:\n" + ExceptionUtils.getStackTrace(new Throwable()));
return;
}
combineSteps();
}
use of org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace in project batfish by batfish.
the class Driver method mainRunWorkService.
private static void mainRunWorkService() {
if (_mainSettings.getTracingEnable() && !GlobalTracer.isRegistered()) {
initTracer();
}
String protocol = _mainSettings.getSslDisable() ? "http" : "https";
String baseUrl = String.format("%s://%s", protocol, _mainSettings.getServiceBindHost());
URI baseUri = UriBuilder.fromUri(baseUrl).port(_mainSettings.getServicePort()).build();
_mainLogger.debug(String.format("Starting server at %s\n", baseUri));
ResourceConfig rc = new ResourceConfig(Service.class).register(new JettisonFeature());
if (_mainSettings.getTracingEnable()) {
rc.register(ServerTracingDynamicFeature.class);
}
try {
if (_mainSettings.getSslDisable()) {
GrizzlyHttpServerFactory.createHttpServer(baseUri, rc);
} else {
CommonUtil.startSslServer(rc, baseUri, _mainSettings.getSslKeystoreFile(), _mainSettings.getSslKeystorePassword(), _mainSettings.getSslTrustAllCerts(), _mainSettings.getSslTruststoreFile(), _mainSettings.getSslTruststorePassword(), ConfigurationLocator.class, Driver.class);
}
if (_mainSettings.getCoordinatorRegister()) {
// this function does not return until registration succeeds
registerWithCoordinatorPersistent();
}
if (_mainSettings.getParentPid() > 0) {
if (SystemUtils.IS_OS_WINDOWS) {
_mainLogger.errorf("Parent process monitoring is not supported on Windows. We'll live without it.");
} else {
Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new CheckParentProcessTask(_mainSettings.getParentPid()), 0, PARENT_CHECK_INTERVAL_MS, TimeUnit.MILLISECONDS);
SignalHandler handler = signal -> _mainLogger.infof("BFS: Ignoring signal %s\n", signal);
Signal.handle(new Signal("INT"), handler);
}
}
// sleep indefinitely, check for parent pid and coordinator each time
while (true) {
Thread.sleep(COORDINATOR_CHECK_INTERVAL_MS);
/*
* every time we wake up, we check if the coordinator has polled us recently
* if not, re-register the service. the coordinator might have died and come back.
*/
if (_mainSettings.getCoordinatorRegister() && new Date().getTime() - _lastPollFromCoordinator.getTime() > COORDINATOR_POLL_TIMEOUT_MS) {
// this function does not return until registration succeeds
registerWithCoordinatorPersistent();
}
}
} catch (ProcessingException e) {
String msg = "FATAL ERROR: " + e.getMessage() + "\n";
_mainLogger.error(msg);
System.exit(1);
} catch (Exception ex) {
String stackTrace = ExceptionUtils.getStackTrace(ex);
_mainLogger.error(stackTrace);
System.exit(1);
}
}
use of org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace in project batfish by batfish.
the class Driver method mainRunWatchdog.
private static void mainRunWatchdog() {
while (true) {
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
String classPath = runtimeMxBean.getClassPath();
List<String> jvmArguments = runtimeMxBean.getInputArguments().stream().filter(// remove IntelliJ hooks
arg -> !arg.startsWith("-agentlib:")).collect(ImmutableList.toImmutableList());
int myPid = Integer.parseInt(runtimeMxBean.getName().split("@")[0]);
List<String> command = new ImmutableList.Builder<String>().add(Paths.get(System.getProperty("java.home"), "bin", "java").toAbsolutePath().toString()).addAll(jvmArguments).add("-cp").add(classPath).add(Driver.class.getCanonicalName()).add("-" + Settings.ARG_RUN_MODE).add(RunMode.WORKSERVICE.toString()).add("-" + Settings.ARG_PARENT_PID).add(Integer.toString(myPid)).addAll(Arrays.asList(_mainArgs)).build();
_mainLogger.debugf("Will start workservice with arguments: %s\n", command);
ProcessBuilder builder = new ProcessBuilder(command);
builder.redirectErrorStream(true);
builder.redirectInput(Redirect.INHERIT);
Process process;
try {
process = builder.start();
} catch (IOException e) {
_mainLogger.errorf("Exception starting process: %s", ExceptionUtils.getStackTrace(e));
_mainLogger.errorf("Will try again in 1 second\n");
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
_mainLogger.errorf("Sleep was interrrupted: %s", ExceptionUtils.getStackTrace(e1));
}
continue;
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
reader.lines().forEach(line -> _mainLogger.output(line + "\n"));
} catch (IOException e) {
_mainLogger.errorf("Interrupted while reading subprocess stream: %s", ExceptionUtils.getStackTrace(e));
}
try {
process.waitFor();
} catch (InterruptedException e) {
_mainLogger.infof("Subprocess was killed: %s.\nRestarting", ExceptionUtils.getStackTrace(e));
}
}
}
Aggregations