-
Notifications
You must be signed in to change notification settings - Fork 740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java21] Fix failing debugger for java 21 #43448
base: java21
Are you sure you want to change the base?
Conversation
|
||
// variables outside worker should not be visible | ||
Assert.assertFalse(localVariables.containsKey("a")); | ||
if (debugHitInfo.getKey().getLine() == 23) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix is added because with new virtual thread implementation, the order of execution for workers is not consistent. Therefore, we can't rely on the debug point hitting order. I modified the assertions depending on which debug point hits first.
@warunalakshitha Is this expected?
@@ -83,7 +83,7 @@ public void stackFrameDebugTest() throws BallerinaTestException { | |||
// Stack frame representation test for strand creation with 'start' keyword. | |||
// Results of the strand is not assigned to any variable. In this case frame name is assigned to 'anonymous'. | |||
debugTestRunner.assertCallStack(frames[0], "sayHello", 45, "main.bal"); | |||
debugTestRunner.assertCallStack(frames[1], "start:anonymous", 10, "main.bal"); | |||
debugTestRunner.assertCallStack(frames[1], "start:anon", 10, "main.bal"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, the default strand name is changed to anon
if the future value name is not provided.
ClassPrepareRequest classPrepareRequest = erm.createClassPrepareRequest(); | ||
classPrepareRequest.enable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make it consistent with L1112 and L1113
ClassPrepareRequest classPrepareRequest = erm.createClassPrepareRequest(); | |
classPrepareRequest.enable(); | |
ClassPrepareRequest classPrepareRequest = erm.createClassPrepareRequest().enable(); |
private static final Logger LOGGER = LoggerFactory.getLogger(JDIEventProcessor.class); | ||
private static final List<ThreadReference> virtualThreads = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static final Logger LOGGER = LoggerFactory.getLogger(JDIEventProcessor.class); | |
private static final List<ThreadReference> virtualThreads = new ArrayList<>(); | |
private static final Logger LOGGER = LoggerFactory.getLogger(JDIEventProcessor.class); | |
private static final List<ThreadReference> virtualThreads = new ArrayList<>(); |
private static final Logger LOGGER = LoggerFactory.getLogger(JDIEventProcessor.class); | |
private static final List<ThreadReference> virtualThreads = new ArrayList<>(); | |
private static final List<ThreadReference> virtualThreads = new ArrayList<>(); | |
private static final Logger LOGGER = LoggerFactory.getLogger(JDIEventProcessor.class); | |
} else if (event instanceof ThreadStartEvent threadStartEvent) { | ||
ThreadReference thread = threadStartEvent.thread(); | ||
if (thread.isVirtual()) { | ||
synchronized (virtualThreads) { | ||
virtualThreads.add(thread); | ||
} | ||
} | ||
eventSet.resume(); | ||
} else if (event instanceof ThreadDeathEvent threadDeathEvent) { | ||
ThreadReference thread = threadDeathEvent.thread(); | ||
synchronized (virtualThreads) { | ||
virtualThreads.remove(thread); | ||
} | ||
eventSet.resume(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the virtualThreads
variable, using a ConcurrentLinkedQueue
or CopyOnWriteArrayList
(concurrent data structures) is generally better than using an ArrayList with explicit synchronization blocks.
Purpose
$subject
Fixes #43430
Approach
Samples
Remarks
Check List