com.google.protobuf.InvalidProtocolBufferException类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(2275)

本文整理了Java中com.google.protobuf.InvalidProtocolBufferException类的一些代码示例,展示了InvalidProtocolBufferException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InvalidProtocolBufferException类的具体详情如下:
包路径:com.google.protobuf.InvalidProtocolBufferException
类名称:InvalidProtocolBufferException

InvalidProtocolBufferException介绍

[英]Thrown when a protocol message being parsed is invalid in some way, e.g. it contains a malformed varint or a negative byte length.
[中]当正在分析的协议消息以某种方式无效时引发,例如,它包含格式错误的变量或负字节长度。

代码示例

代码示例来源:origin: osmandapp/Osmand

static InvalidProtocolBufferException negativeSize() {
 return new InvalidProtocolBufferException(
  "CodedInputStream encountered an embedded string or message " +
  "which claimed to have negative size.");
}

代码示例来源:origin: apache/incubator-shardingsphere

public Builder mergeFrom(
  com.google.protobuf.CodedInputStream input,
  com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  throws java.io.IOException {
 authpb.Auth.Permission parsedMessage = null;
 try {
  parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
 } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  parsedMessage = (authpb.Auth.Permission) e.getUnfinishedMessage();
  throw e.unwrapIOException();
 } finally {
  if (parsedMessage != null) {
   mergeFrom(parsedMessage);
  }
 }
 return this;
}

代码示例来源:origin: apache/incubator-shardingsphere

