public I deserializeRequest(ByteBufOrStream message) throws IOException { InputStream messageStream = message.stream(); if (message.buf() != null) { try { switch (requestType) { case PROTOBUF: final PrototypeMarshaller<I> marshaller = (PrototypeMarshaller<I>) method.getRequestMarshaller(); // PrototypeMarshaller<I>.getMessagePrototype will always parse to I @SuppressWarnings("unchecked") final I msg = (I) deserializeProto(message.buf(), (Message) marshaller.getMessagePrototype()); return msg; default: // Fallback to using the method's stream marshaller. messageStream = new ByteBufInputStream(message.buf().retain(), true); break; } } finally { if (!unsafeWrapDeserializedBuffer) { message.buf().release(); } } } try (InputStream msg = messageStream) { return method.parseRequest(msg); } }
@SuppressWarnings("Finally") // The code avoids suppressing the exception thrown from try @Override public void messagesAvailable(final MessageProducer producer) { if (call.cancelled) { GrpcUtil.closeQuietly(producer); return; } InputStream message; try { while ((message = producer.next()) != null) { try { listener.onMessage(call.method.parseRequest(message)); } catch (Throwable t) { GrpcUtil.closeQuietly(message); throw t; } message.close(); } } catch (Throwable t) { GrpcUtil.closeQuietly(producer); MoreThrowables.throwIfUnchecked(t); throw new RuntimeException(t); } }
@SuppressWarnings("Finally") // The code avoids suppressing the exception thrown from try @Override public void messagesAvailable(final MessageProducer producer) { if (call.cancelled) { GrpcUtil.closeQuietly(producer); return; } InputStream message; try { while ((message = producer.next()) != null) { try { listener.onMessage(call.method.parseRequest(message)); } catch (Throwable t) { GrpcUtil.closeQuietly(message); throw t; } message.close(); } } catch (Throwable t) { GrpcUtil.closeQuietly(producer); MoreThrowables.throwIfUnchecked(t); throw new RuntimeException(t); } }
public I deserializeRequest(ByteBufOrStream message) throws IOException { InputStream messageStream = message.stream(); if (message.buf() != null) { try { switch (requestType) { case PROTOBUF: final PrototypeMarshaller<I> marshaller = (PrototypeMarshaller<I>) method.getRequestMarshaller(); // PrototypeMarshaller<I>.getMessagePrototype will always parse to I @SuppressWarnings("unchecked") final I msg = (I) deserializeProto(message.buf(), (Message) marshaller.getMessagePrototype()); return msg; default: // Fallback to using the method's stream marshaller. messageStream = new ByteBufInputStream(message.buf().retain(), true); break; } } finally { if (!unsafeWrapDeserializedBuffer) { message.buf().release(); } } } try (InputStream msg = messageStream) { return method.parseRequest(msg); } }