diff --git a/core/chaincode/shim/java/src/main/java/org/hyperledger/fabric/shim/ChaincodeHelper.java b/core/chaincode/shim/java/src/main/java/org/hyperledger/fabric/shim/ChaincodeHelper.java index d2472dbd132..8fb5476aef5 100644 --- a/core/chaincode/shim/java/src/main/java/org/hyperledger/fabric/shim/ChaincodeHelper.java +++ b/core/chaincode/shim/java/src/main/java/org/hyperledger/fabric/shim/ChaincodeHelper.java @@ -33,7 +33,7 @@ public abstract class ChaincodeHelper { public static final int UNKNOWN_VALUE = 0; - + public static Response newResponse(Status status, String message, byte[] payload) { final Builder builder = Response.newBuilder(); builder.setStatus(status.getNumber()); @@ -45,15 +45,15 @@ public static Response newResponse(Status status, String message, byte[] payload } return builder.build(); } - + public static Response newSuccessResponse(String message, byte[] payload) { return newResponse(SUCCESS, message, payload); } - + public static Response newSuccessResponse() { return newSuccessResponse(null, null); } - + public static Response newSuccessResponse(String message) { return newSuccessResponse(message, null); } @@ -65,11 +65,11 @@ public static Response newSuccessResponse(byte[] payload) { public static Response newBadRequestResponse(String message, byte[] payload) { return newResponse(BAD_REQUEST, message, payload); } - + public static Response newBadRequestResponse() { return newBadRequestResponse(null, null); } - + public static Response newBadRequestResponse(String message) { return newBadRequestResponse(message, null); } @@ -85,11 +85,11 @@ public static Response newForbiddenResponse(byte[] payload) { public static Response newForbiddenResponse(String message, byte[] payload) { return newResponse(FORBIDDEN, message, payload); } - + public static Response newForbiddenResponse() { return newForbiddenResponse(null, null); } - + public static Response newForbiddenResponse(String message) { return newForbiddenResponse(message, null); } @@ -97,11 +97,11 @@ public static Response newForbiddenResponse(String message) { public static Response newNotFoundResponse(String message, byte[] payload) { return newResponse(NOT_FOUND, message, payload); } - + public static Response newNotFoundResponse() { return newNotFoundResponse(null, null); } - + public static Response newNotFoundResponse(String message) { return newNotFoundResponse(message, null); } @@ -109,15 +109,15 @@ public static Response newNotFoundResponse(String message) { public static Response newNotFoundResponse(byte[] payload) { return newNotFoundResponse(null, payload); } - + public static Response newRequestEntityTooLargeResponse(String message, byte[] payload) { return newResponse(REQUEST_ENTITY_TOO_LARGE, message, payload); } - + public static Response newRequestEntityTooLargeResponse() { return newRequestEntityTooLargeResponse(null, null); } - + public static Response newRequestEntityTooLargeResponse(String message) { return newRequestEntityTooLargeResponse(message, null); } @@ -125,15 +125,15 @@ public static Response newRequestEntityTooLargeResponse(String message) { public static Response newRequestEntityTooLargeResponse(byte[] payload) { return newRequestEntityTooLargeResponse(null, payload); } - + public static Response newInternalServerErrorResponse(String message, byte[] payload) { return newResponse(INTERNAL_SERVER_ERROR, message, payload); } - + public static Response newInternalServerErrorResponse() { return newInternalServerErrorResponse(null, null); } - + public static Response newInternalServerErrorResponse(String message) { return newInternalServerErrorResponse(message, null); } @@ -141,19 +141,19 @@ public static Response newInternalServerErrorResponse(String message) { public static Response newInternalServerErrorResponse(byte[] payload) { return newInternalServerErrorResponse(null, payload); } - + public static Response newInternalServerErrorResponse(Throwable throwable) { return newInternalServerErrorResponse(throwable.getMessage(), printStackTrace(throwable)); } - + public static Response newServiceUnavailableErrorResponse(String message, byte[] payload) { return newResponse(SERVICE_UNAVAILABLE, message, payload); } - + public static Response newServiceUnavailableErrorResponse() { return newServiceUnavailableErrorResponse(null, null); } - + public static Response newServiceUnavailableErrorResponse(String message) { return newServiceUnavailableErrorResponse(message, null); } @@ -168,5 +168,5 @@ static byte[] printStackTrace(Throwable throwable) { throwable.printStackTrace(new PrintWriter(buffer)); return buffer.toString().getBytes(StandardCharsets.UTF_8); } - + } diff --git a/core/chaincode/shim/java/src/main/java/org/hyperledger/fabric/shim/HandlerHelper.java b/core/chaincode/shim/java/src/main/java/org/hyperledger/fabric/shim/HandlerHelper.java index 99bf7cd8c06..deb75d7aa94 100644 --- a/core/chaincode/shim/java/src/main/java/org/hyperledger/fabric/shim/HandlerHelper.java +++ b/core/chaincode/shim/java/src/main/java/org/hyperledger/fabric/shim/HandlerHelper.java @@ -32,15 +32,15 @@ private static ChaincodeMessage newEventMessage(final Type type, final String tx .setPayload(payload) .build(); } - + static ChaincodeMessage newGetStateEventMessage(final String txid, final String key) { return newEventMessage(GET_STATE, txid, ByteString.copyFromUtf8(key)); } - + static ChaincodeMessage newErrorEventMessage(final String txid, final Response payload) { return newEventMessage(ERROR, txid, payload.toByteString()); } - + static ChaincodeMessage newErrorEventMessage(final String txid, final Throwable throwable) { return newErrorEventMessage(txid, ChaincodeHelper.newInternalServerErrorResponse(throwable)); } diff --git a/core/comm/testdata/grpc/test.proto b/core/comm/testdata/grpc/test.proto index bb61f89ba22..ba733bc63d0 100644 --- a/core/comm/testdata/grpc/test.proto +++ b/core/comm/testdata/grpc/test.proto @@ -21,7 +21,7 @@ option go_package = "github.com/hyperledger/fabric/core/comm/testdata/grpc"; message Empty {} service TestService { - + rpc EmptyCall(Empty) returns (Empty); }