name_ = input.readBytes();
    break;
    password_ = input.readBytes();
    break;
    java.lang.String s = input.readStringRequireUtf8();
    if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
     roles_ = new com.google.protobuf.LazyStringArrayList();
     mutable_bitField0_ |= 0x00000004;
    roles_.add(s);
    break;
 throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
 throw new com.google.protobuf.InvalidProtocolBufferException(
   e).setUnfinishedMessage(this);
} finally {
 if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
  roles_ = roles_.getUnmodifiableView();
 this.unknownFields = unknownFields.build();
 makeExtensionsImmutable();

代码示例来源:origin: alibaba/canal

com.google.protobuf.UnknownFieldSet.newBuilder();
try {
 boolean done = false;
 while (!done) {
  int tag = input.readTag();
  switch (tag) {
   case 0:
   case 8: {
    sendTimestamp_ = input.readInt64();
    break;
    startTimestamp_ = input.readInt64();
    break;
 throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
 throw new com.google.protobuf.InvalidProtocolBufferException(
   e).setUnfinishedMessage(this);
} finally {
 this.unknownFields = unknownFields.build();
 makeExtensionsImmutable();

代码示例来源:origin: apache/hbase

mutable_bitField0_ |= 0x00000001;
    liveNodes_.add(input.readMessage(org.apache.hadoop.hbase.rest.protobuf.generated.StorageClusterStatusMessage.StorageClusterStatus.Node.PARSER, extensionRegistry));
    break;
     deadNodes_ = new com.google.protobuf.LazyStringArrayList();
     mutable_bitField0_ |= 0x00000002;
    deadNodes_.add(input.readBytes());
    break;
 throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
 throw new com.google.protobuf.InvalidProtocolBufferException(
   e.getMessage()).setUnfinishedMessage(this);
} finally {
 if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
  deadNodes_ = new com.google.protobuf.UnmodifiableLazyStringList(deadNodes_);
 this.unknownFields = unknownFields.build();
 makeExtensionsImmutable();

代码示例来源:origin: alibaba/canal

public Builder mergeFrom(
  com.google.protobuf.CodedInputStream input,
  com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  throws java.io.IOException {
 Header parsedMessage = null;
 try {
  parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
 } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  parsedMessage = (Header) e.getUnfinishedMessage();
  throw e;
 } finally {
  if (parsedMessage != null) {
   mergeFrom(parsedMessage);
  }
 }
 return this;
}
private int bitField0_;

代码示例来源:origin: osmandapp/Osmand

public UnknownFieldSet parsePartialFrom(
   CodedInputStream input, ExtensionRegistryLite extensionRegistry)
   throws InvalidProtocolBufferException {
  Builder builder = newBuilder();
  try {
   builder.mergeFrom(input);
  } catch (InvalidProtocolBufferException e) {
   throw e.setUnfinishedMessage(builder.buildPartial());
  } catch (IOException e) {
   throw new InvalidProtocolBufferException(e.getMessage())
     .setUnfinishedMessage(builder.buildPartial());
  }
  return builder.buildPartial();
 }
}

代码示例来源:origin: osmandapp/Osmand

public MessageType parsePartialFrom(InputStream input,
                  ExtensionRegistryLite extensionRegistry)
  throws InvalidProtocolBufferException {
 CodedInputStream codedInput = CodedInputStream.newInstance(input);
 MessageType message = parsePartialFrom(codedInput, extensionRegistry);
 try {
  codedInput.checkLastTagWas(0);
 } catch (InvalidProtocolBufferException e) {
  throw e.setUnfinishedMessage(message);
 }
 return message;
}

代码示例来源:origin: osmandapp/Osmand

public MessageType parsePartialDelimitedFrom(
  InputStream input,
  ExtensionRegistryLite extensionRegistry)
  throws InvalidProtocolBufferException {
 int size;
 try {
  int firstByte = input.read();
  if (firstByte == -1) {
   return null;
  }
  size = CodedInputStream.readRawVarint32(firstByte, input);
 } catch (IOException e) {
  throw new InvalidProtocolBufferException(e.getMessage());
 }
 InputStream limitedInput = new LimitedInputStream(input, size);
 return parsePartialFrom(limitedInput, extensionRegistry);
}

代码示例来源:origin: com.google.protobuf/protobuf-java

private static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
  T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry)
  throws InvalidProtocolBufferException {
 T message;
 try {
  CodedInputStream input = data.newCodedInput();
  message = parsePartialFrom(defaultInstance, input, extensionRegistry);
  try {
   input.checkLastTagWas(0);
  } catch (InvalidProtocolBufferException e) {
   throw e.setUnfinishedMessage(message);
  }
  return message;
 } catch (InvalidProtocolBufferException e) {
  throw e;
 }
}

代码示例来源:origin: osmandapp/Osmand

/**
 * Helper method to check if message is initialized.
 *
 * @throws InvalidProtocolBufferException if it is not initialized.
 * @return The message to check.
 */
private MessageType checkMessageInitialized(MessageType message)
  throws InvalidProtocolBufferException {
 if (message != null && !message.isInitialized()) {
  throw newUninitializedMessageException(message)
    .asInvalidProtocolBufferException()
    .setUnfinishedMessage(message);
 }
 return message;
}

代码示例来源:origin: Alluxio/alluxio

com.google.protobuf.UnknownFieldSet.newBuilder();
try {
 boolean done = false;
 while (!done) {
  int tag = input.readTag();
  switch (tag) {
   case 0:
    com.google.protobuf.ByteString bs = input.readBytes();
    if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
     persistedFileFingerprints_ = new com.google.protobuf.LazyStringArrayList();
     mutable_bitField0_ |= 0x00000001;
    persistedFileFingerprints_.add(bs);
    break;
 throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
 throw new com.google.protobuf.InvalidProtocolBufferException(
   e).setUnfinishedMessage(this);
} finally {
 if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
  persistedFileFingerprints_ = persistedFileFingerprints_.getUnmodifiableView();
 this.unknownFields = unknownFields.build();
 makeExtensionsImmutable();

代码示例来源:origin: alibaba/canal

com.google.protobuf.UnknownFieldSet.newBuilder();
try {
 boolean done = false;
 while (!done) {
  int tag = input.readTag();
  switch (tag) {
   case 0:
   case 8: {
    errorCodePresentCase_ = 1;
    errorCodePresent_ = input.readInt32();
    break;
    java.lang.String s = input.readStringRequireUtf8();
 throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
 throw new com.google.protobuf.InvalidProtocolBufferException(
   e).setUnfinishedMessage(this);
} finally {
 this.unknownFields = unknownFields.build();
 makeExtensionsImmutable();

代码示例来源:origin: alibaba/canal

public Builder mergeFrom(
  com.google.protobuf.CodedInputStream input,
  com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  throws java.io.IOException {
 Entry parsedMessage = null;
 try {
  parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
 } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  parsedMessage = (Entry) e.getUnfinishedMessage();
  throw e;
 } finally {
  if (parsedMessage != null) {
   mergeFrom(parsedMessage);
  }
 }
 return this;
}
private int bitField0_;

代码示例来源:origin: com.google.protobuf/protobuf-java

@Override
 public UnknownFieldSet parsePartialFrom(
   CodedInputStream input, ExtensionRegistryLite extensionRegistry)
   throws InvalidProtocolBufferException {
  Builder builder = newBuilder();
  try {
   builder.mergeFrom(input);
  } catch (InvalidProtocolBufferException e) {
   throw e.setUnfinishedMessage(builder.buildPartial());
  } catch (IOException e) {
   throw new InvalidProtocolBufferException(e)
     .setUnfinishedMessage(builder.buildPartial());
  }
  return builder.buildPartial();
 }
}

代码示例来源:origin: com.google.protobuf/protobuf-java

@Override
public MessageType parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
  throws InvalidProtocolBufferException {
 CodedInputStream codedInput = CodedInputStream.newInstance(input);
 MessageType message = parsePartialFrom(codedInput, extensionRegistry);
 try {
  codedInput.checkLastTagWas(0);
 } catch (InvalidProtocolBufferException e) {
  throw e.setUnfinishedMessage(message);
 }
 return message;
}

代码示例来源:origin: Alluxio/alluxio

com.google.protobuf.UnknownFieldSet.newBuilder();
try {
 boolean done = false;
 while (!done) {
  int tag = input.readTag();
  switch (tag) {
   case 0:
    com.google.protobuf.ByteString bs = input.readBytes();
    if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
     inconsistentPaths_ = new com.google.protobuf.LazyStringArrayList();
     mutable_bitField0_ |= 0x00000001;
    inconsistentPaths_.add(bs);
    break;
 throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
 throw new com.google.protobuf.InvalidProtocolBufferException(
   e).setUnfinishedMessage(this);
} finally {
 if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
  inconsistentPaths_ = inconsistentPaths_.getUnmodifiableView();
 this.unknownFields = unknownFields.build();
 makeExtensionsImmutable();

代码示例来源:origin: apache/incubator-shardingsphere

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:
    int rawValue = input.readEnum();
    key_ = input.readBytes();
    break;
 throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
 throw new com.google.protobuf.InvalidProtocolBufferException(
   e).setUnfinishedMessage(this);
} finally {
 this.unknownFields = unknownFields.build();
 makeExtensionsImmutable();

代码示例来源:origin: alibaba/canal

@java.lang.Override
public Builder mergeFrom(
  com.google.protobuf.CodedInputStream input,
  com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  throws java.io.IOException {
 com.alibaba.otter.canal.protocol.CanalPacket.HeartBeat parsedMessage = null;
 try {
  parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
 } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  parsedMessage = (com.alibaba.otter.canal.protocol.CanalPacket.HeartBeat) e.getUnfinishedMessage();
  throw e.unwrapIOException();
 } finally {
  if (parsedMessage != null) {
   mergeFrom(parsedMessage);
  }
 }
 return this;
}

代码示例来源:origin: alibaba/canal

public Builder mergeFrom(
  com.google.protobuf.CodedInputStream input,
  com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  throws java.io.IOException {
 Column parsedMessage = null;
 try {
  parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
 } catch (com.google.protobuf.InvalidProtocolBufferException e) {
  parsedMessage = (Column) e.getUnfinishedMessage();
  throw e;
 } finally {
  if (parsedMessage != null) {
   mergeFrom(parsedMessage);
  }
 }
 return this;
}
private int bitField0_;

相关文章