ClassCastException - [B cannot be cast to java.lang.Long
See original GitHub issueI am using Jesque which uses Jedis as its Redis client, so I am not entirely sure if this is an issue in Jedis or Jesque.
I am receiving this error:
java.lang.ClassCastException
[B cannot be cast to java.lang.Long
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:178)
at redis.clients.jedis.Jedis.incr(Jedis.java:605)
at net.greghaines.jesque.worker.WorkerImpl.success(WorkerImpl.java:520)
at net.greghaines.jesque.worker.WorkerImpl.execute(WorkerImpl.java:503)
at net.greghaines.jesque.worker.WorkerImpl.process(WorkerImpl.java:465)
at net.greghaines.jesque.worker.WorkerImpl.poll(WorkerImpl.java:405)
at net.greghaines.jesque.worker.WorkerImpl.run(WorkerImpl.java:216)
at java.lang.Thread.run(Thread.java:679)
I read that Jedis isnt thread-safe and in fact I dont try to re-use any Jedis clients in my Threads, I create new instances (I am refactoring this to use JedisPool).
The exception is not consistently reproducible.
Issue Analytics
- State:
- Created 12 years ago
- Comments:41
Top Results From Across the Web
How to fix this java.lang.ClassCastException: [B cannot be ...
You are trying to cast your in.readObject() file to a List. This does not work in Java because the file is written as...
Read more >How to fix java.lang.classcastexception cannot be cast to in Java
As name suggests ClassCastException in Java comes when we try to type cast an object and object is not of the type we...
Read more >B cannot be cast to java.lang.String - MariaDB's JIRA
The last line raises an error: java.lang.ClassCastException: [B cannot be cast to java.lang.String. The output of our stored procedure is a ...
Read more >B cannot be cast to java.util.List Multithreading environnement
java.lang.ClassCastException: [B cannot be cast to java.util.List. at redis.clients.jedis.Connection.getBinaryMultiBulkReply(Connection.java:202).
Read more >How to Fix java.lang.classcastexception in Java?
ClassCastException in Java occurs when we try to convert the data type of entry into another. This is related to the type conversion...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I really don’t know nothing about Gresque and how it uses Jedis underneath. But I am almost 100% sure that this error is because of reusing jedis instance from different threads. If you are using JedisPool, make sure to return Jedis either using returnResource or returnBrokenResource. Also if you are opening a pipeline, remember to close it before returning the resource to the pool. Try to find a script that reproduce this error and send it to me!
On Tue, Jul 26, 2011 at 2:43 PM, ruckus < reply@reply.github.com>wrote:
I got the exact same error a couple times an hour when I used the same connection in a runnable called 20ms later. This is what I originally had.
I changed it to this and it’s been working flawlessly for a few days now.
@hozouhing @AmaranthLIS I’m not sure what your situation is, but if you’re using the same connection more than once then I would try getting a new one. It seems like (at least in my case), it’s a usage error rather than a bug in Jedis.