Skip to content

Conversation

@dengshu2
Copy link

Description

This PR fixes cross-platform compatibility issues that prevented the project from building successfully on Windows environments.

Changes

1. JSON Line Separator Handling (TransportUDFMetadata.java)

  • Issue: Gson outputs Unix line separators (\n) on all platforms, but Windows test expectations use CRLF (\r\n)
  • Fix: Convert JSON output to use System.lineSeparator() for platform-appropriate line endings
  • Impact: Ensures annotation processor tests pass on Windows while maintaining compatibility with Linux/macOS

2. Resource Path Resolution (TransportPluginTest.java)

  • Issue: ClassLoader.getResource().getPath() returns invalid path format on Windows (e.g., /C:/Users/...)
  • Fix: Use Paths.get(resource.toURI()).toString() for proper cross-platform path handling
  • Impact: Fixes InvalidPathException in Trino plugin tests on Windows

3. File URI Format and Path Normalization (FileSystemUtilsTest.java)

  • Issue: Incorrect file URI format (file:// instead of file:///) and backslash/forward slash inconsistencies
  • Fix: Use proper file:/// URI format and normalize paths for comparison
  • Impact: Resolves Hadoop FileSystem API errors and test failures on Windows

Testing

All changes have been tested on Windows 10 (MINGW64_NT-10.0-19045):

  • ✅ Full build successful: ./gradlew clean build -x javadoc
  • ✅ All 152 tasks executed without errors
  • ✅ All tests passed (including previously failing Windows-specific tests)

Cross-Platform Compatibility

These changes are designed to be cross-platform compatible:

  • Use of System.lineSeparator() is a no-op on Linux (returns \n)
  • Paths.get().toURI() is the recommended Java NIO approach for all platforms
  • Path normalization only affects Windows paths (no backslashes on Linux)

Related Issues

Fixes Windows build failures in:

  • transportable-udfs-annotation-processor (7 test failures)
  • transportable-udfs-trino-plugin (1 test failure)
  • transportable-udfs-utils (1 test failure)

This commit fixes three cross-platform compatibility issues that
prevented the project from building successfully on Windows:

1. JSON line separator mismatch in annotation processor tests
   - Modified TransportUDFMetadata to use System.lineSeparator()
   - Ensures consistent newline handling across platforms

2. Invalid Windows path format in Trino plugin tests
   - Changed TransportPluginTest to use Paths.get().toURI()
   - Properly handles resource path resolution on Windows

3. File path separator inconsistency in utils tests
   - Updated FileSystemUtilsTest to use proper file:/// URI format
   - Added path normalization for cross-platform comparisons

All changes are designed to be cross-platform compatible and should
not affect builds on Linux or macOS.

Tested on: Windows 10 (MINGW64_NT-10.0-19045)
Build result: BUILD SUCCESSFUL (152 tasks, all tests passed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant