Protos: Remove unused method and thus cut dependency on gwtorm
We got rid of all usages of this method and can now safely remove it. Change-Id: Ia6a886084e2f57bc9c240a9ce317733408606566
This commit is contained in:

committed by
Dave Borowitz

parent
ab80c219a4
commit
9a2b06ed90
@@ -3,7 +3,6 @@ java_library(
|
||||
srcs = ["Protos.java"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//lib:gwtorm",
|
||||
"//lib:protobuf",
|
||||
],
|
||||
)
|
||||
|
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.proto;
|
||||
|
||||
import com.google.gwtorm.protobuf.ProtobufCodec;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.CodedOutputStream;
|
||||
import com.google.protobuf.MessageLite;
|
||||
@@ -68,29 +67,6 @@ public class Protos {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes an object to a {@link ByteString} using a protobuf codec.
|
||||
*
|
||||
* <p>Guarantees deterministic serialization. No matter whether the use case cares about
|
||||
* determinism or not, always use this method in preference to {@link
|
||||
* ProtobufCodec#encodeToByteString(Object)}, which is not guaranteed deterministic.
|
||||
*
|
||||
* @param object the object to serialize.
|
||||
* @param codec codec for serializing.
|
||||
* @return a {@code ByteString} with the message contents.
|
||||
*/
|
||||
public static <T> ByteString toByteString(T object, ProtobufCodec<T> codec) {
|
||||
try (ByteString.Output bout = ByteString.newOutput()) {
|
||||
CodedOutputStream cout = CodedOutputStream.newInstance(bout);
|
||||
cout.useDeterministicSerialization();
|
||||
codec.encode(object, cout);
|
||||
cout.flush();
|
||||
return bout.toByteString();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("exception writing to ByteString", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a byte array to a protobuf message.
|
||||
*
|
||||
|
Reference in New Issue
Block a user