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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]