Skip to content

Commit

Permalink
Improve exception handling and assume distributed environments in cas…
Browse files Browse the repository at this point in the history
…e log files cannot be read.
  • Loading branch information
jherter committed Oct 5, 2018
1 parent 891f953 commit 2479a02
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/main/java/com/absint/astree/StatusPoller.java
Expand Up @@ -38,7 +38,9 @@
*/
class StatusPoller extends Thread {

static private long INITIAL_DELAY = 1 * 1000;
static private long INITIAL_DELAY = 1 * 1000;
static private String OFF_MSG = "[NOTE] Analyzer log not available in console. " +
"Analysis may be running on a remote machine.\n";

private long interval;
private boolean alive;
Expand All @@ -63,13 +65,16 @@ class StatusPoller extends Thread {


public void run() {
boolean active = true;
RandomAccessFile fileHandler = null;
StringBuilder sb = null;
boolean active = true;
boolean exceptionCaught = false;
RandomAccessFile fileHandler = null;
StringBuilder sb = null;

long lpos = 0, cpos;
try { this.sleep(INITIAL_DELAY); }
catch(InterruptedException e) {}
while(active) {

while(active && !exceptionCaught) {
if(!alive) // last update
active = false;
try {
Expand All @@ -88,10 +93,14 @@ public void run() {
catch(InterruptedException ie) {
}
catch( FileNotFoundException e ) {
e.printStackTrace();
if(!exceptionCaught)
this.listener.getLogger().print(OFF_MSG);
exceptionCaught = true;
}
catch( IOException e ) {
e.printStackTrace();
if(!exceptionCaught)
this.listener.getLogger().print(OFF_MSG);
exceptionCaught = true;
}
finally {
if (fileHandler != null )
Expand Down

0 comments on commit 2479a02

Please sign in to comment.