Skip to content

Commit

Permalink
fix(firestore, android): lint warnings and deprecated API (#12577)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Apr 5, 2024
1 parent e6d33f6 commit 1b6ef73
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ private Filter filterFromJson(Map<String, Object> map) {
}
// Deserialize a FilterOperator
String op = (String) map.get("op");
@SuppressWarnings("unchecked")
List<Map<String, Object>> queries = (List<Map<String, Object>>) map.get("queries");

// Map queries recursively
Expand Down Expand Up @@ -428,7 +429,9 @@ private Query readFirestoreQuery(ByteBuffer buffer) {

boolean isFilterQuery = parameters.containsKey("filters");
if (isFilterQuery) {
Filter filter = filterFromJson((Map<String, Object>) parameters.get("filters"));
@SuppressWarnings("unchecked")
Filter filter =
filterFromJson((Map<String, Object>) Objects.requireNonNull(parameters.get("filters")));
query = query.where(filter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ private String registerEventChannel(String prefix, String identifier, StreamHand
private void removeEventListeners() {
synchronized (eventChannels) {
for (String identifier : eventChannels.keySet()) {
eventChannels.get(identifier).setStreamHandler(null);
Objects.requireNonNull(eventChannels.get(identifier)).setStreamHandler(null);
}
eventChannels.clear();
}

synchronized (streamHandlers) {
for (String identifier : streamHandlers.keySet()) {
streamHandlers.get(identifier).onCancel(null);
Objects.requireNonNull(streamHandlers.get(identifier)).onCancel(null);
}
streamHandlers.clear();
}
Expand All @@ -291,7 +291,7 @@ static FirebaseFirestoreSettings getSettingsFromPigeon(
Long receivedCacheSizeBytes = pigeonApp.getSettings().getCacheSizeBytes();
// This is the maximum amount of cache allowed:
// https://firebase.google.com/docs/firestore/manage-data/enable-offline#configure_cache_size
Long cacheSizeBytes = 104857600L;
long cacheSizeBytes = 104857600L;
if (receivedCacheSizeBytes != null && receivedCacheSizeBytes != -1) {
cacheSizeBytes = receivedCacheSizeBytes;
}
Expand Down Expand Up @@ -454,6 +454,8 @@ public void waitForPendingWrites(
}

@Override
// Suppressed because we have already annotated the user facing Dart API as deprecated.
@SuppressWarnings("deprecation")
public void setIndexConfiguration(
@NonNull GeneratedAndroidFirebaseFirestore.FirestorePigeonFirebaseApp app,
@NonNull String indexConfiguration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ private static Filter filterFromJson(Map<String, Object> map) {
}
// Deserialize a FilterOperator
String op = (String) map.get("op");
@SuppressWarnings("unchecked")
List<Map<String, Object>> queries = (List<Map<String, Object>>) map.get("queries");

// Map queries recursively
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void runInstanceTests() {
],
collectionGroup: 'collectiongroup',
);

// ignore_for_file: deprecated_member_use
await firestore.setIndexConfiguration(
indexes: [index1, index2],
fieldOverrides: [fieldOverride1, fieldOverride2],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ class FirebaseFirestore extends FirebasePluginPlatform {
/// require indexing even if the indices are not yet available. Query execution will automatically
/// start using the index once the index entries have been written.
///
/// This API is in preview mode and is subject to change.
@experimental
/// This API is now deprecated
@Deprecated('setIndexConfiguration() has been deprecated.')
Future<void> setIndexConfiguration({
required List<Index> indexes,
List<FieldOverrides>? fieldOverrides,
Expand Down

0 comments on commit 1b6ef73

Please sign in to comment.