Reputation: 18649
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.
Upvotes: 0
Views: 1171