Skip to content

Different newlines on Windows #6

Description

@prdoyle

Summary

WIndows has trouble with newlines and I'm not sure how you want to proceed.

Failure

When I run JfrSchemaFactoryTest.canRunSimpleSelectFromClassLoad on Windows, it fails on column 2 because the newlines are different:

assertThat(rs.getString(2)).isEqualTo("""
        {
          classLoader = null
          name = "java/lang/Throwable"
          package = {
            name = "java/lang"
            module = {
              name = "java.base"
              version = "17"
              location = "jrt:/java.base"
              classLoader = null
            }
            exported = true
          }
          modifiers = 33
          hidden = false
        }
        """);

Cause

JfrSchema.getConverter is using the following converter:

else if (field.getTypeName().equals("java.lang.Class")) {
    LOGGER.log(INFO, "| -> java.lang.Class");
    return event -> event.getClass(field.getName());
}

I believe when the testcase calls rs.getString(), this is calling RecordedClass.toString() which ultimately uses StructuredWriter.lineSeparator which is initialized to String.format("%n"), and this differs by platform.

Possible solutions

Should we return the java.lang.Class in this case, rather than the RecordedClass object? The Class.toString() method should produce the same result on all platforms.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions