protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 package com.google.protobuf;
32 
33 import java.io.IOException;
34 
41 public class InvalidProtocolBufferException extends IOException {
42  private static final long serialVersionUID = -1616151763072450476L;
43  private MessageLite unfinishedMessage = null;
44  private boolean wasThrownFromInputStream;
45 
47  super(description);
48  }
49 
50  public InvalidProtocolBufferException(IOException e) {
51  super(e.getMessage(), e);
52  }
53 
54  public InvalidProtocolBufferException(final String description, IOException e) {
55  super(description, e);
56  }
57 
65  this.unfinishedMessage = unfinishedMessage;
66  return this;
67  }
68 
73  return unfinishedMessage;
74  }
75 
77  void setThrownFromInputStream() {
78  /* This write can be racy if the same exception is stored and then thrown by multiple custom
79  * InputStreams on different threads. But since it only ever moves from false->true, there's no
80  * problem. A thread checking this condition after catching this exception from a delegate
81  * stream of CodedInputStream is guaranteed to always observe true, because a write on the same
82  * thread set the value when the exception left the delegate. A thread checking the same
83  * condition with an exception created by CodedInputStream is guaranteed to always see false,
84  * because the exception has not been exposed to any code that could publish it to other threads
85  * and cause a write.
86  */
88  }
89 
94  boolean getThrownFromInputStream() {
96  }
97 
102  public IOException unwrapIOException() {
103  return getCause() instanceof IOException ? (IOException) getCause() : this;
104  }
105 
106  static InvalidProtocolBufferException truncatedMessage() {
108  "While parsing a protocol message, the input ended unexpectedly "
109  + "in the middle of a field. This could mean either that the "
110  + "input has been truncated or that an embedded message "
111  + "misreported its own length.");
112  }
113 
114  static InvalidProtocolBufferException negativeSize() {
116  "CodedInputStream encountered an embedded string or message "
117  + "which claimed to have negative size.");
118  }
119 
120  static InvalidProtocolBufferException malformedVarint() {
121  return new InvalidProtocolBufferException("CodedInputStream encountered a malformed varint.");
122  }
123 
124  static InvalidProtocolBufferException invalidTag() {
125  return new InvalidProtocolBufferException("Protocol message contained an invalid tag (zero).");
126  }
127 
128  static InvalidProtocolBufferException invalidEndTag() {
130  "Protocol message end-group tag did not match expected tag.");
131  }
132 
133  static InvalidWireTypeException invalidWireType() {
134  return new InvalidWireTypeException("Protocol message tag had invalid wire type.");
135  }
136 
138  @ExperimentalApi
139  public static class InvalidWireTypeException extends InvalidProtocolBufferException {
140  private static final long serialVersionUID = 3283890091615336259L;
141 
143  super(description);
144  }
145  }
146 
147  static InvalidProtocolBufferException recursionLimitExceeded() {
149  "Protocol message had too many levels of nesting. May be malicious. "
150  + "Use CodedInputStream.setRecursionLimit() to increase the depth limit.");
151  }
152 
153  static InvalidProtocolBufferException sizeLimitExceeded() {
155  "Protocol message was too large. May be malicious. "
156  + "Use CodedInputStream.setSizeLimit() to increase the size limit.");
157  }
158 
159  static InvalidProtocolBufferException parseFailure() {
160  return new InvalidProtocolBufferException("Failed to parse the message.");
161  }
162 
163  static InvalidProtocolBufferException invalidUtf8() {
164  return new InvalidProtocolBufferException("Protocol message had invalid UTF-8.");
165  }
166 }
com.google.protobuf.InvalidProtocolBufferException.getUnfinishedMessage
MessageLite getUnfinishedMessage()
Definition: protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:72
com.google.protobuf.InvalidProtocolBufferException.wasThrownFromInputStream
boolean wasThrownFromInputStream
Definition: protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:44
com.google.protobuf.InvalidProtocolBufferException.unfinishedMessage
MessageLite unfinishedMessage
Definition: bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:43
setup.description
description
Definition: setup.py:544
com.google.protobuf.InvalidProtocolBufferException.unwrapIOException
IOException unwrapIOException()
Definition: protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:102
grpc::protobuf::MessageLite
GRPC_CUSTOM_MESSAGELITE MessageLite
Definition: include/grpcpp/impl/codegen/config_protobuf.h:79
com.google.protobuf.InvalidProtocolBufferException.InvalidWireTypeException.serialVersionUID
static final long serialVersionUID
Definition: bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:117
com.google.protobuf.InvalidProtocolBufferException.InvalidWireTypeException.InvalidWireTypeException
InvalidWireTypeException(String description)
Definition: protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:142
com.google.protobuf.InvalidProtocolBufferException.InvalidProtocolBufferException
InvalidProtocolBufferException(final String description, IOException e)
Definition: protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:54
java
com.google.protobuf.InvalidProtocolBufferException.serialVersionUID
static final long serialVersionUID
Definition: bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:42
com.google.protobuf.InvalidProtocolBufferException.InvalidProtocolBufferException
InvalidProtocolBufferException(final String description)
Definition: protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:46
L
lua_State * L
Definition: upb/upb/bindings/lua/main.c:35
com.google.protobuf.InvalidProtocolBufferException.setUnfinishedMessage
InvalidProtocolBufferException setUnfinishedMessage(MessageLite unfinishedMessage)
Definition: protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:64
com.google.protobuf.InvalidProtocolBufferException
Definition: bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:41
com.google.protobuf.InvalidProtocolBufferException.InvalidProtocolBufferException
InvalidProtocolBufferException(IOException e)
Definition: protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java:50
com.google.protobuf.MessageLite
Definition: bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/MessageLite.java:65


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:07