Merge "Avoid NullPointerException on non-existing file." am: 5db706a48f am: 2cf1c81e8b am: 9328409c4c am: e633b4095c am: 331aa35d2e

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

Change-Id: I1001c780800c3ee92f7ebc0b733556d6734020de
This commit is contained in:
Treehugger Robot
2020-11-05 20:22:18 +00:00
committed by Automerger Merge Worker

View File

@@ -214,7 +214,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);