{"action":"created","issue":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/6151","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/6151/labels{/name}","comments_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/6151/comments","events_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/6151/events","html_url":"https://github.com/hazelcast/hazelcast/issues/6151","id":105312240,"number":6151,"title":"NullPointerException when adding index","user":{"login":"wimdeblauwe","id":1115823,"avatar_url":"https://avatars.githubusercontent.com/u/1115823?v=3","gravatar_id":"","url":"https://api.github.com/users/wimdeblauwe","html_url":"https://github.com/wimdeblauwe","followers_url":"https://api.github.com/users/wimdeblauwe/followers","following_url":"https://api.github.com/users/wimdeblauwe/following{/other_user}","gists_url":"https://api.github.com/users/wimdeblauwe/gists{/gist_id}","starred_url":"https://api.github.com/users/wimdeblauwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wimdeblauwe/subscriptions","organizations_url":"https://api.github.com/users/wimdeblauwe/orgs","repos_url":"https://api.github.com/users/wimdeblauwe/repos","events_url":"https://api.github.com/users/wimdeblauwe/events{/privacy}","received_events_url":"https://api.github.com/users/wimdeblauwe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/PENDING","name":"PENDING","color":"bfe5bf"},{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Team:%20Core","name":"Team: Core","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-08T06:47:05Z","updated_at":"2015-09-10T15:56:58Z","closed_at":null,"body":"The following unit test shows the NullPointerException:\r\n\r\n```\r\npackage com.traficon.tmsng.server;\r\n\r\nimport com.hazelcast.config.Config;\r\nimport com.hazelcast.config.MapConfig;\r\nimport com.hazelcast.config.MapIndexConfig;\r\nimport com.hazelcast.core.Hazelcast;\r\nimport com.hazelcast.core.HazelcastInstance;\r\nimport com.hazelcast.core.IMap;\r\n\r\nimport java.io.Serializable;\r\n\r\n/**\r\n * Created by wdb on 07/09/15.\r\n */\r\npublic class HazelcastIndexTest\r\n{\r\n\tpublic static void main( String[] args )\r\n\t{\r\n\t\tConfig config = new Config();\r\n\t\tMapConfig mapConfig = new MapConfig();\r\n\t\tmapConfig.setName( \"test\" );\r\n\t\tmapConfig.addMapIndexConfig( new MapIndexConfig( \"name\", false ) );\r\n\t\tmapConfig.addMapIndexConfig( new MapIndexConfig( \"testInterface.foo\", false ) );\r\n\t\tconfig.addMapConfig( mapConfig );\r\n\t\tHazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance( config );\r\n\r\n\t\tIMap<Object, Object> testMap = hazelcastInstance.getMap( \"test\" );\r\n\r\n\t\ttestMap.put( \"key\", new Person() );\r\n\t}\r\n\r\n\tprivate static class Person implements Serializable\r\n\t{\r\n\t\tprivate String m_name;\r\n\t\tprivate TestInterface m_testInterface;\r\n\r\n\t\tpublic String getName()\r\n\t\t{\r\n\t\t\treturn m_name;\r\n\t\t}\r\n\r\n\t\tpublic void setName( String name )\r\n\t\t{\r\n\t\t\tm_name = name;\r\n\t\t}\r\n\r\n\t\tpublic TestInterface getTestInterface()\r\n\t\t{\r\n\t\t\treturn m_testInterface;\r\n\t\t}\r\n\r\n\t\tpublic void setTestInterface( TestInterface testInterface )\r\n\t\t{\r\n\t\t\tm_testInterface = testInterface;\r\n\t\t}\r\n\t}\r\n\r\n\tprivate static interface TestInterface\r\n\t{\r\n\r\n\t}\r\n\r\n\tprivate static class TestInterfaceImpl implements TestInterface\r\n\t{\r\n\t\tprivate String m_foo;\r\n\r\n\t\tpublic String getFoo()\r\n\t\t{\r\n\t\t\treturn m_foo;\r\n\t\t}\r\n\r\n\t\tpublic void setFoo( String foo )\r\n\t\t{\r\n\t\t\tm_foo = foo;\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nAnd this is the resulting exception:\r\n\r\n```\r\nException in thread \"main\" com.hazelcast.query.QueryException: java.lang.NullPointerException\r\n\tat com.hazelcast.query.impl.getters.ReflectionHelper.createGetter(ReflectionHelper.java:204)\r\n\tat com.hazelcast.query.impl.getters.ReflectionHelper.getAttributeType(ReflectionHelper.java:128)\r\n\tat com.hazelcast.query.impl.QueryEntry.getAttributeType(QueryEntry.java:174)\r\n\tat com.hazelcast.query.impl.IndexImpl.saveEntryIndex(IndexImpl.java:83)\r\n\tat com.hazelcast.query.impl.IndexService.saveEntryIndex(IndexService.java:83)\r\n\tat com.hazelcast.map.impl.AbstractRecordStore.saveIndex(AbstractRecordStore.java:159)\r\n\tat com.hazelcast.map.impl.DefaultRecordStore.put(DefaultRecordStore.java:776)\r\n\tat com.hazelcast.map.impl.operation.PutOperation.run(PutOperation.java:34)\r\n\tat com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:137)\r\n\tat com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.processOperation(OperationThread.java:154)\r\n\tat com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.process(OperationThread.java:110)\r\n\tat com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.doRun(OperationThread.java:101)\r\n\tat com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.run(OperationThread.java:76)\r\nCaused by: java.lang.NullPointerException\r\n\tat com.hazelcast.query.impl.getters.ReflectionHelper.createGetter(ReflectionHelper.java:180)\r\n\t... 12 more\r\n```\r\n\r\nThe problem is that we want to index on a field `foo` that is only available in a subclass of the interface `TestInterface`. This works fine in Coherence.\r\n\r\nIs there any workaround we can use for now?\r\n\r\nWe are using Hazelcast 3.5 on Java 8.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/comments/139289894","html_url":"https://github.com/hazelcast/hazelcast/issues/6151#issuecomment-139289894","issue_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/6151","id":139289894,"user":{"login":"jerrinot","id":158619,"avatar_url":"https://avatars.githubusercontent.com/u/158619?v=3","gravatar_id":"","url":"https://api.github.com/users/jerrinot","html_url":"https://github.com/jerrinot","followers_url":"https://api.github.com/users/jerrinot/followers","following_url":"https://api.github.com/users/jerrinot/following{/other_user}","gists_url":"https://api.github.com/users/jerrinot/gists{/gist_id}","starred_url":"https://api.github.com/users/jerrinot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerrinot/subscriptions","organizations_url":"https://api.github.com/users/jerrinot/orgs","repos_url":"https://api.github.com/users/jerrinot/repos","events_url":"https://api.github.com/users/jerrinot/events{/privacy}","received_events_url":"https://api.github.com/users/jerrinot/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T15:56:57Z","updated_at":"2015-09-10T15:56:57Z","body":"@wimdeblauwe: I'm afraid the best workaround I can see right now is to add the method `String getFoo()` into the `TestInterface` interface.\r\n\r\nI'll send a PR to fix the NPE, but in won't help with your case. You will just get a more descriptive error message. "}}