间谍 memcached 转换异常,可能的错误?
我在服务器日志中看到一个罕见的错误,很难追踪。我想知道会导致这样的异常,以便我可以确定我们的代码中发生了什么触发它?不幸的是,我没有重现的步骤,所以我无法确定是什么调用了代码导致了它。
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;
}
一切似乎都按顺序进行,它将正确接口的匿名实现放入队列中,稍后应该对其进行优化。我不知道问题发生在哪里。
There is an infrequent error that I see in my serverlogs which is hard to track down. I am wondering would cause such an exception so I can identify what in our code happens to trigger it? Unfortunately I don't have steps to reproduce so I can't identify what calls in out code cause it.
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)
Update:
I am fairly sure this is the offending code on my side:
Future<CASValue<Object>> profiles;
String userID = "OBFUSCATED";
profiles = memClient.asyncGets("PROFILES_" + userID);
And in spy memcached it should run:
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;
}
Everything seems to be in order, it puts an anonymous implementation of the correct interface into the queue which should get optimized later. I am missing where the problem is occurring.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是bug 96,已于 7 月修复。您正在运行旧版本。
This was bug 96, fixed in July. You're running an old version.