ngageoint / elasticgeo

ElasticGeo provides a GeoTools data store that allows geospatial features from an Elasticsearch index to be published via OGC services using GeoServer.
GNU General Public License v3.0
168 stars 85 forks source link

ClassCastException when walking a mapping with attribute called "type" #8

Closed IamJeffG closed 9 years ago

IamJeffG commented 9 years ago

When publishing a new layer for an index that contains the following type mapping:

{
  "myindexname" : {
    "mappings" : {
      "baz" : {
    "_all" : {
      "enabled" : false
    },
    "_id" : {
      "path" : "id"
    },
    "_timestamp" : {
      "enabled" : true,
      "store" : true
    },
    "properties" : {
      "crs" : {
        "dynamic" : "true",
        "properties" : {
          "properties" : {
            "dynamic" : "true",
            "properties" : {
              "name" : {
                "type" : "string"
              }
            }
          },
          "type" : {
            "type" : "string"
          }
        }
      },
      "geometry" : {
        "type" : "geo_shape",
        "tree" : "quadtree",
      }
    }
      }
    }
  }
}

Geoserver crashes with a stack trace, saying HashMap can't be cast as a String.

The trick is that the mapping above has {"type": {"type": "string"}}, and the value of the first type key is not a string. This stems from ElasticDataStore's walk method.

sjudeng commented 9 years ago

I committed and pushed a fix, which was especially easy thanks to the details you provided in your bug report.

IamJeffG commented 9 years ago

Many thanks for the quick response, @sjudeng !