apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.66k stars 853 forks source link

java.nio.charset.CoderMalfunctionError whilst searching #6671

Open DavidGradwell opened 1 year ago

DavidGradwell commented 1 year ago

Apache NetBeans version

Apache NetBeans 19

What happened

Whilst searching all open projects for a text string 'tview_instance_class' got the attached error. This error is repeatable. It occurs after the search has been going on for around 10 seconds and many files have been scanned.

messages.log

It looks to be data related. Watching the search as it progresses and then closing the project it was scanning and trying again removes the issue.

How to reproduce

No response

Did this work correctly in an earlier version?

No / Don't know

Operating System

Mac OS X version 14.0 running on aarch64; UTF-8; en_GB (nb)

JDK

OpenJDK 64-Bit Server VM 17.0.7+7-LTS Runtime: OpenJDK Runtime Environment 17.0.7+7-LTS System:

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else


java.lang.IllegalArgumentException: newPosition > limit: (8193 > 8192)
    at java.base/java.nio.Buffer.createPositionException(Buffer.java:341)
    at java.base/java.nio.Buffer.position(Buffer.java:316)
    at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1516)
    at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:622)
    at org.netbeans.api.queries.FileEncodingQuery$ProxyCharset$ProxyDecoder.decodeHead(FileEncodingQuery.java:239)
    at org.netbeans.api.queries.FileEncodingQuery$ProxyCharset$ProxyDecoder.decodeLoop(FileEncodingQuery.java:201)
    at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:585)
Caused: java.nio.charset.CoderMalfunctionError
    at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:587)
    at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:305)
    at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:188)
    at java.base/java.io.InputStreamReader.read(InputStreamReader.java:177)
    at java.base/java.io.BufferedReader.fill(BufferedReader.java:162)
    at java.base/java.io.BufferedReader.read(BufferedReader.java:183)
    at org.netbeans.modules.search.matcher.LineReader.readNext(LineReader.java:70)
    at org.netbeans.modules.search.matcher.SingleLineStreamMatcher.getTextDetailsSL(SingleLineStreamMatcher.java:102)
    at org.netbeans.modules.search.matcher.SingleLineStreamMatcher.checkMeasuredInternal(SingleLineStreamMatcher.java:68)
    at org.netbeans.modules.search.matcher.AbstractMatcher.check(AbstractMatcher.java:53)
    at org.netbeans.modules.search.matcher.DefaultMatcher.checkMeasuredInternal(DefaultMatcher.java:93)
    at org.netbeans.modules.search.matcher.AbstractMatcher.check(AbstractMatcher.java:53)
    at org.netbeans.modules.search.BasicComposition.start(BasicComposition.java:78)
    at org.netbeans.modules.search.SearchTask.run(SearchTask.java:87)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1419)
    at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2034)

Are you willing to submit a pull request?

No

mbien commented 1 year ago

are you using search or search and replace?

since the search has two modes. The strict mode should be only active on replace since it has to make sure the file is valid. It will throw exceptions if it is not.

https://github.com/apache/netbeans/blob/73237de9420b5847640cae2bc5fff940d7d5b346/platform/api.search/src/org/netbeans/modules/search/matcher/AbstractMatcher.java#L87-L106

0k00l commented 8 months ago

Same here, Netbeans version: 20. One of my java bean is marked with error marker, but file compiles without any problems.

Netbeans JDK: 17 Project JDK: 1.8