Add null check to SQLiteConnectionPool.dump()

This change adds a null check before adding the current connection
pool path's parent to the list of directories, since the parent might be
null. This avoids an NPE in SQLiteDatabase.dumpAll().

Test: run dumpsys dbinfo, verify that it no longer times out
Bug: 281043011
Change-Id: Iec7fa9d0941d79dfa034f117c35c30797c7d3113
This commit is contained in:
Kevin Jeon
2023-05-05 10:21:48 -04:00
parent a3b93dcc4b
commit 68304252b7

View File

@@ -1136,7 +1136,10 @@ public final class SQLiteConnectionPool implements Closeable {
Printer indentedPrinter = PrefixPrinter.create(printer, " ");
synchronized (mLock) {
if (directories != null) {
directories.add(new File(mConfiguration.path).getParent());
String parent = new File(mConfiguration.path).getParent();
if (parent != null) {
directories.add(parent);
}
}
boolean isCompatibilityWalEnabled = mConfiguration.isLegacyCompatibilityWalEnabled();
printer.println("Connection pool for " + mConfiguration.path + ":");