Skip to content

Commit d3faaa4

Browse files
committed
Revert "add cause message to ContractRuntimeException message"
This reverts commit 16f6a6f. The ContractRuntimeException intentionally doesn't report any details back to the client for security reasons. Signed-off-by: James Taylor <[email protected]>
1 parent 66e9d81 commit d3faaa4

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/execution/impl/ContractExecutionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public Chaincode.Response executeRequest(final TxFunction txFn, final Invocation
7676
if (cause instanceof ChaincodeException) {
7777
response = ResponseUtils.newErrorResponse(cause);
7878
} else {
79-
throw new ContractRuntimeException(String.format("Error during contract method execution: %s", cause.getMessage()), cause);
79+
throw new ContractRuntimeException("Error during contract method execution", cause);
8080
}
8181
}
8282

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/ChaincodeInvocationTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ protected ByteString invoke(final ChaincodeMessage message) {
217217
logger.fine(() -> String.format("[%-8.8s] Successful response received.", txId));
218218
return response.getPayload();
219219
case ERROR:
220-
logger.severe(() -> String.format("[%-8.8s] Unsuccessful response received: %s.", txId, response.getPayload().toStringUtf8()));
221-
throw new RuntimeException(String.format("[%-8.8s]Unsuccessful response received: %s.", txId, response.getPayload().toStringUtf8()));
220+
logger.severe(() -> String.format("[%-8.8s] Unsuccessful response received.", txId));
221+
throw new RuntimeException(String.format("[%-8.8s]Unsuccessful response received.", txId));
222222
default:
223223
logger.severe(() -> String.format("[%-8.8s] Unexpected %s response received. Expected %s or %s.", txId,
224224
response.getType(), RESPONSE, ERROR));

fabric-chaincode-shim/src/test/java/org/hyperledger/fabric/contract/ContractRouterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public void testInvokeTxnThatThrowsAnException() {
346346
final Chaincode.Response response = r.invoke(s);
347347
assertThat(response, is(notNullValue()));
348348
assertThat(response.getStatus(), is(Chaincode.Response.Status.INTERNAL_SERVER_ERROR));
349-
assertThat(response.getMessage(), is(equalTo("Error during contract method execution: T3 fail!")));
349+
assertThat(response.getMessage(), is(equalTo("Error during contract method execution")));
350350
assertThat(response.getStringPayload(), is(nullValue()));
351351
assertThat(SampleContract.getBeforeInvoked(), is(1));
352352
assertThat(SampleContract.getAfterInvoked(), is(0));

0 commit comments

Comments
 (0)