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

DMNRuntime API parameter nullcheck

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Done
    • Major
    • None
    • None
    • dmn engine
    • None
    • 2018 Week 33-35
    • 1
    • NEW
    • NEW

    Description

      Given

              final DMNModel dmnModel = runtime.getModel("<wrong>", "<wrong>");
              // please notice an end-user of the API might not having checked the result of the previous call is not a null.
              DMNContext emptyContext = DMNFactory.newContext();
              DMNResult dmnResult = runtime.evaluateAll(dmnModel, emptyContext);
      

      This would fail with:

      java.lang.NullPointerException
      	at org.kie.dmn.core.impl.DMNRuntimeImpl.performRuntimeTypeCheck(DMNRuntimeImpl.java:622)
      	at org.kie.dmn.core.impl.DMNRuntimeImpl.evaluateAll(DMNRuntimeImpl.java:118)
      	at org.kie.dmn.core.DMNRuntimeTypeCheckTest.testMisleadingNPEbyAPIusage(DMNRuntimeTypeCheckTest.java:199)
      ...
      

      which is not very helpful for the end-user of API to understand he inadvertently passed a null model to the DMNRuntime.evaluateAll method.

      With the proposed change:

      java.lang.NullPointerException: Kie DMN API parameter 'model' cannot be null.
        at java.util.Objects.requireNonNull(Objects.java:290)
        at org.kie.dmn.core.impl.DMNRuntimeImpl.evaluateAll(DMNRuntimeImpl.java:123)
        at org.kie.dmn.core.DMNRuntimeTypeCheckTest.testMisleadingNPEbyAPIusage(DMNRuntimeTypeCheckTest.java:199)
      ...
      

      Attachments

        Activity

          People

            mmortari@redhat.com Matteo Mortari
            mmortari@redhat.com Matteo Mortari
            Tibor Zimányi Tibor Zimányi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: