Forráskód Böngészése

v3rpc: force RangeEnd=nil if length is 0

gRPC will replace empty strings with nil, but for the embedded case it's
possible for []byte{} to slip in and confuse the single key / >= key
watch logic.
Anthony Romano 8 éve
szülő
commit
135a40751e
1 módosított fájl, 5 hozzáadás és 0 törlés
  1. 5 0
      etcdserver/api/v3rpc/watch.go

+ 5 - 0
etcdserver/api/v3rpc/watch.go

@@ -171,6 +171,11 @@ func (sws *serverWatchStream) recvLoop() error {
 				// \x00 is the smallest key
 				creq.Key = []byte{0}
 			}
+			if len(creq.RangeEnd) == 0 {
+				// force nil since watchstream.Watch distinguishes
+				// between nil and []byte{} for single key / >=
+				creq.RangeEnd = nil
+			}
 			if len(creq.RangeEnd) == 1 && creq.RangeEnd[0] == 0 {
 				// support  >= key queries
 				creq.RangeEnd = []byte{}