RFR: JDK-8317920: JDWP-agent sends broken exception event with onthrow option [v4]

Johannes Bechberger jbechberger at openjdk.org
Tue Oct 17 20:43:56 UTC 2023


On Tue, 17 Oct 2023 20:32:52 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:

>> test/jdk/com/sun/jdi/JdwpOnThrowTest.java line 76:
>> 
>>> 74:                     while(eventIterator.hasNext() && start + TIMEOUT > System.currentTimeMillis()) {
>>> 75:                         Event event = eventIterator.next();
>>> 76:                         if (event instanceof ExceptionEvent ex) {
>> 
>> It's a bit unclear to me why this test is even seeing the ExceptionEvent since I don't see any place where an ExceptionEventRequest has been setup.
>
> It seems that ex.request()) is null for this event. The spec for Event.request() says null might happen for VMDeath events, but doesn't mention any other. In any case, I guess JDI does not filter out any events for which there is not a request, which is why the test is seeing it. This also means the event could be considered unexpected if the debugger did not explicitly add an ExceptionEventRequest, and it could in fact cause an NPE if the debugger decides to look at ex.request().
> 
> On the other hand, I think if the debug agent requires that a handler be in place (as a result of the debugger creating and enabling the EventRequest) in order for onthrow to send the event, then the handler creation might come too late, and the event will get filtered out.

Yes, so the current way is probably ok?

IDEs like IntelliJ properly handle the exception event that is sent and don't report an error, so I don't see a problem.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16145#discussion_r1362744055


More information about the serviceability-dev mailing list