java.lang.NullPointerException

Spring JIRA | William Weiss | 2 years ago
  1. 0

    When calling equals on a Neo4jEntity with a non-entity object, a NullPointerException is thrown due to the handling of equals(), and ultimately, the handling of getId() in EntityStateHandler. The following test case illustrates the problem: {code:title=AbstractNeo4jObject.java|borderStyle=solid} @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/META-INF/spring/infrastructure/test/test-context.xml") public class AbstractNeo4jObjectTest { protected AbstractNeo4jObject object; @Test @Transactional public void testPersistedEntityEqualsBug() throws Exception { // Given givenAPersistedEntity(); final ArrayList<String> otherObj = new ArrayList<String>(); // When final boolean result = object.equals(otherObj); // Then assertFalse(result); } protected void givenAPersistedEntity() throws Exception { final MockNeo4jEntity entity = new MockNeo4jEntity(); entity.setValud("foo"); entity.persist(); this.object = entity; } } {code} Running this test will result in the following: {noformat} java.lang.NullPointerException at org.springframework.data.neo4j.support.mapping.EntityStateHandler.getId(EntityStateHandler.java:89) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.getPersistentState(EntityStateHandler.java:108) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.equals(EntityStateHandler.java:288) at org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$equals(Neo4jNodeBacking.aj:235) ... {noformat}

    Spring JIRA | 2 years ago | William Weiss
    java.lang.NullPointerException
  2. 0

    When calling equals on a Neo4jEntity with a non-entity object, a NullPointerException is thrown due to the handling of equals(), and ultimately, the handling of getId() in EntityStateHandler. The following test case illustrates the problem: {code:title=AbstractNeo4jObject.java|borderStyle=solid} @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/META-INF/spring/infrastructure/test/test-context.xml") public class AbstractNeo4jObjectTest { protected AbstractNeo4jObject object; @Test @Transactional public void testPersistedEntityEqualsBug() throws Exception { // Given givenAPersistedEntity(); final ArrayList<String> otherObj = new ArrayList<String>(); // When final boolean result = object.equals(otherObj); // Then assertFalse(result); } protected void givenAPersistedEntity() throws Exception { final MockNeo4jEntity entity = new MockNeo4jEntity(); entity.setValud("foo"); entity.persist(); this.object = entity; } } {code} Running this test will result in the following: {noformat} java.lang.NullPointerException at org.springframework.data.neo4j.support.mapping.EntityStateHandler.getId(EntityStateHandler.java:89) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.getPersistentState(EntityStateHandler.java:108) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.equals(EntityStateHandler.java:288) at org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$equals(Neo4jNodeBacking.aj:235) ... {noformat}

    Spring JIRA | 2 years ago | William Weiss
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.springframework.data.neo4j.support.mapping.EntityStateHandler.getId()
    2. Spring Data Neo4j
      EntityStateHandler.equals
      1. org.springframework.data.neo4j.support.mapping.EntityStateHandler.getId(EntityStateHandler.java:89)
      2. org.springframework.data.neo4j.support.mapping.EntityStateHandler.getPersistentState(EntityStateHandler.java:108)
      3. org.springframework.data.neo4j.support.mapping.EntityStateHandler.equals(EntityStateHandler.java:288)
      3 frames
    3. Spring Data Neo4j - AspectJ Advanced Mapping
      Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$equals
      1. org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$equals(Neo4jNodeBacking.aj:235)
      1 frame