Skip to content

Commit

Permalink
Avoid NPE on building message with protobuff
Browse files Browse the repository at this point in the history
 - 'explanation' argument in builder should not be null.
  • Loading branch information
zkejid committed Jul 24, 2017
1 parent 4591e1d commit d9f0aa8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Expand Up @@ -475,8 +475,10 @@ public void receiveMessage(Protos.TwoWayChannelMessage msg) throws InsufficientM
} catch (VerificationException e) {
log.error("Caught verification exception handling message from server", e);
errorBuilder = Protos.Error.newBuilder()
.setCode(Protos.Error.ErrorCode.BAD_TRANSACTION)
.setExplanation(e.getMessage());
.setCode(Protos.Error.ErrorCode.BAD_TRANSACTION);
if (e.getMessage() != null) {
errorBuilder.setExplanation(e.getMessage());
}
closeReason = CloseReason.REMOTE_SENT_INVALID_MESSAGE;
} catch (IllegalStateException e) {
log.error("Caught illegal state exception handling message from server", e);
Expand Down
Expand Up @@ -526,8 +526,10 @@ private void error(String message, Protos.Error.ErrorCode errorCode, CloseReason
log.error(message);
Protos.Error.Builder errorBuilder;
errorBuilder = Protos.Error.newBuilder()
.setCode(errorCode)
.setExplanation(message);
.setCode(errorCode);
if (message != null) {
errorBuilder.setExplanation(message);
}
conn.sendToClient(Protos.TwoWayChannelMessage.newBuilder()
.setError(errorBuilder)
.setType(Protos.TwoWayChannelMessage.MessageType.ERROR)
Expand Down

0 comments on commit d9f0aa8

Please sign in to comment.