when setting null value ttl, reset it

This commit is contained in:
Shay Banon 2011-09-13 21:43:56 +03:00
parent e52dbf4fda
commit a8fc0cbcf3
1 changed files with 6 additions and 2 deletions

View File

@ -288,15 +288,19 @@ public class IndexRequest extends ShardReplicationOperationRequest {
return this.timestamp;
}
// Sets the relative ttl value. It musts be > 0 as it makes little sense otherwise.
/**
* Sets the relative ttl value. It musts be > 0 as it makes little sense otherwise. Setting it
* to <tt>null</tt> will reset to have no ttl.
*/
public IndexRequest ttl(Long ttl) throws ElasticSearchGenerationException {
if (ttl == null) {
this.ttl = -1;
return this;
}
if (ttl <= 0) {
throw new ElasticSearchIllegalArgumentException("TTL value must be > 0. Illegal value provided [" + ttl + "]");
}
this.ttl = ttl;
this.ttl = ttl;
return this;
}