Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-6195

RutaLiteralMatcher throws NPE

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 3.0.0ruta
    • Fix Version/s: 3.0.1ruta
    • Component/s: Ruta
    • Labels:
      None

      Description

      Problem
      During update to ruta 3.0.0. from 2.6.1, one of my rules started to throw an NPE at execution in RutaLiteralMatcher.

      Example
      It's a very simple rule with a literal upper case "I" followed by a previous match (in this case underscores):

      "____+" -> SIMPLEFORMATTING;
      "I" SIMPLEFORMATTING "I"? { -> MARKONCE(FORMATTING,1,2)};
      

      When run on input like

      "PI_____I How to test it?"

      it crashes with NPE. Input like

      "P I_____I How to test it?"

      is fine.

      Here's the stack:

      org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator processing failed.    org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator processing failed.     at org.apache.uima.ruta.engine.RutaEngine.process(RutaEngine.java:614) at org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48) at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.lambda$callProcessMethod$3(AnalysisEngineImplBase.java:626) at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.withContexts(AnalysisEngineImplBase.java:653) at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.callProcessMethod(AnalysisEngineImplBase.java:623) at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:381) at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:299) at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:272) at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:287) at com.myorg.uima.ruta.recognizer.RecognizerFormattingFactoryTest.run(RecognizerFormattingFactoryTest.java:208) at com.myorg.uima.ruta.recognizer.RecognizerFormattingFactoryTest.testFormattingRutaUpdateBug2020(RecognizerFormattingFactoryTest.java:191) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)Caused by: java.lang.NullPointerException at org.apache.uima.ruta.rule.RutaLiteralMatcher.getAnnotation(RutaLiteralMatcher.java:72) at org.apache.uima.ruta.rule.RutaLiteralMatcher.getMatchingAnnotations(RutaLiteralMatcher.java:62) at org.apache.uima.ruta.rule.RutaLiteralMatcher.getMatchingAnnotations(RutaLiteralMatcher.java:37) at org.apache.uima.ruta.rule.RutaRuleElement.getAnchors(RutaRuleElement.java:52) at org.apache.uima.ruta.rule.RutaRuleElement.startMatch(RutaRuleElement.java:60) at org.apache.uima.ruta.rule.ComposedRuleElement.startMatch(ComposedRuleElement.java:77) at org.apache.uima.ruta.rule.RutaRule.apply(RutaRule.java:65) at org.apache.uima.ruta.rule.RutaRule.apply(RutaRule.java:56) at org.apache.uima.ruta.rule.RutaRule.apply(RutaRule.java:38) at org.apache.uima.ruta.block.RutaScriptBlock.apply(RutaScriptBlock.java:72) at org.apache.uima.ruta.RutaModule.apply(RutaModule.java:56) at org.apache.uima.ruta.engine.RutaEngine.process(RutaEngine.java:612) ... 33 more
      

      I looked just a little at debugging RutaLiteralMatcher.java and it crashes in L71 at retrieving the beginAnchor.

      RutaBasic beginAnchor = stream.getBeginAnchor(begin);

      The begin that it is looking for is 1, but it's covered by "CAP:3"/"RutaBasic:21" from 0 to 2 (cf. screen captures).

      This did not occur with ruta 2.6.1.

       

        Attachments

        1. 2_Debug_View_Types.JPG
          98 kB
          Dominic Jehle
        2. 1_Debug_View.JPG
          273 kB
          Dominic Jehle

          Issue Links

            Activity

              People

              • Assignee:
                pkluegl Peter Klügl
                Reporter:
                Dominic20 Dominic Jehle
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: