Author: pkluegl Date: Tue Dec 18 20:12:27 2018 New Revision: 1849223 URL: http://svn.apache.org/viewvc?rev=1849223&view=rev Log: UIMA-5882: use withSnapshotIterators, added test
Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/WildCard2Test.java Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java?rev=1849223&r1=1849222&r2=1849223&view=diff ============================================================================== --- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java (original) +++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java Tue Dec 18 20:12:27 2018 @@ -235,7 +235,7 @@ public class WildCardRuleElement extends RutaStream stream, RuleElement element, AnnotationFS result) { RutaRuleElement re = (RutaRuleElement) element; RutaMatcher matcher = re.getMatcher(); - + if (matcher instanceof RutaLiteralMatcher) { RutaLiteralMatcher lm = (RutaLiteralMatcher) matcher; IStringExpression expression = lm.getExpression(); @@ -256,7 +256,7 @@ public class WildCardRuleElement extends if (iterator == null) { return null; } - + if (iterator.isValid()) { result = iterator.get(); if (annotation != null && (after && result.getEnd() == annotation.getEnd()) @@ -424,10 +424,10 @@ public class WildCardRuleElement extends if (stream.getDocumentAnnotation().equals(cas.getDocumentAnnotation())) { // no windowing needed if (annotation == null) { - result = cas.getAnnotationIndex(type).iterator(); + result = cas.getAnnotationIndex(type).withSnapshotIterators().iterator(); } else { AnnotationFS pointer = stream.getAnchor(after, annotation); - result = cas.getAnnotationIndex(type).iterator(pointer); + result = cas.getAnnotationIndex(type).withSnapshotIterators().iterator(pointer); if (!result.isValid()) { if (after) { // result.moveToFirst(); Modified: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/WildCard2Test.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/WildCard2Test.java?rev=1849223&r1=1849222&r2=1849223&view=diff ============================================================================== --- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/WildCard2Test.java (original) +++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/WildCard2Test.java Tue Dec 18 20:12:27 2018 @@ -171,4 +171,16 @@ public class WildCard2Test { cas.release(); } + @Test + public void testWildCardBetweenSameTypeWithAction() throws Exception { + String document = "1 a b c 2 d e f 3"; + String script = "NUM{->T1,T1};"; + script += "T1 # t:T1{-> UNMARK(t)};\n"; + + CAS cas = RutaTestUtils.getCAS(document); + Ruta.apply(cas, script); + + RutaTestUtils.assertAnnotationsEquals(cas, 1, 2, "1", "1"); + } + }