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 255185 - Find and Replace is redoing the replace in some specific scenarios, generating wrong results
Summary: Find and Replace is redoing the replace in some specific scenarios, generatin...
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Search (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal (vote)
Assignee: Milutin Kristofic
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2015-09-10 14:13 UTC by Michel Graciano
Modified: 2015-09-16 08:49 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 211444


Attachments
nps snapshot (720.59 KB, application/nps)
2015-09-10 14:13 UTC, Michel Graciano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Graciano 2015-09-10 14:13:24 UTC
This issue was reported manually by hmichel.
It already has 2 duplicates 


Build: NetBeans IDE Dev (Build 20150909-6ff4934e5978)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Java(TM) SE Runtime Environment, 1.8.0_51-b16
OS: Linux

User Comments:
GUEST: was replacing      @Test   with  //     @Test  In a JUnit test class. 
Selected the Replace Backwards checkbox.  Slowness was definitely the result.

hmichel: Using Find and Replace Ui to replace some text on a selection in the editor. 20 lines were selected more or less.



Maximum slowness yet reported was 55703 ms, average is 45977
Comment 1 Michel Graciano 2015-09-10 14:13:33 UTC
Created attachment 156063 [details]
nps snapshot
Comment 2 Michel Graciano 2015-09-10 14:17:29 UTC
This happened when I tried to do a Find and Replace operation which resulted in a really broken result. The problem probably is because the operation generates a line with 188768 columns, from an originally 75 character long line.

I will investigate further to reproduce it in a source that I can disclosure.
Comment 3 Michel Graciano 2015-09-10 14:47:06 UTC
Ok, now I can reproduce it with the following class. It happen ONLY when selecting part of the source.

package nb;

import java.util.Collection;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;

public class SampleClass {

  public <T> void someMethod(final Collection<T> dtos,
          final BiPredicate<T, Collection<XXX>> is,
          final BiFunction<T, XXX.Builder, XXX> from,
          final BiFunction<T, Collection<XXX>, Optional<XXX>> findXXX) {
    someCollection.forEach(someObject::removeXXX);
  }

}

Steps to reproduce:
1. Select the whole method 'someMethod', press Ctrl + H
2. Put XXX for 'Find What', and MoreXXX for 'Replace With'
3. The result is as follow. In a bigger Java file, it looks long and generate this slowness report.

public <T> void someMethod(final Collection<T> dtos,
          final BiPredicate<T, Collection<MoreXXX>> is,
          final BiFunction<T, MoreXXX.Builder, MoreXXX> from,
          final BiFunction<T, Collection<MoreXXX>, Optional<MoreXXX>> findMoreXXX) {
    someCollection.forEach(someObject::removeMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreMoreXXX);
  }
Comment 4 Michel Graciano 2015-09-10 14:47:54 UTC
BTW, it does not looks like a performance issue for me anymore. The performance issue is a side effect for the original issue.
Comment 5 Milutin Kristofic 2015-09-14 14:00:36 UTC
Thank you for reproducible steps.

I fixed it http://hg.netbeans.org/jet-main/rev/148ba0364f52
Comment 6 Quality Engineering 2015-09-15 01:23:15 UTC
Integrated into 'main-silver', will be available in build *201509150002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/148ba0364f52
User: Milutin Kristofic <mkristofic@netbeans.org>
Log: #255185 - Find and Replace is redoing the replace in some specific scenarios, generating wrong results
Comment 7 Michel Graciano 2015-09-15 16:19:17 UTC
v. Build 20150915-cf4f4fc676df
Comment 8 Milutin Kristofic 2015-09-16 08:49:35 UTC
Michel thank you for verification.