Skip to content

Commit 55c175e

Browse files
committed
Fixes #3259: Prepare to upgrade to Protobuf 4.
Address some small incompatibilities between Protobuf 3 and Protobuf 4, attempting to have code that will compile against both. * `Descriptors.FileDescriptor.getSyntax`, which was deprecated, is now removed. Use `DescriptorProtos.FileDescriptorProto.getSyntax`. * `TextFormat.shortDebugString` is deprecated. Remove newlines manually for now (only in test failure codepath). * guava is no longer a transitive dependency; add it explicitly where needed.
1 parent cda59cc commit 55c175e

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/metadata/MetaDataEvolutionValidator.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,9 @@ private void validateMessage(@Nonnull Descriptor oldDescriptor, @Nonnull Descrip
251251
}
252252
}
253253

254-
@SuppressWarnings("deprecation") // checks the deprecated syntax field
255254
private void validateProtoSyntax(@Nonnull Descriptors.Descriptor oldDescriptor, @Nonnull Descriptors.Descriptor newDescriptor) {
256-
if (!oldDescriptor.getFile().getSyntax().equals(newDescriptor.getFile().getSyntax())
257-
|| !oldDescriptor.getFile().getEdition().equals(newDescriptor.getFile().getEdition())) {
255+
if (!oldDescriptor.getFile().toProto().getSyntax().equals(newDescriptor.getFile().toProto().getSyntax())
256+
|| !oldDescriptor.getFile().toProto().getEdition().equals(newDescriptor.getFile().toProto().getEdition())) {
258257
throw new MetaDataException("message descriptor proto syntax changed",
259258
LogMessageKeys.RECORD_TYPE, oldDescriptor.getName());
260259
}

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/metadata/MetaDataEvolutionValidatorTestV3.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void nestedProto2ToProto3() {
148148
@SuppressWarnings("deprecation") // test focuses on checking the (deprecated) syntax field
149149
@Test
150150
public void onlyFileProto2ToProto3() throws InvalidProtocolBufferException {
151-
assertNotEquals(TestRecords1Proto.getDescriptor().getSyntax(), TestRecords1ImportedProto.getDescriptor().getSyntax());
151+
assertNotEquals(TestRecords1Proto.getDescriptor().toProto().getSyntax(), TestRecords1ImportedProto.getDescriptor().toProto().getSyntax());
152152
MetaDataEvolutionValidator.getDefaultInstance().validateUnion(
153153
TestRecords1Proto.RecordTypeUnion.getDescriptor(),
154154
TestRecords1ImportedProto.RecordTypeUnion.getDescriptor()

fdb-relational-server/src/test/java/com/apple/foundationdb/relational/server/RelationalServerTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ static void simpleJDBCServiceClientOperation(ManagedChannel managedChannel) {
110110
} catch (Throwable t) {
111111
com.google.rpc.Status status = StatusProto.fromThrowable(t);
112112
if (status != null) {
113-
logger.fatal(t + ", " + TextFormat.shortDebugString(status));
113+
// V3: printer().shortDebugString(status)
114+
// V4: printer().emittingSingleLine(true).printToString(status)
115+
logger.fatal(t + ", " + TextFormat.printer().printToString(status).replace("\n", " "));
114116
}
115117
throw t;
116118
} finally {

yaml-tests/yaml-tests.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ dependencies {
6363
implementation(libs.junit.api)
6464
implementation(libs.junit.params)
6565
implementation(libs.log4j.api)
66+
implementation(libs.guava)
6667
implementation(libs.protobuf)
6768
implementation(libs.protobuf.util)
6869
implementation(libs.snakeyaml)

0 commit comments

Comments
 (0)