Skip to content

NullReferenceException in MappingWalker #1068

@mausch

Description

@mausch
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Nest.DSL.Visitor.MappingWalker.Accept(RootObjectMapping mapping) in c:\code\elasticsearch-net\src\Nest\DSL\Visitor\MappingWalker.cs:line 21
   at Nest.GetMappingResponse.Accept(IMappingVisitor visitor) in c:\code\elasticsearch-net\src\Nest\Domain\Responses\GetMappingResponse.cs:line 54
   at NESTMapping.Program.Main(String[] args) in c:\Users\Mauricio\Documents\Visual Studio 2013\Projects\NESTMapping\NESTMapping\Program.cs:line 117

Repro:

using System;
using System.Collections.Generic;
using Nest;
using Nest.DSL.Visitor;

namespace NESTMapping
{
    public class UnwantedObject
    {
        public int DoNotWant { get; set; }
    }

    public class SomeObject
    {
        public UnwantedObject Unwanted { get; set; }

        public string Name;
    }

    class MappingVisitor: IMappingVisitor
    {
        private readonly int id;

        public MappingVisitor(int id)
        {
            this.id = id;
        }

        public int Depth
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void Visit(AttachmentMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(GeoShapeMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(GeoPointMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(IPMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(MultiFieldMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(NestedObjectMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(ObjectMapping mapping)
        {
            throw new Exception("Object mapping detected " + id);
        }

        public void Visit(BinaryMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(BooleanMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(DateMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(NumberMapping mapping)
        {
            throw new NotImplementedException();
        }

        public void Visit(StringMapping mapping)
        {
        }

        public void Visit(RootObjectMapping mapping)
        {
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            const string indexName = "someindex";
            var connectionSettings = new ConnectionSettings(uri: null, defaultIndex: indexName);
            var client = new ElasticClient(connectionSettings);
            client.DeleteIndex(x => x.AllIndices());
            client.CreateIndex(indexName);
            client.Map<SomeObject>(m => m.Type(indexName).Properties(p => p.String(d => d.Name(x => x.Name))));
            var mapping = client.GetMapping<SomeObject>(x => x);
            mapping.Accept(new MappingVisitor(1));
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions