Skip to content

NullPointerException when Deactivating type mapping #210

Closed
@Joalien

Description

@Joalien

To deactivate the type mapping, the documentation advises to set typeKey to null

As explained in the documentation

deactivating type mapping may lead to exceptions when reading the entities from the DB.

In the method com.arangodb.springframework.core.convert.DefaultArangoTypeMapper.DefaultTypeAliasAccessor#readAliasFrom, the call source.get(this.typeKey); throws a NullPointerException when this.typeKey is null. I suggest to add a non-null check before

before

if (source.isObject()) {
    final VPackSlice typeKey = source.get(this.typeKey);
    return Alias.ofNullable(typeKey.isString() ? typeKey.getAsString() : null);
}

after

if (source.isObject()) {
    if (this.typeKey == null) return Alias.NONE;
    final VPackSlice typeKey = source.get(this.typeKey);
    return Alias.ofNullable(typeKey.isString() ? typeKey.getAsString() : null);
}

Here is the linked pull request

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions