Fix Opening FB4A Database Plugin
Summary: The FB4A SQLite database plugin has to be opened 4-5 times before it shows a list of databases. This is because some databases are encrypted and can't be opened. In this case the code throws and exception and we do not catch that, causing the whole load process to crash. Now catching the exception and returning an empty list. Reviewed By: jknoxville Differential Revision: D19463876 fbshipit-source-id: af8c9a70dc2761e62088d90ce89f8d16057e8745
This commit is contained in:
committed by
Facebook Github Bot
parent
7c03366136
commit
c8b9dd949b
@@ -89,24 +89,28 @@ public class SqliteDatabaseDriver extends DatabaseDriver<SqliteDatabaseDescripto
|
||||
|
||||
@Override
|
||||
public List<String> getTableNames(SqliteDatabaseDescriptor databaseDescriptor) {
|
||||
SQLiteDatabase database =
|
||||
sqliteDatabaseConnectionProvider.openDatabase(databaseDescriptor.file);
|
||||
try {
|
||||
Cursor cursor =
|
||||
database.rawQuery(
|
||||
"SELECT name FROM " + SCHEMA_TABLE + " WHERE type IN (?, ?)",
|
||||
new String[] {"table", "view"});
|
||||
SQLiteDatabase database =
|
||||
sqliteDatabaseConnectionProvider.openDatabase(databaseDescriptor.file);
|
||||
try {
|
||||
List<String> tableNames = new ArrayList<>();
|
||||
while (cursor.moveToNext()) {
|
||||
tableNames.add(cursor.getString(0));
|
||||
Cursor cursor =
|
||||
database.rawQuery(
|
||||
"SELECT name FROM " + SCHEMA_TABLE + " WHERE type IN (?, ?)",
|
||||
new String[] {"table", "view"});
|
||||
try {
|
||||
List<String> tableNames = new ArrayList<>();
|
||||
while (cursor.moveToNext()) {
|
||||
tableNames.add(cursor.getString(0));
|
||||
}
|
||||
return tableNames;
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
return tableNames;
|
||||
} finally {
|
||||
cursor.close();
|
||||
database.close();
|
||||
}
|
||||
} finally {
|
||||
database.close();
|
||||
} catch (SQLiteException ex) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user