elasticsearch/elasticsearch — pull request #4932 by dadoonet (2014-01-28 16:59:37+00:00)
Title: Fix potential NPE when no source and no body

In recent changes, we added missing support for `source` parameter in some REST APIs:

* #4892 : mget
* #4900 : mpercolate
* #4901 : msearch
* #4902 : mtermvectors
* #4903 : percolate

```java
BytesReference content = null;
if (request.hasContent()) {
content = request.content();
} else {
String source = request.param("source");
if (source != null) {
content = new BytesArray(source);
}
}
```

It's definitely better to have:

```java
BytesReference content = request.content();
if (!request.hasContent()) {
String source = request.param("source");
if (source != null) {
content = new BytesArray(source);
}
}
```

That said, it could be nice to have a single method to manage it for various REST actions.

Closes #4924.