Skip to content

Commit 229ab05

Browse files
schmidt-sebastianchingor13
authored andcommitted
Firestore: Validate that at least one argument is provided for Cursor (#3900)
1 parent 327e1b6 commit 229ab05

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ private Cursor createCursor(
336336
private Cursor createCursor(List<FieldOrder> order, Object[] fieldValues, boolean before) {
337337
Cursor.Builder result = Cursor.newBuilder();
338338

339+
Preconditions.checkState(
340+
fieldValues.length != 0, "At least one cursor value must be specified.");
341+
339342
Preconditions.checkState(
340343
fieldValues.length <= order.size(),
341344
"Too many cursor values specified. The specified values must match the "

google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ private interface ConformanceTestCase extends Test, Describable {}
106106
/** If non-empty, only runs tests included in this set. */
107107
private final Set<String> includedTests = Collections.emptySet();
108108

109+
/** If true, prints debug information to System.out. */
110+
private final boolean DEBUG_MODE = !includedTests.isEmpty();
111+
109112
@Captor private ArgumentCaptor<CommitRequest> commitCapture;
110113

111114
@Captor private ArgumentCaptor<BatchGetDocumentsRequest> getAllCapture;
@@ -386,8 +389,9 @@ public void run(TestResult testResult) {
386389
new Protectable() {
387390
@Override
388391
public void protect() throws Throwable {
389-
// Uncomment to print the test protobuf:
390-
// System.out.println(testDefinition);
392+
if (DEBUG_MODE) {
393+
System.out.println(testDefinition);
394+
}
391395

392396
switch (testDefinition.getTestCase()) {
393397
case GET:
Binary file not shown.

0 commit comments

Comments
 (0)