Open GoogleCodeExporter opened 9 years ago
Something I'll have to investigate further when I have time. Issue with Java
reflection call, but I'm not intimately familiar with Java reflection.
Original comment by manga...@gmail.com
on 25 Mar 2011 at 6:25
Just a thought, maybe this has to do with Java exceptions. Perhaps when
throwing exceptions it is considered another argument/parameter, so reflection
call needs to pass some additional expected parameter? Need to research...
If true, code will have to figure out from reflection call whether the method
actually throws an exception on a given code path, and handle that accordingly.
Original comment by manga...@gmail.com
on 25 Mar 2011 at 6:40
From researching related issue for .NET implementation, this is the reason for
the issue and the likely solution:
http://download.oracle.com/javase/1.4.2/docs/api/java/lang/reflect/InvocationTar
getException.html#getTargetException()
Original comment by manga...@gmail.com
on 14 Sep 2011 at 5:35
To be fixed with next patch release.
Original comment by manga...@gmail.com
on 18 Sep 2011 at 1:17
From developer feedback as well:
Hi David
I think the issue may be in the catch block of the run_keyword method of the
RemoteServerMethods class. InvocationTargetException may be swallowing your
error messages. A possible workaround is to check if the exception you catch is
an InvocationTargetException and handle its cause instead.
Also, you are getting an ugly stack trace because you are not handling it
properly. The idiomatic way to do it is:
e.printStackTrace(new PrintWriter(stringWriter));
String stktrc = stringWriter.toString();
Ugly, and hard to guess or remember (I have to google for it every time I need
it), but you wanted to use Java :P
This is what the catch block should look like:
catch (Throwable e) {
if(e instanceof InvocationTargetException){
e = e.getCause();
}
e.printStackTrace();
kr.put("status", "FAIL");
kr.put("return", "");
kr.put("error",e.getMessage());
kr.put("output",e.getMessage());
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
String stktrc = stringWriter.toString();
kr.put("traceback", stktrc);
return kr;
}
Hope that helps
Original comment by manga...@gmail.com
on 18 Sep 2011 at 1:25
This should be fixed with the new release at
https://github.com/ombre42/jrobotremoteserver
Original comment by manga...@gmail.com
on 21 Jul 2012 at 5:52
Original issue reported on code.google.com by
manga...@gmail.com
on 25 Mar 2011 at 6:24