Skip to content

Commit

Permalink
finagle-memcachedx: reduce compile warnings
Browse files Browse the repository at this point in the history
reduce compile warnings

RB_ID=714976
  • Loading branch information
blackicewei authored and jenkins committed Jul 20, 2015
1 parent ed7e492 commit 72261ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public Future<Long> incr(String key) {
return result.map(new Function<Option<Long>, Long>() {
public Long apply(Option<Long> value) {
if (value.isDefined()) {
return (Long) value.get();
return value.get();
} else {
return -1L;
}
Expand All @@ -161,7 +161,7 @@ public Future<Long> incr(String key, long delta) {
return result.map(new Function<Option<Long>, Long>() {
public Long apply(Option<Long> value) {
if (value.isDefined()) {
return (Long) value.get();
return value.get();
} else {
return -1L;
}
Expand All @@ -174,7 +174,7 @@ public Future<Long> decr(String key) {
return result.map(new Function<Option<Long>, Long>() {
public Long apply(Option<Long> value) {
if (value.isDefined()) {
return (Long) value.get();
return value.get();
} else {
return -1L;
}
Expand All @@ -187,7 +187,7 @@ public Future<Long> decr(String key, long delta) {
return result.map(new Function<Option<Long>, Long>() {
public Long apply(Option<Long> value) {
if (value.isDefined()) {
return (Long) value.get();
return value.get();
} else {
return -1L;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.twitter.finagle.memcachedx.protocol.Response;
import com.twitter.finagle.memcachedx.protocol.text.Memcached;
import com.twitter.io.Buf;
import com.twitter.util.Await;

/**
* This is mainly for internal testing, not for external purpose
Expand All @@ -22,7 +23,7 @@ public final class ClientTest {

private ClientTest() { }

public static void main(String[] args) {
public static void main(String[] args) throws Exception {
Service<Command, Response> service =
ClientBuilder.safeBuild(
ClientBuilder
Expand All @@ -49,17 +50,17 @@ public static void main(String[] args) {

}

public static void testClient(Client client) {
client.delete("foo").get();
client.set("foo", "bar").get();
Option<String> res = Buf.Utf8$.MODULE$.unapply(client.get("foo").get());
public static void testClient(Client client) throws Exception {
Await.result(client.delete("foo"));
Await.result(client.set("foo", "bar"));
Option<String> res = Buf.Utf8$.MODULE$.unapply(Await.result(client.get("foo")));
assert "bar".equals(res.get());
ResultWithCAS casRes = client.gets("foo").get();
assert client.cas("foo", "baz", casRes.casUnique).get();
ResultWithCAS casRes = Await.result(client.gets("foo"));
assert Await.result(client.cas("foo", "baz", casRes.casUnique));

Option<String> res2 = Buf.Utf8$.MODULE$.unapply(client.get("foo").get());
Option<String> res2 = Buf.Utf8$.MODULE$.unapply(Await.result(client.get("foo")));
assert "baz".equals(res2.get());
client.delete("foo").get();
Await.result(client.delete("foo"));
System.err.println("passed.");
client.release();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ trait Client extends BaseClient[Buf] {
def withBytes: BaseClient[Array[Byte]] = adapt(
new Bijection[Buf, Array[Byte]] {
def apply(a: Buf): Array[Byte] = a.toArray
def invert(b: Array[Byte]): Buf = Buf.ByteArray(b)
def invert(b: Array[Byte]): Buf = Buf.ByteArray.Owned(b)
}
)
}
Expand Down Expand Up @@ -721,8 +721,8 @@ class KetamaFailureAccrualFactory[Req, Rep](
// exclude CancelledRequestException and CancelledConnectionException for cache client failure accrual
override def isSuccess(response: Try[Rep]): Boolean = response match {
case Return(_) => true
case Throw(f@Failure(_: CancelledRequestException)) if f.isFlagged(Failure.Interrupted) => true
case Throw(f@Failure(_: CancelledConnectionException)) if f.isFlagged(Failure.Interrupted) => true
case Throw(f: Failure) if f.cause.exists(_.isInstanceOf[CancelledRequestException]) && f.isFlagged(Failure.Interrupted) => true
case Throw(f: Failure) if f.cause.exists(_.isInstanceOf[CancelledConnectionException]) && f.isFlagged(Failure.Interrupted) => true
// Failure.InterruptedBy(_) would subsume all these eventually after rb/334371
case Throw(WriteException(_: CancelledRequestException)) => true
case Throw(_: CancelledRequestException) => true
Expand Down

0 comments on commit 72261ed

Please sign in to comment.