Prettify primary response in assertion message

We are getting the default Object#toString implementation here, we need
more than this. This commit instead formats the primary response to JSON
so we can see into its soul.
This commit is contained in:
Jason Tedor 2017-09-01 19:25:06 -04:00
parent 9735e7d706
commit 1757bd8d92
1 changed files with 2 additions and 1 deletions

View File

@ -20,6 +20,7 @@
package org.elasticsearch.action.bulk; package org.elasticsearch.action.bulk;
import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.DocWriteRequest;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.io.stream.Streamable;
@ -78,7 +79,7 @@ public class BulkItemRequest implements Streamable {
setPrimaryResponse(new BulkItemResponse(id, request.opType(), failure)); setPrimaryResponse(new BulkItemResponse(id, request.opType(), failure));
} else { } else {
assert primaryResponse.isFailed() && primaryResponse.getFailure().isAborted() assert primaryResponse.isFailed() && primaryResponse.getFailure().isAborted()
: "response [" + primaryResponse + "]; cause [" + cause + "]"; : "response [" + Strings.toString(primaryResponse) + "]; cause [" + cause + "]";
if (primaryResponse.isFailed() && primaryResponse.getFailure().isAborted()) { if (primaryResponse.isFailed() && primaryResponse.getFailure().isAborted()) {
primaryResponse.getFailure().getCause().addSuppressed(cause); primaryResponse.getFailure().getCause().addSuppressed(cause);
} else { } else {