SOLR-11380: use the inNull() method to check for empty UpdateRequest

This commit is contained in:
Noble Paul 2017-10-31 16:33:08 +10:30
parent 706b6c9171
commit cb3ed762fb
2 changed files with 3 additions and 13 deletions

View File

@ -40,12 +40,7 @@ public class BinaryRequestWriter extends RequestWriter {
public ContentWriter getContentWriter(SolrRequest req) {
if (req instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) req;
if (isNull(updateRequest.getDocuments()) &&
isNull(updateRequest.getDeleteByIdMap()) &&
isNull(updateRequest.getDeleteQuery())
&& (updateRequest.getDocIterator() == null)) {
return null;
}
if (isEmpty(updateRequest)) return null;
return new ContentWriter() {
@Override
public void write(OutputStream os) throws IOException {
@ -66,12 +61,7 @@ public class BinaryRequestWriter extends RequestWriter {
public Collection<ContentStream> getContentStreams(SolrRequest req) throws IOException {
if (req instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) req;
if (isNull(updateRequest.getDocuments()) &&
isNull(updateRequest.getDeleteByIdMap()) &&
isNull(updateRequest.getDeleteQuery())
&& (updateRequest.getDocIterator() == null) ) {
return null;
}
if (isEmpty(updateRequest) ) return null;
throw new RuntimeException("This Should not happen");
} else {
return super.getContentStreams(req);

View File

@ -73,7 +73,7 @@ public class RequestWriter {
return req.getContentStreams();
}
private boolean isEmpty(UpdateRequest updateRequest) {
protected boolean isEmpty(UpdateRequest updateRequest) {
return isNull(updateRequest.getDocuments()) &&
isNull(updateRequest.getDeleteByIdMap()) &&
isNull(updateRequest.getDeleteQuery()) &&