From d770e51f247f5c2fbdaab7ac8ca42439f537101f Mon Sep 17 00:00:00 2001 From: srinjoyray Date: Thu, 7 Nov 2024 15:01:02 +0530 Subject: [PATCH] wip - fixed DatastoreCallbacksTests --- .../api/datastore/AsyncDatastoreServiceImpl.java | 5 +++-- .../appengine/api/datastore/DataTypeTranslator.java | 4 ++-- .../api/datastore/dev/LocalDatastoreService.java | 12 ++++++------ shared_sdk/pom.xml | 4 ---- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/api/src/main/java/com/google/appengine/api/datastore/AsyncDatastoreServiceImpl.java b/api/src/main/java/com/google/appengine/api/datastore/AsyncDatastoreServiceImpl.java index aa33b3eb..124c88e1 100644 --- a/api/src/main/java/com/google/appengine/api/datastore/AsyncDatastoreServiceImpl.java +++ b/api/src/main/java/com/google/appengine/api/datastore/AsyncDatastoreServiceImpl.java @@ -43,6 +43,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.protobuf.Message; +import com.google.protobuf.MessageLite; import com.google.protobuf.MessageLiteOrBuilder; import com.google.storage.onestore.v3.proto2api.OnestoreEntity.CompositeIndex; import com.google.storage.onestore.v3.proto2api.OnestoreEntity.EntityProto; @@ -79,13 +80,13 @@ class AsyncDatastoreServiceImpl extends BaseAsyncDatastoreServiceImpl { */ private abstract class V3Batcher< S extends Message, - R extends MessageLiteOrBuilder, + R extends MessageLite.Builder, F, T extends Message> extends BaseRpcBatcher { @Override final R newBatch(R baseBatch) { - return (R) baseBatch.getDefaultInstanceForType().toBuilder().clone(); + return (R) baseBatch.clone(); } } diff --git a/api/src/main/java/com/google/appengine/api/datastore/DataTypeTranslator.java b/api/src/main/java/com/google/appengine/api/datastore/DataTypeTranslator.java index 227ee4fa..98958ba3 100644 --- a/api/src/main/java/com/google/appengine/api/datastore/DataTypeTranslator.java +++ b/api/src/main/java/com/google/appengine/api/datastore/DataTypeTranslator.java @@ -1665,7 +1665,7 @@ public EmbeddedEntity getValue(PropertyValue propertyValue) { if (proto.hasKey() && !proto.getKey().getApp().isEmpty()) { result.setKey(KeyTranslator.createFromPb(proto.getKey())); } - extractPropertiesFromPb(proto.build(), result.getPropertyMap()); + extractPropertiesFromPb(proto.buildPartial(), result.getPropertyMap()); return result; } @@ -1689,7 +1689,7 @@ public void toV3Value(Object value, PropertyValue.Builder propertyValue) { } addPropertiesToPb(structProp.getPropertyMap(), proto); // TODO: Figure out how to do partial serialization. - propertyValue.setStringValueBytes(proto.build().toByteString()).build(); + propertyValue.setStringValueBytes(proto.buildPartial().toByteString()).build(); } @Override diff --git a/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalDatastoreService.java b/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalDatastoreService.java index 96c937a9..06be6e7a 100644 --- a/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalDatastoreService.java +++ b/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalDatastoreService.java @@ -864,12 +864,12 @@ public PutResponse putImpl(Status status, PutRequest request) { EntityProto.Builder clone = entity.toBuilder().clone(); clones.add(clone.build()); checkArgument(clone.hasKey()); - Reference key = clone.getKey(); + Reference.Builder key = clone.getKeyBuilder(); checkArgument(key.getPath().getElementCount() > 0); - clone.getKey().toBuilder().setApp(app); + clone.getKeyBuilder().setApp(app); - Element.Builder lastPath = getLastElement(key).toBuilder(); + Element.Builder lastPath = getLastElement(key.build()).toBuilder(); if (lastPath.getId() == 0 && !lastPath.hasName()) { if (autoIdAllocationPolicy == AutoIdAllocationPolicy.SEQUENTIAL) { @@ -878,12 +878,12 @@ public PutResponse putImpl(Status status, PutRequest request) { lastPath.setId(toScatteredId(entityIdScattered.getAndIncrement())); } } - + key.getPathBuilder().setElement(key.getPath().getElementCount() - 1, lastPath); preprocessEntity(clone); if (clone.getEntityGroup().getElementCount() == 0) { // The entity needs its entity group set. - Path.Builder group = clone.getEntityGroup().toBuilder(); + Path.Builder group = clone.getEntityGroupBuilder(); Element root = key.getPath().getElementList().get(0); Element.Builder pathElement = group.addElementBuilder(); pathElement.setType(root.getType()); @@ -2775,7 +2775,7 @@ private EntityProto.Builder postProcessEntityForQuery(EntityProto entity) { .mergeFrom(prop.getValue()); } } - } else if (query.hasKeysOnly()) { + } else if (query.getKeysOnly()) { result = EntityProto.newBuilder(); result.getKeyBuilder().mergeFrom(entity.getKey()); result.getEntityGroup(); diff --git a/shared_sdk/pom.xml b/shared_sdk/pom.xml index 74a7b642..76621692 100644 --- a/shared_sdk/pom.xml +++ b/shared_sdk/pom.xml @@ -56,9 +56,5 @@ auto-value provided - - com.google.appengine - appengine-apis -