间谍memcached施放异常,可能的bug?

时间:2011-11-22 15:54:31

标签: java memcached spymemcached

我在服务器日志中看到的常见错误很难追踪。我想知道会导致这样的异常,所以我可以确定我们的代码中发生了什么触发它?不幸的是,我没有重现的步骤,所以我无法确定代码中的调用是什么原因造成的。

           java.lang.ClassCastException: net.spy.memcached.MemcachedClient$5 cannot be cast to net.spy.memcached.ops.GetOperation$Callback
           at net.spy.memcached.protocol.ProxyCallback.addCallbacks(ProxyCallback.java:25)
           at net.spy.memcached.protocol.binary.OptimizedGetImpl.addOperation(OptimizedGetImpl.java:28)
           at net.spy.memcached.protocol.binary.OptimizedGetImpl.<init>(OptimizedGetImpl.java:21)
           at net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl.optimizeGets(BinaryMemcachedNodeImpl.java:46)
           at net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl.optimize(BinaryMemcachedNodeImpl.java:35)
           at net.spy.memcached.protocol.TCPMemcachedNodeImpl.fillWriteBuffer(TCPMemcachedNodeImpl.java:177)
           at net.spy.memcached.MemcachedConnection.handleWrites(MemcachedConnection.java:374)
           at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:326)
           at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:219)
           at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:1591)

更新: 我很确定这是我身边有问题的代码:

    Future<CASValue<Object>> profiles;
    String userID = "OBFUSCATED";
    profiles = memClient.asyncGets("PROFILES_" + userID);

在间谍memcached中它应该运行:

 public <T> OperationFuture<CASValue<T>> asyncGets(final String key,
  final Transcoder<T> tc) {

final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<CASValue<T>> rv =
    new OperationFuture<CASValue<T>>(key, latch, operationTimeout);

Operation op = opFact.gets(key, new GetsOperation.Callback() {
  private CASValue<T> val = null;

  public void receivedStatus(OperationStatus status) {
    rv.set(val, status);
  }

  public void gotData(String k, int flags, long cas, byte[] data) {
    assert key.equals(k) : "Wrong key returned";
    assert cas > 0 : "CAS was less than zero: " + cas;
    val =
        new CASValue<T>(cas, tc.decode(new CachedData(flags, data,
            tc.getMaxSize())));
  }

  public void complete() {
    latch.countDown();
  }
});
rv.setOperation(op);
addOp(key, op);
return rv;
}

一切似乎都井然有序,它将正确接口的匿名实现放入队列中,以后应该进行优化。我错过了问题发生的地方。

1 个答案:

答案 0 :(得分:2)

这是bug 96,已于7月修复。你正在运行一个旧版本。