Skip to content

Commit

Permalink
fix: corrected implementation of tracing executor
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Jan 11, 2024
1 parent efe5595 commit 5091b1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public OSourceTraceExecutorService(ExecutorService service) {

@Override
public void execute(Runnable command) {
final OTracedExecutionException trace = OTracedExecutionException.prepareTrace(command);
this.service.execute(
() -> {
final OTracedExecutionException trace = OTracedExecutionException.prepareTrace(command);
try {
command.run();
} catch (RuntimeException e) {
Expand Down Expand Up @@ -59,9 +59,9 @@ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedE

@Override
public <T> Future<T> submit(Callable<T> task) {
final OTracedExecutionException trace = OTracedExecutionException.prepareTrace(task);
return this.service.submit(
() -> {
final OTracedExecutionException trace = OTracedExecutionException.prepareTrace(task);
try {
return task.call();
} catch (RuntimeException e) {
Expand All @@ -72,9 +72,9 @@ public <T> Future<T> submit(Callable<T> task) {

@Override
public <T> Future<T> submit(Runnable task, T result) {
final OTracedExecutionException trace = OTracedExecutionException.prepareTrace(task);
return this.service.submit(
() -> {
final OTracedExecutionException trace = OTracedExecutionException.prepareTrace(task);
try {
task.run();
} catch (RuntimeException e) {
Expand All @@ -86,9 +86,9 @@ public <T> Future<T> submit(Runnable task, T result) {

@Override
public Future<?> submit(Runnable task) {
final OTracedExecutionException trace = OTracedExecutionException.prepareTrace(task);
return this.service.submit(
() -> {
final OTracedExecutionException trace = OTracedExecutionException.prepareTrace(task);
try {
task.run();
} catch (RuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.orientechnologies.common.thread;

import com.orientechnologies.common.exception.OException;
import com.orientechnologies.common.log.OLogManager;

public class OTracedExecutionException extends OException {

Expand All @@ -23,13 +22,8 @@ private static String taskName(Object task) {

public static OTracedExecutionException prepareTrace(Object task) {
final OTracedExecutionException trace;
if (OLogManager.instance().isDebugEnabled()) {
trace =
new OTracedExecutionException(String.format("Async task [%s] failed", taskName(task)));
trace.fillInStackTrace();
} else {
trace = null;
}
trace = new OTracedExecutionException(String.format("Async task [%s] failed", taskName(task)));
trace.fillInStackTrace();
return trace;
}

Expand Down

0 comments on commit 5091b1c

Please sign in to comment.