6464
6565class InvocationStubImpl implements ChaincodeStub {
6666
67- private static final String UNSPECIFIED_KEY = new String (Character .toChars (0x000001 ));
67+ private static final String UNSPECIFIED_START_KEY = new String (Character .toChars (0x000001 ));
68+ private static final String UNSPECIFIED_END_KEY = "" ;
6869 private static final Logger LOGGER = Logger .getLogger (InvocationStubImpl .class .getName ());
6970
7071 public static final String MAX_UNICODE_RUNE = "\udbff \udfff " ;
@@ -248,11 +249,11 @@ public QueryResultsIterator<KeyValue> getStateByRange(final String startKey, fin
248249 String start = startKey ;
249250 String end = endKey ;
250251
251- if (startKey == null ) {
252- start = UNSPECIFIED_KEY ;
252+ if (startKey == null || startKey . isEmpty () ) {
253+ start = UNSPECIFIED_START_KEY ;
253254 }
254255 if (endKey == null ) {
255- end = UNSPECIFIED_KEY ;
256+ end = UNSPECIFIED_END_KEY ;
256257 }
257258 CompositeKey .validateSimpleKeys (start , end );
258259
@@ -293,11 +294,11 @@ public QueryResultsIteratorWithMetadata<KeyValue> getStateByRangeWithPagination(
293294 String start = startKey ;
294295 String end = endKey ;
295296
296- if (startKey == null ) {
297- start = UNSPECIFIED_KEY ;
297+ if (startKey == null || startKey . isEmpty () ) {
298+ start = UNSPECIFIED_START_KEY ;
298299 }
299300 if (endKey == null ) {
300- end = UNSPECIFIED_KEY ;
301+ end = UNSPECIFIED_END_KEY ;
301302 }
302303
303304 CompositeKey .validateSimpleKeys (start , end );
@@ -350,7 +351,7 @@ public QueryResultsIterator<KeyValue> getStateByPartialCompositeKey(final Compos
350351 String cKeyAsString ;
351352
352353 if (compositeKey == null ) {
353- cKeyAsString = new CompositeKey (UNSPECIFIED_KEY ).toString ();
354+ cKeyAsString = new CompositeKey (UNSPECIFIED_START_KEY ).toString ();
354355 } else {
355356 cKeyAsString = compositeKey .toString ();
356357 }
@@ -365,7 +366,7 @@ public QueryResultsIteratorWithMetadata<KeyValue> getStateByPartialCompositeKeyW
365366 String cKeyAsString ;
366367
367368 if (compositeKey == null ) {
368- cKeyAsString = new CompositeKey (UNSPECIFIED_KEY ).toString ();
369+ cKeyAsString = new CompositeKey (UNSPECIFIED_START_KEY ).toString ();
369370 } else {
370371 cKeyAsString = compositeKey .toString ();
371372 }
@@ -520,11 +521,11 @@ public QueryResultsIterator<KeyValue> getPrivateDataByRange(final String collect
520521 String end = endKey ;
521522
522523 validateCollection (collection );
523- if (startKey == null ) {
524- start = UNSPECIFIED_KEY ;
524+ if (startKey == null || startKey . isEmpty () ) {
525+ start = UNSPECIFIED_START_KEY ;
525526 }
526527 if (endKey == null ) {
527- end = UNSPECIFIED_KEY ;
528+ end = UNSPECIFIED_END_KEY ;
528529 }
529530 CompositeKey .validateSimpleKeys (start , end );
530531
@@ -553,7 +554,7 @@ public QueryResultsIterator<KeyValue> getPrivateDataByPartialCompositeKey(final
553554 final CompositeKey compositeKey ) {
554555 String cKeyAsString ;
555556 if (compositeKey == null ) {
556- cKeyAsString = new CompositeKey (UNSPECIFIED_KEY ).toString ();
557+ cKeyAsString = new CompositeKey (UNSPECIFIED_START_KEY ).toString ();
557558 } else {
558559 cKeyAsString = compositeKey .toString ();
559560 }
0 commit comments