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

Navigating a class that extends Map results in the map's value type masking real properties

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.7.1 (Hopper SR1)
    • Fix Version/s: None
    • Component/s: Repository Support
    • Labels:
      None
    • Sprint:
      Hopper GA, Hopper SR2

      Description

      Navigating a type like this:

      class Pipeline extends HashMap<String, Object> implements Timestamped {
        @JsonIgnore
        Long lastModified
      
        @JsonIgnore
        String getApplication() {
          return super.get("application")
        }
      
        @JsonIgnore
        String getName() {
          return super.get("name")
        }
      
        void setName(String name) {
          super.put("name", name)
        }
      
        @Override
        @JsonIgnore
        String getId() {
          return super.get("id")
        }
      
        void setId(String id) {
          super.put("id", id)
        }
      }
      

      ...when used as a subtype of another enclosing type, causes Spring Data Redis to look that the Map's value type...

      Spring Data Commons:TypeDiscoverer.java
      	public TypeInformation<?> getActualType() {
      
      		if (isMap()) {
      			return getMapValueType();
      		}
      
      		if (isCollectionLike()) {
      			return getComponentType();
      		}
      
      		return this;
      	}
      

      Hence, the Pipeline above will resolve itself to Object. At that point, a finder method based on "application" property will look for Object.application, and come up with null, since that doesn't exist. Hence, property traversal fails.

      NOTE: Is this a Spring Data Commons issue?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cstrobl Christoph Strobl
              Reporter:
              gregturn Greg Turnquist
              Last updater:
              Christoph Strobl
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: