Conversation
BREAKING CHANGE: Path/File/InputStream hasContent (and related Diff-based content comparisons) no longer ignore a single trailing newline. Lines are split with trailing empty segments preserved so "a" and "a\n" differ, while line-ending style (\n/\r/\r\n) remains normalized.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Check List:
Description
Team decision on #2993: keep 3.x behavior, but in 4.0 take newlines into account for
hasContent.DiffusedBufferedReader.readLine(), which drops the distinction between content with and without a single trailing line terminator ("a"vs"a\n"). That made:Change: read full text and split with
split("\\R", -1)so a final terminator is kept as a trailing empty line. Line-ending style (\n/\r/\r\n) stays normalized; only presence/absence of a trailing terminator (and other real line differences) matters.Javadoc: Path / File / InputStream
hasContentno longer claim newlines are ignored; document exact comparison and point tocontent()/asString()+isEqualToIgnoringNewlineswhen that is desired.Tests: trailing-newline pass/fail cases on
Paths_assertHasTextualContent,DiffFile/String and InputStream/String; existing File→String fixtures updated so expected strings include the trailing separator written byTextFileWriter/ resource files.Verified locally (JDK 25+/Homebrew OpenJDK 26,
./mvnw):Diff_diff_File_*,Files_assertHasContent_*, size/hasContent unit testsPaths_assertHasTextualContent_Test,Diff_diff_InputStream_*,InputStreamAssert_hasContent_Test