I use Spring Boot 1.5.19

org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:204) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:348) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:129) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:92) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:79) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:194) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:169) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:91) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    at org.springframework.data.redis.core.DefaultListOperations.leftPop(DefaultListOperations.java:50) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    at com.dxy.platform.core.message.RedisQueueMessageConsumerContainer.getIfPresent(RedisQueueMessageConsumerContainer.java:23) ~[module-core-0.0.29.jar!/:0.0.29]
    at com.dxy.platform.core.message.QueueMessageConsumerContainerAdapter.lambda$init$0(QueueMessageConsumerContainerAdapter.java:64) ~[module-core-0.0.29.jar!/:0.0.29]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_181]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_181]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
    at redis.clients.util.Pool.getResource(Pool.java:53) ~[jedis-2.9.1.jar!/:?]
    at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226) ~[jedis-2.9.1.jar!/:?]
    at redis.clients.jedis.JedisPool.getResource(JedisPool.java:16) ~[jedis-2.9.1.jar!/:?]
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:194) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    ... 13 more
Caused by: java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014) ~[?:1.8.0_181]
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2088) ~[?:1.8.0_181]
    at org.apache.commons.pool2.impl.LinkedBlockingDeque.pollFirst(LinkedBlockingDeque.java:635) ~[commons-pool2-2.4.3.jar!/:2.4.3]
    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:442) ~[commons-pool2-2.4.3.jar!/:2.4.3]
    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:361) ~[commons-pool2-2.4.3.jar!/:2.4.3]
    at redis.clients.util.Pool.getResource(Pool.java:49) ~[jedis-2.9.1.jar!/:?]
    at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226) ~[jedis-2.9.1.jar!/:?]
    at redis.clients.jedis.JedisPool.getResource(JedisPool.java:16) ~[jedis-2.9.1.jar!/:?]
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:194) ~[spring-data-redis-1.8.18.RELEASE.jar!/:?]
    ... 13 more

Comment From: wilkinsona

The exception is indicating that something has interrupted a thread that was attempting to retrieve a connection from the pool. That could be entirely normal behaviour if, for example, the pool is being closed by one thread while another is trying to use it. You haven't described the circumstances in which the exception is occurring or explained why you think the problem is caused by Spring Boot. If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem.

Comment From: shenjianeng

It's hard to give examples.

While running with Spring Boot 1.5.19 ,it is facing this issue .

But while running with Spring Boot 1.5.18 , it is good .

Comment From: wilkinsona

The only changes made in 1.5.19 were dependency upgrades so, with no evidence to the contrary, I do not think that Spring Boot itself is the cause of the problem. The most likely cause is the upgrade to Jedis 2.9.1 which contained changes for 83 issues. You could downgrade to Jedis 2.9.0 (by setting jedis.version in you pom or Gradle script) and see if the problem still occurs. If it does not, I would recommend opening a Jedis issue and provided as much detail as possible.

Comment From: arturhc

I have a similar problem..

The log is:

2019-05-30 14:44:31.652 DEBUG 31999 --- [http-nio-80-exec-646] o.s.b.a.audit.listener.AuditListener : AuditEvent [timestamp=2019-05-30T14:44:31.652Z, principal=arturh.sw@gmail.com, type=AUTHENTICATION_SUCCESS, data={details={grant_type=password, scope=read, client_secret=chat_s3cr3t, client_id=qbits_chat, username=arturh.sw@gmail.com}}]
2019-05-30 14:44:31.669 DEBUG 31999 --- [http-nio-80-exec-646] .m.m.a.ExceptionHandlerExceptionResolver : Using @ExceptionHandler public org.springframework.http.ResponseEntity<org.springframework.security.oauth2.common.exceptions.OAuth2Exception> org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.handleException(java.lang.Exception) throws java.lang.Exception
2019-05-30 14:44:31.670 WARN 31999 --- [http-nio-80-exec-646] o.s.s.o.provider.endpoint.TokenEndpoint : Handling error: RedisConnectionFailureException, Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
2019-05-30 14:44:31.692 DEBUG 31999 --- [http-nio-80-exec-646] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [application/json] and supported [application/json, application/*+json, application/json, application/*+json]
2019-05-30 14:44:31.693 DEBUG 31999 --- [http-nio-80-exec-646] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [error="server_error", error_description="Internal Server Error"]
2019-05-30 14:44:31.701 DEBUG 31999 --- [http-nio-80-exec-646] o.s.s.w.header.writers.HstsHeaderWriter : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@746660a8
2019-05-30 14:44:31.701 DEBUG 31999 --- [http-nio-80-exec-646] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool]
2019-05-30 14:44:31.701 DEBUG 31999 --- [http-nio-80-exec-646] o.s.web.servlet.DispatcherServlet : Completed 500 INTERNAL_SERVER_ERROR
2019-05-30 14:44:31.702 DEBUG 31999 --- [http-nio-80-exec-646] o.s.s.w.a.ExceptionTranslationFilter : Chain processed normally

I have the following dependencies:

        <dependency>
            <groupId>org.springframework.security.oauth</groupId>
            <artifactId>spring-security-oauth2</artifactId>
            <version>2.3.3.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
            <version>2.0.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.9.0</version>
            <type>jar</type>
        </dependency>

I'm using RedisTokenStore with OAuth2

Comment From: shindemayuri

I am also getting same issue sometimes and its yet to resolve my build.gradle is like:

springBootVersion = '2.0.2.RELEASE'
compile('org.springframework.boot:spring-boot-starter-data-redis:2.0.2.RELEASE')
compile('redis.clients:jedis:2.9.1')

Please suggest some solution.

Comment From: wilkinsona

@shindemayuri Please see my comment above for some suggestions.

Comment From: philwebb

@shindemayuri I'd recommend upgrading to the latest stable version of Spring Boot as well if possible. Boot v2.0.2 is quite old now.

Comment From: shindemayuri

Issue is resolved now: By removing extra Space issue at end of line in redis configuration properties spring.redis.host=localhost

Comment From: Tidhy

问题现已解决: 通过在Redis配置属性 spring.redis.host = localhost中删除行尾的多余空间问题

别闹

Comment From: SriramShree

org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketTimeoutException

Comment From: shenjianeng

这是来自邮箱的自动回复邮件,我已收到邮件。-------------------------------------------------