Skip to content

Commit

Permalink
Add stack trace print for jlm test connect exceptions (#403)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Rushton <srushton@redhat.com>
  • Loading branch information
lumpfish authored Feb 9, 2021
1 parent 1340622 commit 116a1aa
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,23 @@ private void getStatsViaProxy() {
ie.printStackTrace();
Assert.fail("The sleeping profiler was interrupted");
} catch (UndeclaredThrowableException ue) {
// If the exception was caused by a Connect or Unmarshal Exception
// assume the monitored JVM has finished.
Throwable cause = ue.getCause();
Class<ConnectException> connectExcept = ConnectException.class;
Class<UnmarshalException> unmarshalExcept = UnmarshalException.class;

if (connectExcept.isInstance(cause) || unmarshalExcept.isInstance(cause)) {

// If the exception was caused by a Connect or Unmarshal
// Exception, assume the monitored JVM has finished.
this.closeCSVFile();
Message.logOut("Exiting as JVM we are connected to has finished");
Assert.fail("Exiting as JVM we are connected to has finished");
} else {
Message.logOut(ue.getMessage());
ue.printStackTrace();
Assert.fail(ue.getMessage());
String msg = "";
if (connectExcept.isInstance(cause)) {
msg = "Exiting as ConnectException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
}
else if (unmarshalExcept.isInstance(cause)) {
msg = "Exiting as UnmarshalException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
}
msg += ue.getMessage();
this.closeCSVFile();
Message.logOut(msg);
ue.printStackTrace();
Assert.fail(msg);
} finally {
this.closeCSVFile();
}
Expand Down Expand Up @@ -258,17 +259,22 @@ private void getStatsViaServer() {
Thread.sleep(1000);
secondsCnt++;
}

// If the exception is a Connect or Unmarshal Exception, assume the
// monitored JVM has finished
// If the exception is a Connect or Unmarshal Exception assume the
// monitored JVM has finished.
} catch (ConnectException ce) {
this.closeCSVFile();
Message.logOut("Exiting as JVM we are connected to has finished");
Assert.fail("Exiting as JVM we are connected to has finished");
String msg = "Exiting as ConnectException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
msg += ce.getMessage();
Message.logOut(msg);
ce.printStackTrace();
Assert.fail(msg);
} catch (UnmarshalException ue) {
this.closeCSVFile();
Message.logOut("Exiting as JVM we are connected to has finished");
Assert.fail("Exiting as JVM we are connected to has finished");
String msg = "Exiting as UnmarshalException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
msg += ue.getMessage();
Message.logOut(msg);
ue.printStackTrace();
Assert.fail(msg);
} catch (InterruptedException ie) {
Message.logOut("The sleeping profiler was interrupted");
ie.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,23 @@ private void getStatsViaProxy() {
ie.printStackTrace();
Assert.fail("The sleeping profiler was interrupted");
} catch (UndeclaredThrowableException ue) {
// If the exception was caused by a Connect or Unmarshal Exception, assume the
// monitored JVM has finished.
// If the exception was caused by a Connect or Unmarshal Exception
// assume the monitored JVM has finished.
Throwable cause = ue.getCause();
Class<ConnectException> connectExcept = ConnectException.class;
Class<UnmarshalException> unmarshalExcept = UnmarshalException.class;

if (connectExcept.isInstance(cause) || unmarshalExcept.isInstance(cause)) {
this.closeCSVFile();
Message.logOut("Exiting as JVM we are connected to has finished");
Class<ConnectException> connectExcept = ConnectException.class;
Class<UnmarshalException> unmarshalExcept = UnmarshalException.class;
String msg = "";
if (connectExcept.isInstance(cause)) {
msg = "Exiting as ConnectException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
}
else {
Message.logOut("Rethrowing UndeclaredThrowableException");
else if (unmarshalExcept.isInstance(cause)) {
msg = "Exiting as UnmarshalException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
}
Assert.fail();
msg += ue.getMessage();
this.closeCSVFile();
Message.logOut(msg);
ue.printStackTrace();
Assert.fail(msg);
} finally {
this.closeCSVFile();
}
Expand Down Expand Up @@ -256,12 +259,22 @@ private void getStatsViaServer() {
Thread.sleep(1000);
secondsCnt++;
}
// If the exception is a Connect or Unmarshal Exception assume the
// monitored JVM has finished.
} catch (ConnectException ce) {
this.closeCSVFile();
Assert.fail("Exiting as JVM we are connected to has finished");
String msg = "Exiting as ConnectException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
msg += ce.getMessage();
Message.logOut(msg);
ce.printStackTrace();
Assert.fail(msg);
} catch (UnmarshalException ue) {
this.closeCSVFile();
Assert.fail("Exiting as JVM we are connected to has finished");
String msg = "Exiting as UnmarshalException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
msg += ue.getMessage();
Message.logOut(msg);
ue.printStackTrace();
Assert.fail(msg);
} catch (InterruptedException ie) {
ie.printStackTrace();
Assert.fail("The sleeping profiler was interrupted");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,18 @@ private void getStatsViaProxy() {
Throwable cause = ue.getCause();
Class<ConnectException> connectExcept = ConnectException.class;
Class<UnmarshalException> unmarshalExcept = UnmarshalException.class;

if (connectExcept.isInstance(cause) || unmarshalExcept.isInstance(cause)) {
this.closeCSVFile();
Message.logOut("Exiting as JVM we are connected to has finished");
Assert.fail("Exiting as JVM we are connected to has finished");
} else {
Message.logOut(ue.getMessage());
ue.printStackTrace();
Assert.fail(ue.getMessage());
String msg = "";
if (connectExcept.isInstance(cause)) {
msg = "Exiting as ConnectException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
}
else if (unmarshalExcept.isInstance(cause)) {
msg = "Exiting as UnmarshalException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
}
msg += ue.getMessage();
this.closeCSVFile();
Message.logOut(msg);
ue.printStackTrace();
Assert.fail(msg);
} finally {
this.closeCSVFile();
}
Expand Down Expand Up @@ -207,12 +209,18 @@ private void getStatsViaServer() {
// monitored JVM has finished.
} catch (ConnectException ce) {
this.closeCSVFile();
Message.logOut("Exiting as JVM we are connected to has finished");
Assert.fail("Exiting as JVM we are connected to has finished");
String msg = "Exiting as ConnectException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
msg += ce.getMessage();
Message.logOut(msg);
ce.printStackTrace();
Assert.fail(msg);
} catch (UnmarshalException ue) {
this.closeCSVFile();
Message.logOut("Exiting as JVM we are connected to has finished");
Assert.fail("Exiting as JVM we are connected to has finished");
String msg = "Exiting as UnmarshalException thrown receiving data from the connected JVM. This may mean the JVM we are connected to has finished. ";
msg += ue.getMessage();
Message.logOut(msg);
ue.printStackTrace();
Assert.fail(msg);
} catch (InterruptedException ie) {
Message.logOut("The sleeping profiler was interrupted");
ie.printStackTrace();
Expand Down

0 comments on commit 116a1aa

Please sign in to comment.