licenser icon indicating copy to clipboard operation
licenser copied to clipboard

Fix adding license header to files larger than 2048 bytes

Open joschi opened this issue 4 years ago • 1 comments

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)

joschi avatar Jul 29 '21 21:07 joschi

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

joschi avatar Jul 29 '21 22:07 joschi