mirror of https://github.com/grpc/grpc-java.git
Rename onPayload to onMessage
This commit is contained in:
parent
8fe667676c
commit
14e774130d
|
|
@ -63,7 +63,7 @@ public abstract class ClientCall<RequestT, ResponseT> {
|
||||||
public abstract static class Listener<T> {
|
public abstract static class Listener<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The response headers have been received. Headers always precede payloads.
|
* The response headers have been received. Headers always precede messages.
|
||||||
* This method is always called, if no headers were received then an empty {@link Metadata}
|
* This method is always called, if no headers were received then an empty {@link Metadata}
|
||||||
* is passed.
|
* is passed.
|
||||||
*
|
*
|
||||||
|
|
@ -75,9 +75,23 @@ public abstract class ClientCall<RequestT, ResponseT> {
|
||||||
* A response payload has been received. May be called zero or more times depending on whether
|
* A response payload has been received. May be called zero or more times depending on whether
|
||||||
* the call response is empty, a single message or a stream of messages.
|
* the call response is empty, a single message or a stream of messages.
|
||||||
*
|
*
|
||||||
* @param payload returned by the server
|
* @param payload returned by the server
|
||||||
|
* @deprecated use {@link #onMessage}
|
||||||
*/
|
*/
|
||||||
public abstract void onPayload(T payload);
|
@Deprecated
|
||||||
|
public void onPayload(T payload) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A response message has been received. May be called zero or more times depending on whether
|
||||||
|
* the call response is empty, a single message or a stream of messages.
|
||||||
|
*
|
||||||
|
* @param message returned by the server
|
||||||
|
*/
|
||||||
|
public void onMessage(T message) {
|
||||||
|
onPayload(message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ClientCall has been closed. Any additional calls to the {@code ClientCall} will not be
|
* The ClientCall has been closed. Any additional calls to the {@code ClientCall} will not be
|
||||||
|
|
@ -113,7 +127,7 @@ public abstract class ClientCall<RequestT, ResponseT> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests up to the given number of messages from the call to be delivered to
|
* Requests up to the given number of messages from the call to be delivered to
|
||||||
* {@link Listener#onPayload(Object)}. No additional messages will be delivered.
|
* {@link Listener#onMessage(Object)}. No additional messages will be delivered.
|
||||||
*
|
*
|
||||||
* <p>Message delivery is guaranteed to be sequential in the order received. In addition, the
|
* <p>Message delivery is guaranteed to be sequential in the order received. In addition, the
|
||||||
* listener methods will not be accessed concurrently. While it is not guaranteed that the same
|
* listener methods will not be accessed concurrently. While it is not guaranteed that the same
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
observer.onPayload(method.parseResponse(message));
|
observer.onMessage(method.parseResponse(message));
|
||||||
} finally {
|
} finally {
|
||||||
message.close();
|
message.close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ public abstract class ForwardingClientCallListener<RespT> extends ClientCall.Lis
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPayload(RespT payload) {
|
public void onMessage(RespT message) {
|
||||||
delegate().onPayload(payload);
|
delegate().onMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -449,8 +449,8 @@ public abstract class AbstractTransportTest {
|
||||||
public void onHeaders(Metadata.Headers headers) {}
|
public void onHeaders(Metadata.Headers headers) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPayload(final StreamingOutputCallResponse payload) {
|
public void onMessage(final StreamingOutputCallResponse message) {
|
||||||
queue.add(payload);
|
queue.add(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -241,14 +241,14 @@ public class ClientCalls {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPayload(RespT payload) {
|
public void onMessage(RespT message) {
|
||||||
if (firstResponseReceived && !streamingResponse) {
|
if (firstResponseReceived && !streamingResponse) {
|
||||||
throw Status.INTERNAL
|
throw Status.INTERNAL
|
||||||
.withDescription("More than one responses received for unary or client-streaming call")
|
.withDescription("More than one responses received for unary or client-streaming call")
|
||||||
.asRuntimeException();
|
.asRuntimeException();
|
||||||
}
|
}
|
||||||
firstResponseReceived = true;
|
firstResponseReceived = true;
|
||||||
observer.onValue(payload);
|
observer.onValue(message);
|
||||||
|
|
||||||
if (streamingResponse) {
|
if (streamingResponse) {
|
||||||
// Request delivery of the next inbound message.
|
// Request delivery of the next inbound message.
|
||||||
|
|
@ -282,7 +282,7 @@ public class ClientCalls {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPayload(RespT value) {
|
public void onMessage(RespT value) {
|
||||||
if (this.value != null) {
|
if (this.value != null) {
|
||||||
throw Status.INTERNAL.withDescription("More than one value received for unary call")
|
throw Status.INTERNAL.withDescription("More than one value received for unary call")
|
||||||
.asRuntimeException();
|
.asRuntimeException();
|
||||||
|
|
@ -397,7 +397,7 @@ public class ClientCalls {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPayload(T value) {
|
public void onMessage(T value) {
|
||||||
Preconditions.checkState(!done, "ClientCall already closed");
|
Preconditions.checkState(!done, "ClientCall already closed");
|
||||||
buffer.add(value);
|
buffer.add(value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class ClientCallsTest {
|
||||||
ClientCall.Listener<String> listener = listenerCaptor.getValue();
|
ClientCall.Listener<String> listener = listenerCaptor.getValue();
|
||||||
verify(call).sendPayload(req);
|
verify(call).sendPayload(req);
|
||||||
verify(call).halfClose();
|
verify(call).halfClose();
|
||||||
listener.onPayload("bar");
|
listener.onMessage("bar");
|
||||||
listener.onClose(Status.OK, new Metadata.Trailers());
|
listener.onClose(Status.OK, new Metadata.Trailers());
|
||||||
assertEquals("bar", future.get());
|
assertEquals("bar", future.get());
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +102,7 @@ public class ClientCallsTest {
|
||||||
ClientCall.Listener<String> listener = listenerCaptor.getValue();
|
ClientCall.Listener<String> listener = listenerCaptor.getValue();
|
||||||
future.cancel(true);
|
future.cancel(true);
|
||||||
verify(call).cancel();
|
verify(call).cancel();
|
||||||
listener.onPayload("bar");
|
listener.onMessage("bar");
|
||||||
listener.onClose(Status.OK, new Metadata.Trailers());
|
listener.onClose(Status.OK, new Metadata.Trailers());
|
||||||
try {
|
try {
|
||||||
future.get();
|
future.get();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue