When calling dropIndexes with "*" to drop all indexes on a collection, the operation incorrectly drops indexes from all collections in the database instead of just the target collection.
The bug is in AbstractMongoDatabase.dropIndexes() where the code iterates over all documents in system.indexes without filtering by namespace:
if (Objects.equals(index, "*")) {
for (Document indexDocument : indexCollection.queryAll()) {
// ...
}
}
This causes indexes from unrelated collections to be deleted from system.indexes, leading to failures in subsequent operations. For example, listIndexes won't show the deleted indexes, and dropping the database fails with Expected [Index] to be empty because the collection's in-memory index list is out of sync with system.indexes.
The fix is to filter by namespace when iterating. A PR will follow shortly