|
@@ -4,23 +4,16 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
|
|
import com.google.protobuf.Message;
|
|
|
import com.google.protobuf.MessageOrBuilder;
|
|
|
import com.google.protobuf.util.JsonFormat;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
* @author dyp
|
|
|
*/
|
|
|
-@Slf4j
|
|
|
public class ProtobufUtils {
|
|
|
- public static String toJson(MessageOrBuilder message) {
|
|
|
+ public static String toJson(MessageOrBuilder message) throws InvalidProtocolBufferException {
|
|
|
if (message == null) {
|
|
|
return "";
|
|
|
}
|
|
|
- try {
|
|
|
- return JsonFormat.printer().includingDefaultValueFields().print(message);
|
|
|
- } catch (InvalidProtocolBufferException e) {
|
|
|
- log.error("ProtobufUtils toJson error", e);
|
|
|
- }
|
|
|
- return "";
|
|
|
+ return JsonFormat.printer().includingDefaultValueFields().print(message);
|
|
|
}
|
|
|
|
|
|
public static void fromJson(String json, Message.Builder builder) throws InvalidProtocolBufferException {
|