You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "davisusanibar (via GitHub)" <gi...@apache.org> on 2023/03/28 16:03:11 UTC

[GitHub] [arrow] davisusanibar commented on a diff in pull request #34312: GH-34293: [Java] Error loading native libraries on Windows

davisusanibar commented on code in PR #34312:
URL: https://github.com/apache/arrow/pull/34312#discussion_r1150850276


##########
java/dataset/src/test/java/org/apache/arrow/dataset/file/TestFileSystemDataset.java:
##########
@@ -386,6 +388,27 @@ public void testBaseCsvRead() throws Exception {
     }
   }
 
+  @Test
+  public void testResourceToLoad() throws IOException {
+    if (System.getProperty("os.name").equalsIgnoreCase("Windows")) {
+      assertEquals("\\", File.separator);
+      final String pathWithoutFileSeparator = "/" + "avroschema" + "/" + "user.avsc";
+      try (final InputStream stream = TestFileSystemDataset.class.getResourceAsStream(pathWithoutFileSeparator)) {
+        if (stream == null) {
+          throw new FileNotFoundException(pathWithoutFileSeparator);
+        }
+      }
+      final String pathWithFileSeparator = File.separator + "avroschema" + File.separator + "user.avsc";
+      Assertions.assertThrows(FileNotFoundException.class, () -> {
+        try (final InputStream stream = TestFileSystemDataset.class.getResourceAsStream(pathWithFileSeparator)) {
+          if (stream == null) {
+            throw new FileNotFoundException(pathWithFileSeparator);
+          }
+        }
+      }, "FileNotFound \\avroschema\\user.avsc");
+    }
+  }
+

Review Comment:
   The current JUnit tests are able to read resources without any issues.
   
   Basically, this error was not detected because of the lack of checking of `getResourceAsStream` in the main code to load native libraries.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org