Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure BufferedInputStream is not initialized with a buffer size of 0 #3491

Merged

Conversation

matthiasblaesing
Copy link
Contributor

With an empty file the BufferedCharSequence fails to be initialized:

java.lang.IllegalArgumentException: Buffer size <= 0
	at java.base/java.io.BufferedInputStream.<init>(BufferedInputStream.java:207)
	at org.netbeans.modules.search.matcher.BufferedCharSequence$Source.initStreams(BufferedCharSequence.java:562)
Caused: java.io.IOException
Caused: org.netbeans.modules.search.matcher.BufferedCharSequence$SourceIOException
	at org.netbeans.modules.search.matcher.BufferedCharSequence$Source.initStreams(BufferedCharSequence.java:570)
	at org.netbeans.modules.search.matcher.BufferedCharSequence$Source.<init>(BufferedCharSequence.java:494)
	at org.netbeans.modules.search.matcher.BufferedCharSequence.<init>(BufferedCharSequence.java:145)
[catch] at org.netbeans.modules.search.matcher.MultiLineStreamMatcher.checkMeasuredInternal(MultiLineStreamMatcher.java:84)
	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:93)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

So ensure, that at least a 1 byte buffer is used.

With an empty file the BufferedCharSequence fails to be initialized:

java.lang.IllegalArgumentException: Buffer size <= 0
	at java.base/java.io.BufferedInputStream.<init>(BufferedInputStream.java:207)
	at org.netbeans.modules.search.matcher.BufferedCharSequence$Source.initStreams(BufferedCharSequence.java:562)
Caused: java.io.IOException
Caused: org.netbeans.modules.search.matcher.BufferedCharSequence$SourceIOException
	at org.netbeans.modules.search.matcher.BufferedCharSequence$Source.initStreams(BufferedCharSequence.java:570)
	at org.netbeans.modules.search.matcher.BufferedCharSequence$Source.<init>(BufferedCharSequence.java:494)
	at org.netbeans.modules.search.matcher.BufferedCharSequence.<init>(BufferedCharSequence.java:145)
[catch] at org.netbeans.modules.search.matcher.MultiLineStreamMatcher.checkMeasuredInternal(MultiLineStreamMatcher.java:84)
	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:93)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

So ensure, that at least a 1 byte buffer is used.
@matthiasblaesing
Copy link
Contributor Author

This was noticed by @neilcsmith-net in #3489

Copy link
Member

@neilcsmith-net neilcsmith-net left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @matthiasblaesing Hadn't time then to delve further. Looks safest minimal approach - wasn't sure whether to try and skip empty files completely.

@neilcsmith-net neilcsmith-net merged commit a42b661 into apache:delivery Jan 24, 2022
@matthiasblaesing matthiasblaesing deleted the error_multiline_search branch January 27, 2022 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants