OrientGraph createIndex and Configuration throw exception


#1

Hello everyone:
I have a question that I got a exception when I create index .
The version of tinkergraph-gremlin is 3.3.4 , the version of orientdb-gremlin is 3.0.10.

some code as follow:

  Configuration configuration = orientGraph.configuration();  

  configuration.setProperty("type",OClass.INDEX_TYPE.UNIQUE.toString()); 

  orientGraph.createVertexIndex("name","person",configuration);

The question is that the value of the setProperty of Configuration is Object. as follow:

void setProperty(String key, Object value);

then what I meet is :
When I make the value of the property called type to be OClass.INDEX_TYPE.UNIQUE,which belong to enum. but the method called createVertexIndex will call a method like:

private <E extends Element> void createIndex(final String key, String className, final Configuration configuration) {
    makeActive();

    prepareIndexConfiguration(configuration);

    OCallable<OClass, OrientGraph> callable = new OCallable<OClass, OrientGraph>() {
      @Override
      public OClass call(final OrientGraph g) {

        String indexType = configuration.getString("type"); 
        OType keyType = (OType) configuration.getProperty("keytype");
        String collate = configuration.getString("collate");
        ODocument metadata = (ODocument) configuration.getProperty("metadata");

        final ODatabaseDocument db = getRawDatabase();
        final OSchema schema = db.getMetadata().getSchema();

        final OClass cls = schema.getClass(className);
        final OProperty property = cls.getProperty(key);
        if (property != null)
          keyType = property.getType();

        OPropertyIndexDefinition indexDefinition = new OPropertyIndexDefinition(className, key, keyType);
        if (collate != null)
          indexDefinition.setCollate(collate);
        db.getMetadata().getIndexManager()
            .createIndex(className + "." + key, indexType, indexDefinition, cls.getPolymorphicClusterIds(), null, metadata);
        return null;
      }
    };
    execute(callable, "create key index on '", className, ".", key, "'");
  }

and some code in those is

String indexType = configuration.getString("type"); 

The implements of the method called getString is :

 public String getString(String key)
    {
        String s = getString(key, null);
        if (s != null)
        {
            return s;
        }
        else if (isThrowExceptionOnMissing())
        {
            throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object");
        }
        else
        {
            return null;
        }
    }

and then some code is :

String s = getString(key, null);

there,the implements of the method called getString() is :

public String getString(String key, String defaultValue)
    {
        Object value = resolveContainerStore(key);

        if (value instanceof String)
        {
            return interpolate((String) value);
        }
        else if (value == null)
        {
            return interpolate(defaultValue);
        }
        else
        {
            throw new ConversionException('\'' + key + "' doesn't map to a String object");
        }
    }

and then I found that the type of value allowed is String ,if it is others ,and it will throw exception.It is strange.

somebody help

Thanks

52HZ