Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 203702 - Copy/pasting a code with automatically added imports duplicates type identifiers
Copy/pasting a code with automatically added imports duplicates type identifiers
Status: VERIFIED FIXED
Product: java
Classification: Unclassified
Component: Editor
7.1
PC Linux
: P2 (vote)
: 7.1
Assigned To: Jan Lahoda
issues@java
: REGRESSION
: 203692 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
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
:


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


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo