Uploaded image for project: 'Spring Data Redis'
  1. Spring Data Redis
  2. DATAREDIS-950

ClassCastException on connection validation of shared Lettuce Cluster connections

    XMLWordPrintable

    Details

      Description

      Hi,

      I am using spring-data-redis 2.1.5.

       

      When getting a connection from the LettuceConnectionFactory, I get a ClassCastException from LettuceConnectionFactory.SharedConnection#validateConnection.

      The connection I created is StatefulRedisClusterConnection and I think the code below is wrong

      if (connection instanceof StatefulRedisClusterConnection) {
         ((StatefulRedisConnection) connection).sync().ping();
      }
      

       

      And one more question.
      I'm using LettucePoolingConnectionProvicer as the connectionProvider.

      And the code under the validationConnection method seems to work incorrectly.

      if (!valid) {
      
         if (connection != null) {
            connectionProvider.release(connection);
         }
      
         log.warn("Validation of shared connection failed. Creating a new connection.");
      
         resetConnection();
         this.connection = getNativeConnection();
      }

       

      Because LettucePoolingConnectionProvicer#releae is called twice in a row.
      In the first call, the pool is removed from poolRef, and in the second call, there is no pool and a PoolException exception is thrown.

      Any help would be much appreciated.

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mp911de Mark Paluch
              Reporter:
              wonkuym wonkuym
              Last updater:
              Oliver Drotbohm
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: