summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Freni <dariofreni@google.com>2020-11-05 14:30:00 +0000
committerDario Freni <dariofreni@google.com>2020-11-05 14:32:18 +0000
commit2d510d9b6cd99875fd1e808c82b4d08e72cc3fbd (patch)
treec2485f0d0b12bf52dc78e153a06a62774fe075fa
parent97f35bbbefe9be8aa74c81a4dd8fff3e52ce2d01 (diff)
Avoid NullPointerException on non-existing file.
This change allows the method to throw a more informative exception containing the file name that has not been found. Test: used the library in sharedlibs_host_tests Change-Id: I196385486ef4c121f1c655cd76c3ea5233e2a722
-rw-r--r--tests/utils/hostutils/src/com/android/internal/util/test/SystemPreparer.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/utils/hostutils/src/com/android/internal/util/test/SystemPreparer.java b/tests/utils/hostutils/src/com/android/internal/util/test/SystemPreparer.java
index f30c35aca8da..173338660113 100644
--- a/tests/utils/hostutils/src/com/android/internal/util/test/SystemPreparer.java
+++ b/tests/utils/hostutils/src/com/android/internal/util/test/SystemPreparer.java
@@ -186,7 +186,7 @@ public class SystemPreparer extends ExternalResource {
private File copyResourceToTemp(String resourcePath) throws IOException {
final File tempFile = mHostTempFolder.newFile();
final ClassLoader classLoader = getClass().getClassLoader();
- try (InputStream assetIs = classLoader.getResource(resourcePath).openStream();
+ try (InputStream assetIs = classLoader.getResourceAsStream(resourcePath);
FileOutputStream assetOs = new FileOutputStream(tempFile)) {
if (assetIs == null) {
throw new IllegalStateException("Failed to find resource " + resourcePath);