Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ public NestedIdentity getNestedIdentity() {
*/
@Override
public BytesReference sourceRef() {
if (this.source == null) {
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add the curly brackets around this statement? we tend to use them although not needed around a single, for better readability.

}

try {
this.source = CompressorFactory.uncompressIfNeeded(this.source);
return this.source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,15 @@ public void testSerializeShardTarget() throws Exception {
assertThat(results.getAt(1).shard(), equalTo(target));
}

public void testNullSource() throws Exception {
InternalSearchHit searchHit = new InternalSearchHit(0, "_id", new Text("_type"), null);

assertThat(searchHit.source(), nullValue());
assertThat(searchHit.sourceRef(), nullValue());
assertThat(searchHit.sourceAsMap(), nullValue());
assertThat(searchHit.sourceAsString(), nullValue());
assertThat(searchHit.getSource(), nullValue());
assertThat(searchHit.getSourceRef(), nullValue());
assertThat(searchHit.getSourceAsString(), nullValue());
}
}