Skip to content

Conversation

@joschi
Copy link
Contributor

@joschi joschi commented Jul 29, 2021

The BufferedReader in PreparedCommentHeader#update() is initialized with a read-ahead limit of 2048 bytes.

If a file is larger than that, the mark will be invalidated while the update() method skips through the file line-by-line and when no valid existing license header was detected, the BufferedReader#reset() method will fail.

java.io.IOException: Mark invalid
	at java.base/java.io.BufferedReader.reset(BufferedReader.java:517)
	at java_io_BufferedReader$reset$1.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
	at org.cadixdev.gradle.licenser.header.PreparedCommentHeader$_update_closure2.doCall(PreparedCommentHeader.groovy:84)

The `BufferedReader` in `PreparedCommentHeader#update()` is initialized with a read-ahead limit of 2048 bytes.

If a file is larger than that, the mark will be invalidated while the `update()` method skips through the file line-by-line and when no valid existing license header was detected, the `BufferedReader#reset()` method will fail.

```text
java.io.IOException: Mark invalid
	at java.base/java.io.BufferedReader.reset(BufferedReader.java:517)
	at java_io_BufferedReader$reset$1.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
	at org.cadixdev.gradle.licenser.header.PreparedCommentHeader$_update_closure2.doCall(PreparedCommentHeader.groovy:84)
```
@joschi joschi force-pushed the buffered-reader-bug branch from a474bad to 0d8612e Compare July 29, 2021 22:02
@joschi
Copy link
Contributor Author

joschi commented Jul 29, 2021

The failing tests on Travis CI are unrelated to this PR.

org.cadixdev.gradle.licenser.LicenserPluginFunctionalTest > supports Kotlin buildscripts (gradle 6.8.3) FAILED

    org.gradle.testkit.runner.UnexpectedBuildFailure at LicenserPluginFunctionalTest.groovy:431

org.cadixdev.gradle.licenser.LicenserPluginFunctionalTest > supports Kotlin buildscripts (gradle 6.8.3) FAILED

    org.gradle.testkit.runner.UnexpectedBuildFailure at LicenserPluginFunctionalTest.groovy:431

org.cadixdev.gradle.licenser.LicenserPluginFunctionalTest > supports Kotlin buildscripts (gradle 6.9) FAILED

    org.gradle.testkit.runner.UnexpectedBuildFailure at LicenserPluginFunctionalTest.groovy:431

60 tests completed, 3 failed

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.

1 participant