Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
Copy tags from additional query options (#276)
Browse files Browse the repository at this point in the history
Signed-off-by: Alban Dericbourg <[email protected]>
  • Loading branch information
adericbourg authored and rickfast committed Nov 30, 2017
1 parent 41d49b3 commit d04ad93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/orbitz/consul/cache/ConsulCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,16 @@ protected static QueryOptions watchParams(final BigInteger index, final int bloc
checkArgument(!queryOptions.getIndex().isPresent() && !queryOptions.getWait().isPresent(),
"Index and wait cannot be overridden");

return ImmutableQueryOptions.builder()
ImmutableQueryOptions.Builder builder = ImmutableQueryOptions.builder()
.from(watchDefaultParams(index, blockSeconds))
.token(queryOptions.getToken())
.consistencyMode(queryOptions.getConsistencyMode())
.near(queryOptions.getNear())
.datacenter(queryOptions.getDatacenter())
.build();
.datacenter(queryOptions.getDatacenter());
for (String tag : queryOptions.getTag()) {
builder.addTag(tag);
}
return builder.build();
}

private static QueryOptions watchDefaultParams(final BigInteger index, final int blockSeconds) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/orbitz/consul/cache/ConsulCacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ public void testWatchParamsWithAdditionalOptions() {
BigInteger index = new BigInteger("12");
QueryOptions additionalOptions = ImmutableQueryOptions.builder()
.consistencyMode(ConsistencyMode.STALE)
.addTag("someTag")
.token("186596")
.near("156892")
.build();
Expand All @@ -394,6 +395,7 @@ public void testWatchParamsWithAdditionalOptions() {
.index(index)
.wait("10s")
.consistencyMode(ConsistencyMode.STALE)
.addTag("someTag")
.token("186596")
.near("156892")
.build();
Expand Down

0 comments on commit d04ad93

Please sign in to comment.