9797import io .grpc .ManagedChannelBuilder ;
9898import io .grpc .MethodDescriptor ;
9999import io .grpc .Status ;
100+ import io .grpc .StatusRuntimeException ;
100101import io .grpc .protobuf .ProtoUtils ;
101102import io .opentelemetry .api .OpenTelemetry ;
102103import java .io .Closeable ;
@@ -1214,21 +1215,15 @@ public Response parse(InputStream stream) {
12141215 cis .setSizeLimit (Integer .MAX_VALUE );
12151216 }
12161217 } catch (IOException e ) {
1217- throw Status .INTERNAL
1218- .withDescription ("Error parsing input stream for ReadObject" )
1219- .withCause (e )
1220- .asRuntimeException ();
1218+ throw createStatusRuntimeException (e );
12211219 }
12221220 if (cis != null ) {
12231221 // fast path (no memory copy)
12241222 Response message ;
12251223 try {
12261224 message = parseFrom (cis );
12271225 } catch (InvalidProtocolBufferException ipbe ) {
1228- throw Status .INTERNAL
1229- .withDescription ("Invalid protobuf byte sequence for ReadObject" )
1230- .withCause (ipbe )
1231- .asRuntimeException ();
1226+ throw createStatusRuntimeException (ipbe );
12321227 }
12331228 unclosedStreams .put (message , stream );
12341229 return message ;
@@ -1238,6 +1233,18 @@ public Response parse(InputStream stream) {
12381233 }
12391234 }
12401235
1236+ private StatusRuntimeException createStatusRuntimeException (IOException e ) {
1237+ String description = "" ;
1238+ Response messagePrototype = baseMarshaller .getMessagePrototype ();
1239+ if (messagePrototype != null ) {
1240+ description = "for " + messagePrototype .getClass ().getSimpleName ();
1241+ }
1242+ return Status .INTERNAL
1243+ .withDescription ("Error parsing input stream" + description )
1244+ .withCause (e )
1245+ .asRuntimeException ();
1246+ }
1247+
12411248 private Response parseFrom (CodedInputStream stream ) throws InvalidProtocolBufferException {
12421249 Response message = parser .parseFrom (stream );
12431250 try {
0 commit comments