Skip to content

CoderMalfunctionError while searching #7839

Closed

Description

@wumpz

Apache NetBeans version

Apache NetBeans 23

What happened

I have a multimodule project. Using Netbeans Find method on specific module with e.g. text "TEST" i find results. Using the find globally or with scope Open Projects I got less results. First I thought, I do not understand what scope "Open Projects" means but looking into the IDE Log I found:

SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.netbeans.modules.search.SearchTask
java.lang.IllegalArgumentException: newPosition > limit: (1 > 0)
	at java.base/java.nio.Buffer.createPositionException(Buffer.java:352)
	at java.base/java.nio.Buffer.position(Buffer.java:327)
	at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1551)
	at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:623)
	at org.netbeans.api.queries.FileEncodingQuery$ProxyCharset$ProxyDecoder.decodeLoop(FileEncodingQuery.java:191)
	at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:586)
Caused: java.nio.charset.CoderMalfunctionError
	at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:588)
	at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:385)
	at java.base/sun.nio.cs.StreamDecoder.lockedRead(StreamDecoder.java:217)
	at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:171)
	at java.base/java.io.InputStreamReader.read(InputStreamReader.java:188)
	at java.base/java.io.BufferedReader.fill(BufferedReader.java:160)
	at java.base/java.io.BufferedReader.implRead(BufferedReader.java:196)
	at java.base/java.io.BufferedReader.read(BufferedReader.java:181)
	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:1403)
	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:2018)

So I assume there is somewere a for Netbeans problematic file. However, this should not stop the search.

Language / Project Type / NetBeans Component

Multimodule Java Maven Project (no java modules)

How to reproduce

That is a good question. Since I cannot make a project copy of mine, I still search for the problematic file.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows

JDK

21

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

Activity

  1. added
    kind:bugBug report or fix
    needs:triageRequires attention from one of the committers
    on Oct 8, 2024
  2. matthiasblaesing commented on Oct 8, 2024

    @matthiasblaesing
    Contributor

    Was this "Find" or "Replace"?

    Edit: Which JDK exactly was used? (Help Menu -> About, Lines Java + Runtime)

  3. wumpz commented on Oct 8, 2024

    @wumpz
    ContributorAuthor

    Was find from menu or popup. this seems to happen using scope Open Projects.
    Jdk version follows ...

  4. mbien commented on Oct 8, 2024

    @mbien
    Member

    duplicate of #6671

    can also happen during indexing: #4762

    also see the question in #6671 (comment)

  5. wumpz commented on Oct 9, 2024

    @wumpz
    ContributorAuthor

    Java: 21.0.4; OpenJDK 64-Bit Server VM 21.0.4+7-LTS

  6. matthiasblaesing commented on Oct 10, 2024

    @matthiasblaesing
    Contributor

    @wumpz which Vendor?

    To narrow the problem down, you could invoke Find from the "Files" tab and descent through the directory tree until you pinpoint the problematic file. This should reduce the number of attempts drasticly.

  7. mbien commented on Oct 10, 2024

    @mbien
    Member

    as mentioned on the other issue, the exception is intended for search/replace since the file must be correctly decodeable when replacing something in it. So if this is happening on find it could be that some search action is using the wrong code path somewhere or forgets to set strict=false.

    If this happens during serach/replace, its really not much we can do about it, maybe improve the message to list the file and skip it.

  8. matthiasblaesing commented on Oct 10, 2024

    @matthiasblaesing
    Contributor

    The fact, that an java.nio.charset.CoderMalfunctionError (core keyword being Error) is raised, indicates a deeper problem. I learned, that catching Exception is discouraged and catching Error is just plain wrong (with very few exceptions). So when this happens when using a decoder, this is either a bug in the JDK or in our usage of the facilities.
    That is why I'd like to have a reproducer and know where this comes from.

  9. mbien commented on Oct 10, 2024

    @mbien
    Member

    I don't disagree, I just mean that there is another layer to that, NB controls when the error should be thrown or not:

    decoder.onMalformedInput(CodingErrorAction.REPORT);

    it is meant to only propagate the error on search/replace. All what I am saying is that if this happens already during plain search, there might be more to that.

    edit: i am also sure if the decoder API would be designed today, it wouldn't extend Error.

  10. mbien commented on Oct 11, 2024

    @mbien
    Member

    this might be a good place catch CoderMalfunctionError, but this is only for the SingleLineStreamMatcher, there are likely more places (indexing included) - thats why it would be good to have a reproducer for this.

    } catch (Exception e) {
    listener.fileContentMatchingError(file.getPath(), e);
    return null;
    }

  11. wumpz commented on Oct 21, 2024

    @wumpz
    ContributorAuthor

    @matthiasblaesing Sorry. Did not see your mentioning. This is an Eclipse Temurin Release.

  12. keosion commented on Mar 6, 2025

    @keosion

    I also reproduce this bug since a long time, with multiple Netbeans versions. I now use NetBeans IDE 25 on Linux. Java version is 21.0.6, OpenJDK 64-Bit Server VM 21.0.6+2.
    I finally found the culprit and can reproduce this bug with only one file in a project. Either using search or with automatic scanning. Here is the file : error_file.txt . You'll have to change extension. I used .gpx but .xml also works.

    The xml encoding property say "UTF-8" but the file is not UTF-8 encoded. There are accentuated characters in the file.

    Hope this helps

  13. added and removed
    needs:triageRequires attention from one of the committers
    pending-responseAwaiting further information to be supplied
    on Mar 6, 2025
  14. added this to the NB26 milestone on Mar 6, 2025
  15. mbien commented on Mar 6, 2025

    @mbien
    Member

    @keosion thanks for the reproducer. Will check if this can be improved for NB 26.

  16. changed the title [-]exception while searching[/-] [+]CoderMalfunctionError while searching[/+] on Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions