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

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

Change-Id: Id7436bf23606e4c21dc1e2311da88ab9f0e8ac11
This commit is contained in:
Treehugger Robot
2020-11-05 20:17:41 +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);