[
https://issues.apache.org/jira/browse/RAT-273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17515527#comment-17515527
]
Jochen Wiedmann commented on RAT-273:
-------------------------------------
So far, I can't provide a fix, but I believe to have found the reason. Suggest
the following snippet:
{{ final StringReader sr = new StringReader("One\nTwo");}}
{{ final LineNumberReader lnr = new LineNumberReader(sr);}}
{{ for (;;) {}}
{{ final int c = lnr.read();}}
{{ if (c == -1) {}}
{{ System.out.println("Line number=" + lnr.getLineNumber());}}
{{ break;}}
{{ }}}
{{ }}}
{{What it does, is basically this. Read a text, that's not terminated with a
line terminator, piping }}{{ the complete text through a LineNumberReader.}}
Well, the point is this: On Java 17, the last line is counted. Whereas, on Java
11, and 8, it's not counted.
Knowing that, we might easily fix the unit test by adjusting the expected
result, accordingly. Problem is: I am not sure, whether this problem could
affect some functionality, that isn't tested. So, before I create a fix, I'd be
interested in other opinions.
{{[jwi@localhost ews]$ /usr/lib/jvm/java-1.8.0/bin/java -classpath
LineNumberReaderDemo/bin demo.LineNumberReaderDemo}}
{{Line number=1}}
{{[jwi@localhost ews]$ /usr/lib/jvm/java-11/bin/java -classpath
LineNumberReaderDemo/bin demo.LineNumberReaderDemo}}
{{Line number=1}}
{{[jwi@localhost ews]$ /usr/lib/jvm/java-17/bin/java -classpath
LineNumberReaderDemo/bin demo.LineNumberReaderDemo}}
{{Line number=2}}
> Build failures with >=JDK16 - analyze test behaviour or rewrite tests and
> update build matrix
> ---------------------------------------------------------------------------------------------
>
> Key: RAT-273
> URL: https://issues.apache.org/jira/browse/RAT-273
> Project: Apache Rat
> Issue Type: Bug
> Affects Versions: 0.14
> Reporter: Philipp Ottlinger
> Assignee: Philipp Ottlinger
> Priority: Major
>
> A Travis build running against
> DOCKER_IMAGE=maven:3.6.3-openjdk-16
> revealed the following test failures:
> {{Tests run: 5, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.028 sec
> <<< FAILURE! - in org.apache.rat.header.HeaderMatcherTest
> lines(org.apache.rat.header.HeaderMatcherTest) Time elapsed: 0.01 sec <<<
> FAILURE!
> java.lang.AssertionError: One line read expected:<1> but was:<2>
> at org.apache.rat.header.HeaderMatcherTest.lines(HeaderMatcherTest.java:84)
> noLines(org.apache.rat.header.HeaderMatcherTest) Time elapsed: 0.002 sec <<<
> FAILURE!
> java.lang.AssertionError: No lines read expected:<0> but was:<1>
> at
> org.apache.rat.header.HeaderMatcherTest.noLines(HeaderMatcherTest.java:74)}}
> SUMMARY:
> {{ HeaderMatcherTest.lines:84 One line read expected:<1> but was:<2>
> HeaderMatcherTest.noLines:74 No lines read expected:<0> but was:<1>}}
> [https://travis-ci.org/github/apache/creadur-rat/jobs/726998247]
> After fixing the bug
> * Github Action and
> * Travis matrix builds should be changed to at least contain 8, 11, 17, and
> maybe 18-ea/19-ea (as of 2022-02-10) -
> https://www.oracle.com/java/technologies/java-se-support-roadmap.html
> * Fix errors resulting from running with more modern builds:
> ** Javadoc error on JDK17
> ** RatCheckMojo complaining about module error
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)