Skip to content

Commit

Permalink
mongodb: fix sonnar issues, #TASK-7151, #TASK-7134
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Nov 13, 2024
1 parent ea3906c commit e68c30e
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ private <T> DataResult<T> endQuery(List result, long numMatches, double start) {
long end = System.currentTimeMillis();
int numResults = (result != null) ? result.size() : 0;

DataResult<T> queryResult = new DataResult((int) (end - start), Collections.emptyList(), numResults, result, numMatches, null);
return queryResult;
return new DataResult((int) (end - start), Collections.emptyList(), numResults, result, numMatches, null);
}

private DataResult endWrite(long start) {
Expand Down Expand Up @@ -333,7 +332,7 @@ public <T> DataResult<T> aggregate(List<? extends Bson> operations, ComplexTypeC
long start = startQuery();
DataResult<T> queryResult;
List<T> list = new LinkedList<>();
if (operations != null && operations.size() > 0) {
if (operations != null && !operations.isEmpty()) {
MongoDBIterator<T> iterator = mongoDBNativeQuery.aggregate(operations, converter, options);
if (queryResultWriter != null) {
try {
Expand All @@ -347,7 +346,7 @@ public <T> DataResult<T> aggregate(List<? extends Bson> operations, ComplexTypeC
}
} else {
while (iterator.hasNext()) {
list.add((T) iterator.next());
list.add(iterator.next());
}
}
}
Expand Down Expand Up @@ -429,7 +428,7 @@ public DataResult update(ClientSession clientSession, List<? extends Bson> queri

return endWrite(
wr.getMatchedCount(),
wr.getInsertedCount() + wr.getUpserts().size(),
(long) wr.getInsertedCount() + wr.getUpserts().size(),
wr.getModifiedCount(),
wr.getDeletedCount(),
0,
Expand Down Expand Up @@ -547,8 +546,7 @@ public DataResult createIndex(Bson keys, ObjectMap options) {
}

mongoDBNativeQuery.createIndex(keys, i);
DataResult dataResult = endQuery(Collections.emptyList(), start);
return dataResult;
return endQuery(Collections.emptyList(), start);
}

public void dropIndexes() {
Expand All @@ -558,15 +556,13 @@ public void dropIndexes() {
public DataResult dropIndex(Bson keys) {
long start = startQuery();
mongoDBNativeQuery.dropIndex(keys);
DataResult dataResult = endQuery(Collections.emptyList(), start);
return dataResult;
return endQuery(Collections.emptyList(), start);
}

public DataResult<Document> getIndex() {
long start = startQuery();
List<Document> index = mongoDBNativeQuery.getIndex();
DataResult<Document> queryResult = endQuery(index, start);
return queryResult;
return endQuery(index, start);
}


Expand Down

0 comments on commit e68c30e

Please sign in to comment.