This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 203702 - Copy/pasting a code with automatically added imports duplicates type identifiers
Summary: Copy/pasting a code with automatically added imports duplicates type identifiers
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.1
Hardware: PC Linux
: P2 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords: REGRESSION
: 203692 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-14 09:33 UTC by J Bachorik
Modified: 2011-12-09 15:15 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Test project (11.99 KB, application/octet-stream)
2011-10-14 09:34 UTC, J Bachorik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description J Bachorik 2011-10-14 09:33:34 UTC
When copying the following code snippet:
List<String> a = new LinkedList<String>();

into a different source which contains no import statement for java.util.LinkedList type.

After pasting the code snippet the target source will have its imports section updated correctly but the type identifiers in the pasted par will get duplicated, resulting in:
ListList<StringString> a = new LinkedListLinkedList<StringString>();

I am attaching a test project where you can play by copying line 16 from the ClassB into line 19 of the ClassA. Also, it is worth noting that once you clean/build the project this error becomes rather random with cca. 70% probability of encountering it.
Comment 1 J Bachorik 2011-10-14 09:34:28 UTC
Created attachment 112045 [details]
Test project
Comment 2 Dusan Balek 2011-10-17 11:13:39 UTC
Problem seems to be a race condition in ClipboardHandler.runQuickly that runs the task computing imports twice sometimes.
Comment 3 Jan Lahoda 2011-10-17 11:49:44 UTC
Oops. Thanks for the pointer. I intended to do create-schedule, but did post-schedule instead, which actually runs the task twice.
http://hg.netbeans.org/jet-main/rev/03bb18e2f697
Comment 4 Quality Engineering 2011-10-18 14:13:39 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/03bb18e2f697
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #203702: post already scheduled the task, no need (and actually harmful) to schedule it again.
Comment 5 Jan Lahoda 2011-11-02 16:29:36 UTC
*** Bug 203692 has been marked as a duplicate of this bug. ***
Comment 6 Jiri Prox 2011-12-09 15:15:05 UTC
verified