Skip to content

Commit 53e52c2

Browse files
author
Brian Roach
committed
Merge pull request basho#503 from basho/gh502-update-value-future
Gh502 update value future
2 parents 419028a + 9d329ea commit 53e52c2

2 files changed

Lines changed: 26 additions & 44 deletions

File tree

dependency-reduced-pom.xml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -249,45 +249,6 @@
249249
</plugins>
250250
</build>
251251
</profile>
252-
<profile>
253-
<id>shaded_pb</id>
254-
<build>
255-
<plugins>
256-
<plugin>
257-
<artifactId>maven-shade-plugin</artifactId>
258-
<version>2.1</version>
259-
<executions>
260-
<execution>
261-
<phase>package</phase>
262-
<goals>
263-
<goal>shade</goal>
264-
</goals>
265-
<configuration>
266-
<shadedArtifactAttached>true</shadedArtifactAttached>
267-
<createDependencyReducedPom>true</createDependencyReducedPom>
268-
<artifactSet>
269-
<includes>
270-
<include>com.google.protobuf:protobuf-java</include>
271-
<include>com.basho.riak.protobuf:riak-pb</include>
272-
</includes>
273-
</artifactSet>
274-
<relocations>
275-
<relocation>
276-
<pattern>com.google.protobuf</pattern>
277-
<shadedPattern>shaded.com.google.protobuf</shadedPattern>
278-
</relocation>
279-
<relocation>
280-
<pattern>com.basho.riak.protobuf</pattern>
281-
<shadedPattern>shaded.com.bash.riak.protobuf</shadedPattern>
282-
</relocation>
283-
</relocations>
284-
</configuration>
285-
</execution>
286-
</executions>
287-
</plugin>
288-
</plugins>
289-
</build>
290-
</profile>
291252
</profiles>
292253
<dependencies>
293254
<dependency>

src/main/java/com/basho/riak/client/api/commands/kv/UpdateValue.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.concurrent.CountDownLatch;
3636
import java.util.concurrent.ExecutionException;
3737
import java.util.concurrent.TimeUnit;
38+
import java.util.concurrent.TimeoutException;
3839

3940
/**
4041
* Perform an full cycle update of a Riak value: fetch, resolve, modify, store.
@@ -468,17 +469,37 @@ public boolean cancel(boolean mayInterruptIfRunning)
468469
}
469470

470471
@Override
471-
public Response get() throws InterruptedException
472+
public Response get() throws InterruptedException, ExecutionException
472473
{
473474
latch.await();
474-
return updateResponse;
475+
476+
if (exception != null)
477+
{
478+
throw new ExecutionException(exception);
479+
}
480+
else
481+
{
482+
return updateResponse;
483+
}
475484
}
476485

477486
@Override
478-
public Response get(long timeout, TimeUnit unit) throws InterruptedException
487+
public Response get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
479488
{
480-
latch.await(timeout, unit);
481-
return updateResponse;
489+
boolean succeed = latch.await(timeout, unit);
490+
491+
if (!succeed)
492+
{
493+
throw new TimeoutException();
494+
}
495+
else if (exception != null)
496+
{
497+
throw new ExecutionException(exception);
498+
}
499+
else
500+
{
501+
return updateResponse;
502+
}
482503
}
483504

484505
@Override

0 commit comments

Comments
 (0)