Update to protobuf 4.x
This commit is contained in:
parent
aa5fd52302
commit
eb71e30046
17
pom.xml
17
pom.xml
|
@ -46,7 +46,7 @@
|
||||||
<!-- can be updated to latest version with Dropwizard 5 (Jetty 12); will then need to disable telemetry -->
|
<!-- can be updated to latest version with Dropwizard 5 (Jetty 12); will then need to disable telemetry -->
|
||||||
<dynamodblocal.version>2.2.1</dynamodblocal.version>
|
<dynamodblocal.version>2.2.1</dynamodblocal.version>
|
||||||
<google-cloud-libraries.version>26.57.0</google-cloud-libraries.version>
|
<google-cloud-libraries.version>26.57.0</google-cloud-libraries.version>
|
||||||
<grpc.version>1.69.0</grpc.version> <!-- should be kept in sync with the value from Google libraries-bom -->
|
<grpc.version>1.70.0</grpc.version> <!-- should be kept in sync with the value from Google libraries-bom -->
|
||||||
<gson.version>2.12.1</gson.version>
|
<gson.version>2.12.1</gson.version>
|
||||||
<!-- several libraries (AWS, Google Cloud) use Apache http components transitively, and we need to align them -->
|
<!-- several libraries (AWS, Google Cloud) use Apache http components transitively, and we need to align them -->
|
||||||
<httpcore.version>4.4.16</httpcore.version>
|
<httpcore.version>4.4.16</httpcore.version>
|
||||||
|
@ -65,9 +65,9 @@
|
||||||
<luajava.version>3.5.0</luajava.version>
|
<luajava.version>3.5.0</luajava.version>
|
||||||
<micrometer.version>1.14.5</micrometer.version>
|
<micrometer.version>1.14.5</micrometer.version>
|
||||||
<netty.version>4.1.119.Final</netty.version>
|
<netty.version>4.1.119.Final</netty.version>
|
||||||
<!-- Must be greater than or equal to the value from Google libraries-bom
|
<!-- Must be less than or equal to the value from Google libraries-bom which controls the protobuf runtime version.
|
||||||
since some of its libraries generate code. See https://protobuf.dev/support/cross-version-runtime-guarantee/. -->
|
See https://protobuf.dev/support/cross-version-runtime-guarantee/. -->
|
||||||
<protobuf.version>3.25.5</protobuf.version>
|
<protoc.version>4.29.4</protoc.version>
|
||||||
<pushy.version>0.15.4</pushy.version>
|
<pushy.version>0.15.4</pushy.version>
|
||||||
<reactive.grpc.version>1.2.4</reactive.grpc.version>
|
<reactive.grpc.version>1.2.4</reactive.grpc.version>
|
||||||
<reactor-bom.version>2024.0.4</reactor-bom.version> <!-- 3.7.4, see https://github.com/reactor/reactor#bom-versioning-scheme -->
|
<reactor-bom.version>2024.0.4</reactor-bom.version> <!-- 3.7.4, see https://github.com/reactor/reactor#bom-versioning-scheme -->
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.cloud</groupId>
|
<groupId>com.google.cloud</groupId>
|
||||||
<artifactId>libraries-bom-protobuf3</artifactId>
|
<artifactId>libraries-bom</artifactId>
|
||||||
<version>${google-cloud-libraries.version}</version>
|
<version>${google-cloud-libraries.version}</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
|
@ -175,11 +175,6 @@
|
||||||
<artifactId>pushy-dropwizard-metrics-listener</artifactId>
|
<artifactId>pushy-dropwizard-metrics-listener</artifactId>
|
||||||
<version>${pushy.version}</version>
|
<version>${pushy.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.protobuf</groupId>
|
|
||||||
<artifactId>protobuf-java</artifactId>
|
|
||||||
<version>${protobuf.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.googlecode.libphonenumber</groupId>
|
<groupId>com.googlecode.libphonenumber</groupId>
|
||||||
<artifactId>libphonenumber</artifactId>
|
<artifactId>libphonenumber</artifactId>
|
||||||
|
@ -443,7 +438,7 @@
|
||||||
<version>0.6.1</version>
|
<version>0.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<checkStaleness>false</checkStaleness>
|
<checkStaleness>false</checkStaleness>
|
||||||
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
|
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
|
||||||
<pluginId>grpc-java</pluginId>
|
<pluginId>grpc-java</pluginId>
|
||||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
|
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.whispersystems.textsecuregcm.grpc;
|
||||||
import static org.whispersystems.textsecuregcm.grpc.validators.ValidatorUtils.internalError;
|
import static org.whispersystems.textsecuregcm.grpc.validators.ValidatorUtils.internalError;
|
||||||
|
|
||||||
import com.google.protobuf.Descriptors;
|
import com.google.protobuf.Descriptors;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.Message;
|
||||||
import io.grpc.ForwardingServerCallListener;
|
import io.grpc.ForwardingServerCallListener;
|
||||||
import io.grpc.Metadata;
|
import io.grpc.Metadata;
|
||||||
import io.grpc.ServerCall;
|
import io.grpc.ServerCall;
|
||||||
|
@ -75,7 +75,7 @@ public class ValidatingInterceptor implements ServerInterceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMessage(final Object message) throws StatusException {
|
private void validateMessage(final Object message) throws StatusException {
|
||||||
if (message instanceof GeneratedMessageV3 msg) {
|
if (message instanceof Message msg) {
|
||||||
try {
|
try {
|
||||||
for (final Descriptors.FieldDescriptor fd: msg.getDescriptorForType().getFields()) {
|
for (final Descriptors.FieldDescriptor fd: msg.getDescriptorForType().getFields()) {
|
||||||
for (final Map.Entry<Descriptors.FieldDescriptor, Object> entry: fd.getOptions().getAllFields().entrySet()) {
|
for (final Map.Entry<Descriptors.FieldDescriptor, Object> entry: fd.getOptions().getAllFields().entrySet()) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import static org.whispersystems.textsecuregcm.grpc.validators.ValidatorUtils.in
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Descriptors;
|
import com.google.protobuf.Descriptors;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
import io.grpc.StatusException;
|
import io.grpc.StatusException;
|
||||||
|
@ -49,7 +48,7 @@ public abstract class BaseFieldValidator<T> implements FieldValidator {
|
||||||
public void validate(
|
public void validate(
|
||||||
final Object extensionValue,
|
final Object extensionValue,
|
||||||
final Descriptors.FieldDescriptor fd,
|
final Descriptors.FieldDescriptor fd,
|
||||||
final GeneratedMessageV3 msg) throws StatusException {
|
final Message msg) throws StatusException {
|
||||||
try {
|
try {
|
||||||
final T extensionValueTyped = resolveExtensionValue(extensionValue);
|
final T extensionValueTyped = resolveExtensionValue(extensionValue);
|
||||||
|
|
||||||
|
@ -116,7 +115,7 @@ public abstract class BaseFieldValidator<T> implements FieldValidator {
|
||||||
protected void validateRepeatedField(
|
protected void validateRepeatedField(
|
||||||
final T extensionValue,
|
final T extensionValue,
|
||||||
final Descriptors.FieldDescriptor fd,
|
final Descriptors.FieldDescriptor fd,
|
||||||
final GeneratedMessageV3 msg) throws StatusException {
|
final Message msg) throws StatusException {
|
||||||
throw internalError("`validateRepeatedField` method needs to be implemented");
|
throw internalError("`validateRepeatedField` method needs to be implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import static org.whispersystems.textsecuregcm.grpc.validators.ValidatorUtils.in
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Descriptors;
|
import com.google.protobuf.Descriptors;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.Message;
|
||||||
import io.grpc.StatusException;
|
import io.grpc.StatusException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -53,7 +53,7 @@ public class ExactlySizeFieldValidator extends BaseFieldValidator<Set<Integer>>
|
||||||
protected void validateRepeatedField(
|
protected void validateRepeatedField(
|
||||||
final Set<Integer> permittedSizes,
|
final Set<Integer> permittedSizes,
|
||||||
final Descriptors.FieldDescriptor fd,
|
final Descriptors.FieldDescriptor fd,
|
||||||
final GeneratedMessageV3 msg) throws StatusException {
|
final Message msg) throws StatusException {
|
||||||
final int size = msg.getRepeatedFieldCount(fd);
|
final int size = msg.getRepeatedFieldCount(fd);
|
||||||
if (permittedSizes.contains(size)) {
|
if (permittedSizes.contains(size)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
package org.whispersystems.textsecuregcm.grpc.validators;
|
package org.whispersystems.textsecuregcm.grpc.validators;
|
||||||
|
|
||||||
import com.google.protobuf.Descriptors;
|
import com.google.protobuf.Descriptors;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.Message;
|
||||||
import io.grpc.StatusException;
|
import io.grpc.StatusException;
|
||||||
|
|
||||||
public interface FieldValidator {
|
public interface FieldValidator {
|
||||||
|
|
||||||
void validate(Object extensionValue, Descriptors.FieldDescriptor fd, GeneratedMessageV3 msg)
|
void validate(Object extensionValue, Descriptors.FieldDescriptor fd, Message msg)
|
||||||
throws StatusException;
|
throws StatusException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import static org.whispersystems.textsecuregcm.grpc.validators.ValidatorUtils.in
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Descriptors;
|
import com.google.protobuf.Descriptors;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.Message;
|
||||||
import io.grpc.StatusException;
|
import io.grpc.StatusException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -52,7 +52,7 @@ public class NonEmptyFieldValidator extends BaseFieldValidator<Boolean> {
|
||||||
protected void validateRepeatedField(
|
protected void validateRepeatedField(
|
||||||
final Boolean extensionValue,
|
final Boolean extensionValue,
|
||||||
final Descriptors.FieldDescriptor fd,
|
final Descriptors.FieldDescriptor fd,
|
||||||
final GeneratedMessageV3 msg) throws StatusException {
|
final Message msg) throws StatusException {
|
||||||
if (msg.getRepeatedFieldCount(fd) > 0) {
|
if (msg.getRepeatedFieldCount(fd) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import static org.whispersystems.textsecuregcm.grpc.validators.ValidatorUtils.in
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Descriptors;
|
import com.google.protobuf.Descriptors;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.Message;
|
||||||
import io.grpc.StatusException;
|
import io.grpc.StatusException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.signal.chat.require.SizeConstraint;
|
import org.signal.chat.require.SizeConstraint;
|
||||||
|
@ -48,7 +48,7 @@ public class SizeFieldValidator extends BaseFieldValidator<Range> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void validateRepeatedField(final Range range, final Descriptors.FieldDescriptor fd, final GeneratedMessageV3 msg) throws StatusException {
|
protected void validateRepeatedField(final Range range, final Descriptors.FieldDescriptor fd, final Message msg) throws StatusException {
|
||||||
final int size = msg.getRepeatedFieldCount(fd);
|
final int size = msg.getRepeatedFieldCount(fd);
|
||||||
if (size < range.min() || size > range.max()) {
|
if (size < range.min() || size > range.max()) {
|
||||||
throw invalidArgument("field value is [%d] but expected to be within the [%d, %d] range".formatted(
|
throw invalidArgument("field value is [%d] but expected to be within the [%d, %d] range".formatted(
|
||||||
|
|
Loading…
Reference in New Issue