Merge "Avoid NullPointerException on non-existing file." am: 5db706a48f am: 2cf1c81e8b

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1488698

Change-Id: I107e05a4da398dd0392aa8d62f5b89ed785c1ed2
This commit is contained in:
Treehugger Robot
2020-11-05 18:55:02 +00:00
committed by Automerger Merge Worker

View File

@@ -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);