Menu

#1743 Stack trace is not emitted when exception is thrown

2.18
closed
RBRi
None
1
2017-05-25
2016-02-06
No

I'm migrating GWT to use htmlunit-2.19 and htmlunit-js-core-2.17 (from both 2.13).
However one unit test that is testing stacktrace de-obfuscation is failing, because on the client side, the stacktrace is not emitted:

  private void throwException(String arg) {
    // prevent inlining by double referencing arg
    throw new RuntimeException(arg.charAt(0) + arg.substring(1));
  }

  @Override
  public void onSuccess() {
    try {
      throwException("Runtime Exception");
    } catch (Exception e) {
      String stack = e.toString();
      stack += "\n";
      for (StackTraceElement element : e.getStackTrace()) {
        stack += element + "\n";
      }
      Window.alert(stack);

When htmlunit-js-core-2.15 is used, then the following output is created (and the unit test is working):

~~~text
java.lang.RuntimeException: Runtime Exception
at java.lang.Throwable.Throwable(Throwable.java:65)
at java.lang.Exception.Exception(Exception.java:28)
at java.lang.RuntimeException.RuntimeException(RuntimeException.java:28)
at com.google.gwt.user.client.rpc.LoggingRPCTest.throwException(LoggingRPCTest.java:40)
at com.google.gwt.user.client.rpc.LoggingRPCTest$2.onSuccess(LoggingRPCTest.java:149)
at com.google.gwt.core.client.impl.AsyncFragmentLoader.onLoadImpl(AsyncFragmentLoader.java:574)
at com.google.gwt.core.client.impl.AsyncFragmentLoader.onLoad(AsyncFragmentLoader.java:275)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java:236)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:275)
at Unknown.anonymous(Unknown Source)
~~~

When htmlunit-js-core-2.16 or htmlunit-js-core-2.17 is used, e.getStackTrace() is empty and the unit test is failing (there is nothing to de-obfuscate). What was changed? Can htmlunit be configured so that stacktrace is generated correctly, like it was the case in versions < htmlunit-js-core-2.16?

Thanks.

Discussion

  • RBRi

    RBRi - 2017-05-25

    I guess this is a duplicate of 1606.
    Please try with the latest snapshot and open an new issue if this is still a problem.

     
  • RBRi

    RBRi - 2017-05-25
    • status: open --> closed
    • assigned_to: RBRi
     

Log in to post a comment.

MongoDB Logo MongoDB