You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by GitBox <gi...@apache.org> on 2021/12/01 15:45:10 UTC

[GitHub] [brooklyn-server] grkvlt opened a new pull request #1280: Use toURI on resource URLs to fix Windows path issues

grkvlt opened a new pull request #1280:
URL: https://github.com/apache/brooklyn-server/pull/1280


   Signed-off-by: Andrew Donald Kennedy <an...@gmail.com>


-- 
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: dev-unsubscribe@brooklyn.apache.org

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



[GitHub] [brooklyn-server] ahgittin commented on a change in pull request #1280: Use toURI on resource URLs to fix Windows path issues

Posted by GitBox <gi...@apache.org>.
ahgittin commented on a change in pull request #1280:
URL: https://github.com/apache/brooklyn-server/pull/1280#discussion_r760904034



##########
File path: utils/common/src/test/java/org/apache/brooklyn/util/io/FileUtilTest.java
##########
@@ -123,26 +126,30 @@ public void testIsJavaFileNull(){
     }
 
     @Test
-    public void testIsJavaFileText() throws IOException {
-        byte[] bytes = java.nio.file.Files.readAllBytes(Paths.get(this.getClass().getClassLoader().getResource("brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt").getPath()));
+    public void testIsJavaFileText() throws IOException, URISyntaxException {
+        byte[] bytes = java.nio.file.Files.readAllBytes(
+               Paths.get(this.getClass().getClassLoader().getResource("brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt").toURI()));
         assertFalse(FileUtil.doesZipContainJavaBinaries(InputStreamSource.of("Test bom file", bytes)));

Review comment:
       how about
   
   ```
           assertFalse(FileUtil.doesZipContainJavaBinaries(InputStreamSource.of("Test bom file",
                   Streams.readFully(getClass().getResourceAsStream("/brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt")))));
   ```
   
   AFAIK attempting to read the URL as a file path is not guaranteed anyway, so `URL.toURI()` is a band-aid whereas stream is a fix.  (btw if using the toURI pattern it would be better to wrap all those calls in a `attemptToReadBytesFromAFile(path)` method with a comment that converting to URI increases reliability on windows.)




-- 
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: dev-unsubscribe@brooklyn.apache.org

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