Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-2224

Inconsistent values returned by AccessorKey.hashCode causes NullPointerException during binary deserialization

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 7.5.0.Final
    • Fix Version/s: None
    • Component/s: core engine
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      See junit tests in the linked PR. Note that the two tests need to be run separately:

      $ (cd drools-compiler/ && mvn test -Dtest=SerializedPackageMergeTwoSteps1Test)
      $ (cd drools-compiler/ && mvn test -Dtest=SerializedPackageMergeTwoSteps2Test)
      
      Show
      See junit tests in the linked PR. Note that the two tests need to be run separately: $ (cd drools-compiler/ && mvn test -Dtest=SerializedPackageMergeTwoSteps1Test) $ (cd drools-compiler/ && mvn test -Dtest=SerializedPackageMergeTwoSteps2Test)
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      Consider the following sequence of events:

      1. serialize a set of text rule files
      2. create a binary file for the serialized rule files
      3. deserialize the binary file created in the step 2.

      When each step is executed in different JVM runs, step 3 fails with a NullPointerException:

      java.lang.NullPointerException: null
      	at org.drools.core.reteoo.CompositeObjectSinkAdapter.isHashable(CompositeObjectSinkAdapter.java:158)
      	at org.drools.core.reteoo.CompositeObjectSinkAdapter.getHashableAccessor(CompositeObjectSinkAdapter.java:149)
      	at org.drools.core.reteoo.CompositeObjectSinkAdapter.addObjectSink(CompositeObjectSinkAdapter.java:108)
      	at org.drools.core.reteoo.SingleObjectSinkAdapter.addObjectSink(SingleObjectSinkAdapter.java:55)
      	at org.drools.core.reteoo.ObjectSource.addObjectSink(ObjectSource.java:216)
      	at org.drools.core.reteoo.LeftInputAdapterNode.attach(LeftInputAdapterNode.java:155)
      	at org.drools.core.reteoo.builder.BuildUtils.attachNode(BuildUtils.java:141)
      	at org.drools.core.reteoo.builder.GroupElementBuilder$AndBuilder.buildTupleSource(GroupElementBuilder.java:126)
      	at org.drools.core.reteoo.builder.GroupElementBuilder$AndBuilder.build(GroupElementBuilder.java:109)
      	at org.drools.core.reteoo.builder.GroupElementBuilder.build(GroupElementBuilder.java:68)
      	at org.drools.core.reteoo.builder.ReteooRuleBuilder.addSubRule(ReteooRuleBuilder.java:161)
      	at org.drools.core.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:133)
      	at org.drools.core.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:110)
      	at org.drools.core.impl.KnowledgeBaseImpl.internalAddRule(KnowledgeBaseImpl.java:1526)
      	at org.drools.core.impl.KnowledgeBaseImpl.internalAddPackages(KnowledgeBaseImpl.java:915)
      	at org.drools.core.impl.KnowledgeBaseImpl.lambda$addPackages$1(KnowledgeBaseImpl.java:717)
      	at org.drools.core.impl.KnowledgeBaseImpl.enqueueModification(KnowledgeBaseImpl.java:734)
      	at org.drools.core.impl.KnowledgeBaseImpl.addPackages(KnowledgeBaseImpl.java:717)
      	at org.drools.compiler.integrationtests.SerializedPackageMergeTwoSteps2Test.testBuildAndSerializePackagesInTwoSteps2(SerializedPackageMergeTwoSteps2Test.java:88)
      

      If making one single run for all 3 steps, everything works fine.

      The problem are inconsistent hashCode values for the AccessorKey object when the JVM is restarted, due to the usage of Enum.hashCode:
      https://github.com/kiegroup/drools/blob/master/drools-core/src/main/java/org/drools/core/base/AccessorKey.java#L48

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mfusco Mario Fusco
                  Reporter:
                  mputz Martin Weiler
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: