Remove PROTOTYPE from BulkItemResponse.Failure

Closes #17086
This commit is contained in:
Nik Everett 2016-03-30 21:16:55 -04:00
parent f8a67a2622
commit 30a1862339
2 changed files with 22 additions and 17 deletions

View File

@ -85,8 +85,6 @@ public class BulkItemResponse implements Streamable, StatusToXContent {
static final String CAUSE_FIELD = "cause";
static final String STATUS_FIELD = "status";
public static final Failure PROTOTYPE = new Failure(null, null, null, null);
private final String index;
private final String type;
private final String id;
@ -101,6 +99,26 @@ public class BulkItemResponse implements Streamable, StatusToXContent {
this.status = ExceptionsHelper.status(t);
}
/**
* Read from a stream.
*/
public Failure(StreamInput in) throws IOException {
index = in.readString();
type = in.readString();
id = in.readOptionalString();
cause = in.readThrowable();
status = ExceptionsHelper.status(cause);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(getIndex());
out.writeString(getType());
out.writeOptionalString(getId());
out.writeThrowable(getCause());
}
/**
* The index name of the action.
*/
@ -143,19 +161,6 @@ public class BulkItemResponse implements Streamable, StatusToXContent {
return cause;
}
@Override
public Failure readFrom(StreamInput in) throws IOException {
return new Failure(in.readString(), in.readString(), in.readOptionalString(), in.readThrowable());
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(getIndex());
out.writeString(getType());
out.writeOptionalString(getId());
out.writeThrowable(getCause());
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(INDEX_FIELD, index);
@ -305,7 +310,7 @@ public class BulkItemResponse implements Streamable, StatusToXContent {
}
if (in.readBoolean()) {
failure = Failure.PROTOTYPE.readFrom(in);
failure = new Failure(in);
}
}

View File

@ -136,7 +136,7 @@ public class BulkIndexByScrollResponse extends ActionResponse implements ToXCont
int indexingFailuresCount = in.readVInt();
List<Failure> indexingFailures = new ArrayList<>(indexingFailuresCount);
for (int i = 0; i < indexingFailuresCount; i++) {
indexingFailures.add(Failure.PROTOTYPE.readFrom(in));
indexingFailures.add(new Failure(in));
}
this.indexingFailures = unmodifiableList(indexingFailures);
int searchFailuresCount = in.readVInt();