8262080: vmTestbase/nsk/jdi/Event/request/request001/TestDescription.java failed with "ERROR: new event is not ThreadStartEvent"
Reviewed-by: cjplummer, sspitsyn
This commit is contained in:
parent
0b5216a922
commit
57fc8e9b35
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -355,7 +355,7 @@ public class request001 extends JDIBase {
|
||||
vm.resume();
|
||||
|
||||
log2("......waiting for ThreadStartEvent");
|
||||
getEventSet();
|
||||
getEventSetForThreadStartDeath("thread2");
|
||||
eventSets[10] = eventSet;
|
||||
|
||||
Event receivedEvent = eventIterator.nextEvent();
|
||||
@ -370,7 +370,7 @@ public class request001 extends JDIBase {
|
||||
vm.resume();
|
||||
|
||||
log2("......waiting for ThreadDeathEvent");
|
||||
getEventSet();
|
||||
getEventSetForThreadStartDeath("thread2");
|
||||
eventSets[9] = eventSet;
|
||||
receivedEvent = eventIterator.nextEvent();
|
||||
if ( !(receivedEvent instanceof ThreadDeathEvent) ) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,6 +34,8 @@ import com.sun.jdi.event.Event;
|
||||
import com.sun.jdi.event.EventIterator;
|
||||
import com.sun.jdi.event.EventQueue;
|
||||
import com.sun.jdi.event.EventSet;
|
||||
import com.sun.jdi.event.ThreadDeathEvent;
|
||||
import com.sun.jdi.event.ThreadStartEvent;
|
||||
import com.sun.jdi.request.BreakpointRequest;
|
||||
import com.sun.jdi.request.EventRequest;
|
||||
import com.sun.jdi.request.EventRequestManager;
|
||||
@ -150,6 +152,37 @@ public class JDIBase {
|
||||
}
|
||||
}
|
||||
|
||||
// Special version of getEventSet for ThreadStartEvent/ThreadDeathEvent.
|
||||
// When ThreadStartRequest and/or ThreadDeathRequest are enabled,
|
||||
// we can get the events from system threads unexpected for tests.
|
||||
// The method skips ThreadStartEvent/ThreadDeathEvent events
|
||||
// for all threads except the expected one.
|
||||
protected void getEventSetForThreadStartDeath(String threadName) throws JDITestRuntimeException {
|
||||
boolean gotDesiredEvent = false;
|
||||
while (!gotDesiredEvent) {
|
||||
getEventSet();
|
||||
Event event = eventIterator.nextEvent();
|
||||
if (event instanceof ThreadStartEvent evt) {
|
||||
if (evt.thread().name().equals(threadName)) {
|
||||
gotDesiredEvent = true;
|
||||
} else {
|
||||
log2("Got ThreadStartEvent for wrong thread: " + event);
|
||||
}
|
||||
} else if (event instanceof ThreadDeathEvent evt) {
|
||||
if (evt.thread().name().equals(threadName)) {
|
||||
gotDesiredEvent = true;
|
||||
} else {
|
||||
log2("Got ThreadDeathEvent for wrong thread: " + event);
|
||||
}
|
||||
} else {
|
||||
// not ThreadStartEvent nor ThreadDeathEvent
|
||||
gotDesiredEvent = true;
|
||||
}
|
||||
}
|
||||
// reset the iterator before return
|
||||
eventIterator = eventSet.eventIterator();
|
||||
}
|
||||
|
||||
protected void breakpointForCommunication() throws JDITestRuntimeException {
|
||||
|
||||
log2("breakpointForCommunication");
|
||||
|
Loading…
Reference in New Issue
Block a user