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

Using a collection in the RedisHash is broken

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.12 (Kay SR12), 1.8.17 (Ingalls SR17), 2.1.3 (Lovelace SR3)
    • Component/s: Core
    • Labels:
      None

      Description

      Environment:

      • Spring Boot 2.1
      • Spring Redis 2.1.3
      • Java 8 191
      • Kotlin 1.3.10

       

      @RedisHash("device")
      class Device(
          // device OUI-SN
          @Id val id: String = "",
          // hash of username/password
          var credentials: String? = null,
          // value in seconds of the fast inform interval
          var informInterval: Int = 0,
          // last time it was sent to the ACS
          // assume it has when it was created in the database
          var lastManaged: Instant = Instant.now(),
          // last time it inform
          var lastInform: Instant? = null,
          // each profile this device belongs to
          var profiles: Set<String> = mutableSetOf()
      ) 

      The profiles fails with a ClassCastException unable to convert from String to Set<String>

      Tracked down the area that looks to be trouble.

          @RequiredArgsConstructor
          private class ConverterAwareParameterValueProvider implements PropertyValueProvider<RedisPersistentProperty> {
      
              private final String path;
              private final RedisData source;
              private final ConversionService conversionService;
      
              @Override
              @SuppressWarnings("unchecked")
              public <T> T getPropertyValue(RedisPersistentProperty property) {
      
                  Object value = readProperty(path, source, property);
      
                  // FIXME: doesn't work for kotlin collection
                  if (value != null && !property.getActualType().isInstance(value)) {
                      if (value instanceof Collection) {
                          return (T) value;
                      }
                      return (T) conversionService.convert(value, property.getActualType());
                  }
      
                  return (T) value;
              }
          }
      

        Attachments

          Activity

            People

            • Assignee:
              mp911de Mark Paluch
              Reporter:
              arris_wdroste Will Droste
              Last updater:
              Mark Paluch
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: