Skip to content

Commit

Permalink
#80: Add a simple progress indication for report creation - fixed NPE…
Browse files Browse the repository at this point in the history
… in case TaskManager.startProgress() was not called
  • Loading branch information
jowerner committed Apr 22, 2021
1 parent 08b32a6 commit 65d723f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/com/xceptance/xlt/report/util/TaskManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ private static class SingletonHolder
private static final long INTERVAL = 500;

/**
* The current progress bar
* The current progress bar. Never <code>null</code>. Note that the initial progress bar is inactive. To get active
* visual progress, call {@link #startProgress(String)}.
*/
private volatile ProgressBar progressBar;
private volatile ProgressBar progressBar = new ProgressBarBuilder().setStyle(ProgressBarStyle.ASCII).build().pause();

/**
* Total task for that progress
* Total tasks for the progress bar.
*/
private final AtomicInteger totalTasks = new AtomicInteger(0);

Expand Down Expand Up @@ -125,12 +126,15 @@ public void run()
try
{
task.run();
progressBar.step();
}
catch (Exception e)
{
log.error("Failed to execute task", e);
}
finally
{
progressBar.step();
}
}
});
}
Expand Down

0 comments on commit 65d723f

Please sign in to comment.