Skip to content

Commit 487d155

Browse files
authored
add redis
1 parent 5282735 commit 487d155

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
11
# tutorial-java
22
Tutorial
3+
4+
5+
## Could not get a resource from the pool
6+
7+
```
8+
Caused by: redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool
9+
at redis.clients.util.Pool.getResource(Pool.java:51)
10+
at redis.clients.jedis.ShardedJedisPool.getResource(ShardedJedisPool.java:36)
11+
Caused by: java.util.NoSuchElementException: Unable to validate object
12+
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:506)
13+
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
14+
at redis.clients.util.Pool.getResource(Pool.java:49)
15+
```
16+
17+
```java
18+
@Override
19+
public boolean validateObject(PooledObject<ShardedJedis> pooledShardedJedis) {
20+
try {
21+
ShardedJedis jedis = pooledShardedJedis.getObject();
22+
for (Jedis shard : jedis.getAllShards()) {
23+
if (!shard.ping().equals("PONG")) {
24+
return false;
25+
}
26+
}
27+
return true;
28+
} catch (Exception ex) {
29+
/*
30+
MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
31+
*/
32+
return false;
33+
}
34+
}
35+
```

0 commit comments

Comments
 (0)