RFR: 7540: IItemCollectionJsonSerializerTest.java might fail on Windows due to line endings [v2]

Alex Ciminian duke at openjdk.java.net
Thu Apr 28 05:49:51 UTC 2022


On Wed, 27 Apr 2022 20:30:21 GMT, Christoph Langer <clanger at openjdk.org> wrote:

>> core/tests/org.openjdk.jmc.flightrecorder.serializers.test/src/test/java/org/openjdk/jmc/flightrecorder/serializers/json/test/IItemCollectionJsonSerializerTest.java line 69:
>> 
>>> 67: 		String actual = IItemCollectionJsonSerializer.toJsonString(testRecording);
>>> 68: 
>>> 69: 		assertEquals(expected.replaceAll("\\r\\n", "\n"), actual.replaceAll("\\r\\n", "\n"));
>> 
>> Sorry, I'm late to the party �� I wrote this test and I'm curious what the problem was here �� 
>> 
>> Did this test fail for you? I don't understand how it can be different on windows since the JSON file has unix line endings and the serialiser will output unix line endings.
>
> Hm, it's been a while but obviously it failed for me. In the bug I've written: On Windows, the returned data from IItemCollectionJsonSerializer.toJsonString(testRecording) seems to have platform line endings. Are you sure that there should be unix line endings?

�� Yup, you're right. Sorry, I didn't check [`StructuredWriter.java`](https://github.com/openjdk/jmc/blob/master/core/org.openjdk.jmc.flightrecorder.serializers/src/main/java/org/openjdk/jmc/flightrecorder/serializers/json/StructuredWriter.java#L61), there we are using `String.format("%n");` which will output platform dependent line terminators ��

-------------

PR: https://git.openjdk.java.net/jmc/pull/370


More information about the jmc-dev mailing list