Bug 545689 - Autocompletion of constructor fails due to race condition
Summary: Autocompletion of constructor fails due to race condition
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.11   Edit
Hardware: PC Mac OS X
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-22 17:23 EDT by Jason CLA
Modified: 2023-03-17 16:01 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason CLA 2019-03-22 17:23:42 EDT
Ok, so this is a weird one. It was hard for me to figure out the best way to reproduce this because the bug would only happen some of the time. I've gotten it to the point where it reproduces more than half the time on my computer.

I am assuming, given how it is not reproducible 100% of the time, that this bug is due to a race condition.

1. Paste this code into your eclipse:

public class ReproduceBug {
  final Runnable r = () -> {
    // I recommended copy/pasting this comment at least 100x in order to increase the chances of the bug occurring.
    // I recommended copy/pasting this comment at least 100x in order to increase the chances of the bug occurring.
    // I recommended copy/pasting this comment at least 100x in order to increase the chances of the bug occurring.
    // I recommended copy/pasting this comment at least 100x in order to increase the chances of the bug occurring.
  };
}

2. Copy paste the comment a bunch of times (ideally many times). This will increase the chances of the bug occurring.
3. Save the file
4. Click your mouse cursor directly after the opening curly bracket of the lambda function.
5. Press the ENTER key.
6. type "new String"
7. hit your keybinding for launching auto-complete. For me it is CTRL-SPACE
8. hit the down arrow until you get to the first constructor which takes two arguments - for me it is the (byte[], Charset) constructor
9. hit enter

EXPECTED: the text inside the lambda is "new String(bytes, charset)". The bytes variable is highlighted.

ACTUAL: the text inside the lambda is "new Stringtring". Besides the content being wrong, the cursor is now on the following line.

Note: If you can't reproduce, delete the code you added and try doing steps 3 through 9 again, executing the steps as quickly as you can. Maybe try copy pasting the comment some more times to make it even longer.
Comment 1 Jay Arthanareeswaran CLA 2019-04-03 01:28:33 EDT
I tried a few times but can't reproduce even after several tries with couple of hundreds of duplicated comments. The fact that the comments have an impact indicate that parsing can't be involved. Something wrong in fetching the content from the editor?
Comment 2 Eclipse Genie CLA 2021-03-25 08:54:49 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Eclipse Genie CLA 2023-03-17 16:01:35 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.