From d78ddcecb68f0da69a51968fca74aeaa40f123fb Mon Sep 17 00:00:00 2001 From: Olga Maciaszek-Sharma Date: Tue, 6 May 2025 16:54:01 +0200 Subject: [PATCH] Upgrade to protobuf-java 3.25.7. Fixes gh-1190. Signed-off-by: Olga Maciaszek-Sharma --- spring-cloud-openfeign-core/pom.xml | 2 +- .../encoding/proto/ProtobufTest.java | 52 +- .../openfeign/encoding/proto/Request.java | 632 ++++++++++-------- .../encoding/proto/RequestOrBuilder.java | 9 +- .../src/test/resources/proto/request.proto | 12 + src/checkstyle/checkstyle-suppressions.xml | 4 + 6 files changed, 389 insertions(+), 322 deletions(-) create mode 100644 spring-cloud-openfeign-core/src/test/resources/proto/request.proto diff --git a/spring-cloud-openfeign-core/pom.xml b/spring-cloud-openfeign-core/pom.xml index cd726f90..c5b1a75f 100644 --- a/spring-cloud-openfeign-core/pom.xml +++ b/spring-cloud-openfeign-core/pom.xml @@ -174,7 +174,7 @@ com.google.protobuf protobuf-java - 3.25.5 + 3.25.7 test diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufTest.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufTest.java index 150cd034..e3bb4638 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufTest.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2022 the original author or authors. + * Copyright 2013-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,40 +15,12 @@ */ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: protobuf_test.proto +// source: request.proto package org.springframework.cloud.openfeign.encoding.proto; public final class ProtobufTest { - static final com.google.protobuf.Descriptors.Descriptor internal_static_Request_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_Request_fieldAccessorTable; - - private static com.google.protobuf.Descriptors.FileDescriptor descriptor; - - static { - String[] descriptorData = { """ - - \023protobuf_test.proto"" - \007Request\022 - - \002id\030\001 \001(\005\022\013 - \003msg\030\002 \001(\tB\024 - \020feign.httpclientP\001b\006proto3""" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] {}, assigner); - internal_static_Request_descriptor = getDescriptor().getMessageTypes().get(0); - internal_static_Request_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_Request_descriptor, new String[] { "Id", "Msg", }); - } - private ProtobufTest() { } @@ -59,10 +31,30 @@ public final class ProtobufTest { registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); } + static final com.google.protobuf.Descriptors.Descriptor internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_fieldAccessorTable; + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; } + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + String[] descriptorData = { + "\n\rrequest.proto\0222org.springframework.clo" + "ud.openfeign.encoding.proto\"\"\n\007Request\022\n" + + "\n\002id\030\001 \001(\005\022\013\n\003msg\030\002 \001(\tBD\n2org.springfra" + + "mework.cloud.openfeign.encoding.protoB\014P" + "rotobufTestP\001b\006proto3" }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] {}); + internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_descriptor = getDescriptor() + .getMessageTypes() + .get(0); + internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_descriptor, + new String[] { "Id", "Msg", }); + } + // @@protoc_insertion_point(outer_class_scope) } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/Request.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/Request.java index 5df50ffd..80a84a65 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/Request.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/Request.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2022 the original author or authors. + * Copyright 2013-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,97 +15,178 @@ */ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: protobuf_test.proto +// source: request.proto package org.springframework.cloud.openfeign.encoding.proto; /** - * Protobuf type {@code Request} + * Protobuf type {@code org.springframework.cloud.openfeign.encoding.proto.Request} */ public final class Request extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:Request) - org.springframework.cloud.openfeign.encoding.proto.RequestOrBuilder { - - public static final int ID_FIELD_NUMBER = 1; - - public static final int MSG_FIELD_NUMBER = 2; + // @@protoc_insertion_point(message_implements:org.springframework.cloud.openfeign.encoding.proto.Request) + RequestOrBuilder { private static final long serialVersionUID = 0L; - // @@protoc_insertion_point(class_scope:Request) - private static final Request DEFAULT_INSTANCE; - - private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser<>() { - public Request parsePartialFrom(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Request(input, extensionRegistry); - } - }; - - static { - DEFAULT_INSTANCE = new Request(); - } - - private int id_; - - private volatile Object msg_; - - private byte memoizedIsInitialized = -1; - // Use Request.newBuilder() to construct. private Request(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } private Request() { - this.id_ = 0; - this.msg_ = ""; + msg_ = ""; } - private Request(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: - if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - case 8: - this.id_ = input.readInt32(); - break; - case 18: - String s = input.readStringRequireUtf8(); - this.msg_ = s; - break; - } - } + @Override + @SuppressWarnings({ "unused" }) + protected Object newInstance(UnusedPrivateParameter unused) { + return new Request(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return ProtobufTest.internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_descriptor; + } + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + return ProtobufTest.internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_fieldAccessorTable + .ensureFieldAccessorsInitialized(Request.class, Builder.class); + } + + public static final int ID_FIELD_NUMBER = 1; + + private int id_ = 0; + + /** + * int32 id = 1; + * @return The id. + */ + @Override + public int getId() { + return id_; + } + + public static final int MSG_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile Object msg_ = ""; + + /** + * string msg = 2; + * @return The msg. + */ + @Override + public String getMsg() { + Object ref = msg_; + if (ref instanceof String) { + return (String) ref; } - catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } - catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); - } - finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); + else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + msg_ = s; + return s; } } - public static com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_descriptor; + /** + * string msg = 2; + * @return The bytes for msg. + */ + @Override + public com.google.protobuf.ByteString getMsgBytes() { + Object ref = msg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); + msg_ = b; + return b; + } + else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) + return true; + if (isInitialized == 0) + return false; + + memoizedIsInitialized = 1; + return true; + } + + @Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (id_ != 0) { + output.writeInt32(1, id_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(msg_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, msg_); + } + getUnknownFields().writeTo(output); + } + + @Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) + return size; + + size = 0; + if (id_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, id_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(msg_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, msg_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Request)) { + return super.equals(obj); + } + Request other = (Request) obj; + + if (getId() != other.getId()) + return false; + if (!getMsg().equals(other.getMsg())) + return false; + if (!getUnknownFields().equals(other.getUnknownFields())) + return false; + return true; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId(); + hash = (37 * hash) + MSG_FIELD_NUMBER; + hash = (53 * hash) + getMsg().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; } public static Request parseFrom(java.nio.ByteBuffer data) @@ -166,6 +247,11 @@ public final class Request extends com.google.protobuf.GeneratedMessageV3 implem return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry); } + @Override + public Builder newBuilderForType() { + return newBuilder(); + } + public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } @@ -174,208 +260,65 @@ public final class Request extends com.google.protobuf.GeneratedMessageV3 implem return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } - public static Request getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - @Override - public com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - protected FieldAccessorTable internalGetFieldAccessorTable() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_fieldAccessorTable - .ensureFieldAccessorsInitialized(Request.class, Request.Builder.class); - } - - /** - * int32 id = 1; - */ - public int getId() { - return this.id_; - } - - /** - * string msg = 2; - */ - public String getMsg() { - Object ref = this.msg_; - if (ref instanceof String) { - return (String) ref; - } - else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - this.msg_ = s; - return s; - } - } - - /** - * string msg = 2; - */ - public com.google.protobuf.ByteString getMsgBytes() { - Object ref = this.msg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - this.msg_ = b; - return b; - } - else { - return (com.google.protobuf.ByteString) ref; - } - } - - public boolean isInitialized() { - byte isInitialized = this.memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - this.memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (this.id_ != 0) { - output.writeInt32(1, this.id_); - } - if (!getMsgBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, this.msg_); - } - this.unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = this.memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (this.id_ != 0) { - size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, this.id_); - } - if (!getMsgBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, this.msg_); - } - size += this.unknownFields.getSerializedSize(); - this.memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Request other)) { - return super.equals(obj); - } - - boolean result = true; - result = result && (getId() == other.getId()); - result = result && getMsg().equals(other.getMsg()); - result = result && this.unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (this.memoizedHashCode != 0) { - return this.memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ID_FIELD_NUMBER; - hash = (53 * hash) + getId(); - hash = (37 * hash) + MSG_FIELD_NUMBER; - hash = (53 * hash) + getMsg().hashCode(); - hash = (29 * hash) + this.unknownFields.hashCode(); - this.memoizedHashCode = hash; - return hash; - } - - public Builder newBuilderForType() { - return newBuilder(); - } - public Builder toBuilder() { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); } @Override protected Builder newBuilderForType(BuilderParent parent) { - return new Builder(parent); - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Request getDefaultInstanceForType() { - return DEFAULT_INSTANCE; + Builder builder = new Builder(parent); + return builder; } /** - * Protobuf type {@code Request} + * Protobuf type {@code org.springframework.cloud.openfeign.encoding.proto.Request} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:Request) - org.springframework.cloud.openfeign.encoding.proto.RequestOrBuilder { + // @@protoc_insertion_point(builder_implements:org.springframework.cloud.openfeign.encoding.proto.Request) + RequestOrBuilder { - private int id_; + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return ProtobufTest.internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_descriptor; + } - private Object msg_ = ""; + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + return ProtobufTest.internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_fieldAccessorTable + .ensureFieldAccessorsInitialized(Request.class, Builder.class); + } // Construct using // org.springframework.cloud.openfeign.encoding.proto.Request.newBuilder() private Builder() { - maybeForceBuilderInitialization(); + } private Builder(BuilderParent parent) { super(parent); - maybeForceBuilderInitialization(); - } - - public static com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_descriptor; - } - - protected FieldAccessorTable internalGetFieldAccessorTable() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_fieldAccessorTable - .ensureFieldAccessorsInitialized(Request.class, Request.Builder.class); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { - // TODO: Remove this? - } + } + @Override public Builder clear() { super.clear(); - this.id_ = 0; - this.msg_ = ""; + bitField0_ = 0; + id_ = 0; + msg_ = ""; return this; } + @Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_descriptor; + return ProtobufTest.internal_static_org_springframework_cloud_openfeign_encoding_proto_Request_descriptor; } + @Override public Request getDefaultInstanceForType() { return Request.getDefaultInstance(); } + @Override public Request build() { Request result = buildPartial(); if (!result.isInitialized()) { @@ -384,39 +327,58 @@ public final class Request extends com.google.protobuf.GeneratedMessageV3 implem return result; } + @Override public Request buildPartial() { Request result = new Request(this); - result.id_ = this.id_; - result.msg_ = this.msg_; + if (bitField0_ != 0) { + buildPartial0(result); + } onBuilt(); return result; } + private void buildPartial0(Request result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.id_ = id_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.msg_ = msg_; + } + } + + @Override public Builder clone() { - return (Builder) super.clone(); + return super.clone(); } + @Override public Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return (Builder) super.setField(field, value); + return super.setField(field, value); } + @Override public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); + return super.clearField(field); } + @Override public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); + return super.clearOneof(oneof); } + @Override public Builder setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); + return super.setRepeatedField(field, index, value); } + @Override public Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return (Builder) super.addRepeatedField(field, value); + return super.addRepeatedField(field, value); } + @Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof Request) { return mergeFrom((Request) other); @@ -428,79 +390,117 @@ public final class Request extends com.google.protobuf.GeneratedMessageV3 implem } public Builder mergeFrom(Request other) { - if (other == Request.getDefaultInstance()) { + if (other == Request.getDefaultInstance()) return this; - } if (other.getId() != 0) { setId(other.getId()); } if (!other.getMsg().isEmpty()) { - this.msg_ = other.msg_; + msg_ = other.msg_; + bitField0_ |= 0x00000002; onChanged(); } - this.mergeUnknownFields(other.unknownFields); + this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; } - public boolean isInitialized() { + @Override + public final boolean isInitialized() { return true; } + @Override public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - Request parsedMessage = null; + if (extensionRegistry == null) { + throw new NullPointerException(); + } try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + id_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + msg_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Request) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } + onChanged(); + } // finally return this; } + private int bitField0_; + + private int id_; + /** * int32 id = 1; + * @return The id. */ + @Override public int getId() { - return this.id_; + return id_; } /** * int32 id = 1; + * @param value The id to set. + * @return This builder for chaining. */ public Builder setId(int value) { - this.id_ = value; + id_ = value; + bitField0_ |= 0x00000001; onChanged(); return this; } /** * int32 id = 1; + * @return This builder for chaining. */ public Builder clearId() { - - this.id_ = 0; + bitField0_ = (bitField0_ & ~0x00000001); + id_ = 0; onChanged(); return this; } + private Object msg_ = ""; + /** * string msg = 2; + * @return The msg. */ public String getMsg() { - Object ref = this.msg_; + Object ref = msg_; if (!(ref instanceof String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; String s = bs.toStringUtf8(); - this.msg_ = s; + msg_ = s; return s; } else { @@ -510,25 +510,13 @@ public final class Request extends com.google.protobuf.GeneratedMessageV3 implem /** * string msg = 2; - */ - public Builder setMsg(String value) { - if (value == null) { - throw new NullPointerException(); - } - - this.msg_ = value; - onChanged(); - return this; - } - - /** - * string msg = 2; + * @return The bytes for msg. */ public com.google.protobuf.ByteString getMsgBytes() { - Object ref = this.msg_; + Object ref = msg_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - this.msg_ = b; + msg_ = b; return b; } else { @@ -538,38 +526,106 @@ public final class Request extends com.google.protobuf.GeneratedMessageV3 implem /** * string msg = 2; + * @param value The msg to set. + * @return This builder for chaining. */ - public Builder setMsgBytes(com.google.protobuf.ByteString value) { + public Builder setMsg(String value) { if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - - this.msg_ = value; + msg_ = value; + bitField0_ |= 0x00000002; onChanged(); return this; } /** * string msg = 2; + * @return This builder for chaining. */ public Builder clearMsg() { - - this.msg_ = getDefaultInstance().getMsg(); + msg_ = getDefaultInstance().getMsg(); + bitField0_ = (bitField0_ & ~0x00000002); onChanged(); return this; } - public Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); + /** + * string msg = 2; + * @param value The bytes for msg to set. + * @return This builder for chaining. + */ + public Builder setMsgBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + msg_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; } - public Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + @Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @Override + public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); } - // @@protoc_insertion_point(builder_scope:Request) + // @@protoc_insertion_point(builder_scope:org.springframework.cloud.openfeign.encoding.proto.Request) } + // @@protoc_insertion_point(class_scope:org.springframework.cloud.openfeign.encoding.proto.Request) + private static final Request DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new Request(); + } + + public static Request getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @Override + public Request parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } + catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } + catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } + catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @Override + public Request getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/RequestOrBuilder.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/RequestOrBuilder.java index 131435cc..f5339175 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/RequestOrBuilder.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/RequestOrBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2022 the original author or authors. + * Copyright 2013-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,26 +15,29 @@ */ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: protobuf_test.proto +// source: request.proto package org.springframework.cloud.openfeign.encoding.proto; public interface RequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:Request) + // @@protoc_insertion_point(interface_extends:org.springframework.cloud.openfeign.encoding.proto.Request) com.google.protobuf.MessageOrBuilder { /** * int32 id = 1; + * @return The id. */ int getId(); /** * string msg = 2; + * @return The msg. */ String getMsg(); /** * string msg = 2; + * @return The bytes for msg. */ com.google.protobuf.ByteString getMsgBytes(); diff --git a/spring-cloud-openfeign-core/src/test/resources/proto/request.proto b/spring-cloud-openfeign-core/src/test/resources/proto/request.proto new file mode 100644 index 00000000..795b2ba8 --- /dev/null +++ b/spring-cloud-openfeign-core/src/test/resources/proto/request.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package org.springframework.cloud.openfeign.encoding.proto; + +option java_package = "org.springframework.cloud.openfeign.encoding.proto"; +option java_outer_classname = "ProtobufTest"; +option java_multiple_files = true; + +message Request { + int32 id = 1; + string msg = 2; +} diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index 8a6d8271..c8cfd53b 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -18,4 +18,8 @@ + + + +