You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2020/01/09 19:02:40 UTC

[uima-uimaj] branch bug/UIMA-6168-protect-indexes-v2 created (now d47f085)

This is an automated email from the ASF dual-hosted git repository.

schor pushed a change to branch bug/UIMA-6168-protect-indexes-v2
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git.


      at d47f085  [UIMA-6168] copy change from v3, add test

This branch includes the following new commits:

     new d47f085  [UIMA-6168] copy change from v3, add test

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[uima-uimaj] 01/01: [UIMA-6168] copy change from v3, add test

Posted by sc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

schor pushed a commit to branch bug/UIMA-6168-protect-indexes-v2
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git

commit d47f0857578ad7f74b8344de555f3b3adb14e96d
Author: Marshall Schor <ms...@schor.com>
AuthorDate: Thu Jan 9 14:02:13 2020 -0500

    [UIMA-6168] copy change from v3, add test
---
 .../java/org/apache/uima/cas/impl/CASImpl.java     |  39 +-
 .../org/apache/uima/cas/impl/FSsTobeAddedback.java | 552 ++++++++++-----------
 .../org/apache/uima/cas/impl/ProtectIndexTest.java |  58 +++
 3 files changed, 358 insertions(+), 291 deletions(-)

diff --git a/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java b/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
index ba2f111..568c3d0 100644
--- a/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
+++ b/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
@@ -5406,9 +5406,9 @@ public Iterator<CAS> getViewIterator(String localViewNamePrefix) {
     return r;
   }
   
-  void dropProtectIndexesLevel () {
-    svd.fssTobeAddedback.remove(svd.fssTobeAddedback.size() -1);
-  }
+//  void dropProtectIndexesLevel () {
+//    svd.fssTobeAddedback.remove(svd.fssTobeAddedback.size() -1);
+//  }
   
   /**
    * This design is to support normal operations where the
@@ -5432,18 +5432,27 @@ public Iterator<CAS> getViewIterator(String localViewNamePrefix) {
    * @param addbacks
    */
   void addbackModifiedFSs (FSsTobeAddedback addbacks) {
-    final List<FSsTobeAddedback> s =  svd.fssTobeAddedback;
-    if (s.get(s.size() - 1) == addbacks) {
-      s.remove(s.size());
-    } else {
-      int pos = s.indexOf(addbacks);
-      if (pos >= 0) {
-        for (int i = s.size() - 1; i > pos; i--) {
-          FSsTobeAddedback toAddBack = s.remove(i);
-          toAddBack.addback();
-        }
-      }      
-    }
+    final List<FSsTobeAddedback> listOfAddbackInfos =  svd.fssTobeAddedback;
+    
+    // case 1: the addbacks are the last in the stack:
+    if (listOfAddbackInfos.get(listOfAddbackInfos.size() - 1) == addbacks) {
+      listOfAddbackInfos.remove(listOfAddbackInfos.size() - 1);
+      addbacks.addback();
+      return;
+    } 
+     
+    int pos = listOfAddbackInfos.indexOf(addbacks);
+    
+    // case 2: the addbacks are in the stack, but there are others following it
+    if (pos >= 0) {
+      for (int i = listOfAddbackInfos.size() - 1; i >= pos; i--) {
+        FSsTobeAddedback toAddBack = listOfAddbackInfos.remove(i);
+        toAddBack.addback();
+      }
+      return;
+    }      
+    
+    // case 3: the addbacks are not in the list - just remove them, ignore the list
     addbacks.addback();
   }
   
diff --git a/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java b/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java
index 994f58d..0342c32 100644
--- a/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java
+++ b/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java
@@ -1,276 +1,276 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.uima.cas.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.uima.cas.FSIndexRepository;
-import org.apache.uima.internal.util.IntVector;
-
-
-/**
- * Record information on what was removed, from which view, and (optionally) how many times.
- * 
- * 4 varieties:
- *   1) for a single FS
- *      a) without count
- *      b) with count
- *   2) for multiple FSs
- *      a) without count
- *      b) with count   
- */
-abstract class FSsTobeAddedback implements AutoCloseable {
-  
-  final static boolean SHOW = false;
-  final static AtomicInteger removes = new AtomicInteger(0);
-  
-  /**
-   * does an add back if needed 
-   */
-  public void close() { addback();}
-
-  protected void logPart(FSIndexRepository view) {
-    System.out.format("%,d tobeReindexed: view: %s", removes.incrementAndGet(), view);
-  }
-  
-  protected void log(FSIndexRepositoryImpl view, int count) {
-    if (SHOW) {
-      logPart(view);
-      System.out.format(",  count = %d%n", count);
-    }
-  }
-  
-  private void logPart(int fsAddr, FSIndexRepositoryImpl view) {
-    log(view);
-    System.out.format(",  fsAddr = %,d", fsAddr);
-  }
-  
-  protected void log(int fsAddr, FSIndexRepositoryImpl view, int count) {
-    if (SHOW) {
-      log(fsAddr, view);
-      System.out.format(",  count = %d%n", count);
-    }
-  }
-
-  protected void log(FSIndexRepositoryImpl view) {
-    if (SHOW) {
-      logPart(view);
-      System.out.println();
-    }
-  }
-  
-  protected void log(int fsAddr, FSIndexRepositoryImpl view) {
-    if (SHOW) {
-      logPart(fsAddr, view);
-      System.out.println();
-    }
-  }
-  
-  void recordRemove(FSIndexRepositoryImpl view)                        {throw new UnsupportedOperationException();}
-  void recordRemove(FSIndexRepositoryImpl view, int count)             {
-    if (count == 1) {
-      recordRemove(view);
-    } else {
-      throw new UnsupportedOperationException();
-    }
-  }
-  void recordRemove(int fsAddr, FSIndexRepositoryImpl view)            {throw new UnsupportedOperationException();}
-  void recordRemove(int fsAddr, FSIndexRepositoryImpl view, int count) {
-    if (count == 1) {
-      recordRemove(fsAddr, view);
-    } else { 
-      throw new UnsupportedOperationException();
-    }
-  }
-  
-  void addback()                                                       {throw new UnsupportedOperationException();}
-  void addback(int fsAddr)                                             {throw new UnsupportedOperationException();}
-  abstract void clear();
-
-  static class FSsTobeAddedbackSingle extends FSsTobeAddedback {
-    final List<FSIndexRepositoryImpl> views = new ArrayList<FSIndexRepositoryImpl>();
-    
-    @Override
-    void recordRemove(FSIndexRepositoryImpl view) {
-      log(view);
-      views.add(view);
-    }
-    
-    @Override
-    void recordRemove(int fsAddr, FSIndexRepositoryImpl view) {
-      recordRemove(view);
-    }
-    
-    @Override
-    void recordRemove(int fsAddr, FSIndexRepositoryImpl view, int count) {
-      if (count != 1) {
-        throw new RuntimeException("internal error");
-      }
-      recordRemove(view);
-    }
-          
-    @Override
-    void addback(int fsAddr) {
-      for (FSIndexRepositoryImpl ir : views) {
-        ir.ll_addback(fsAddr, 1);
-      }
-      clear();
-    }
-    
-    @Override
-    void clear() {
-      views.clear();     
-//      if (SHOW) removes.set(0);
-    }
-  }
-  
-  static class FSsTobeAddedbackSingleCounts extends FSsTobeAddedbackSingle {
-    final IntVector counts = new IntVector(4);
-    
-    @Override
-    void recordRemove(FSIndexRepositoryImpl view, int count) {
-      log(view, count);
-      views.add(view);
-      counts.add(count);
-    }
-          
-    @Override
-    void addback(int fsAddr) {
-      int i = 0;
-      for (FSIndexRepositoryImpl ir : views) {
-        ir.ll_addback(fsAddr, counts.get(i++));
-      }
-      clear();
-    }
-    
-    @Override
-    void clear() {
-      views.clear();
-      counts.removeAllElementsAdjustSizeDown();
-//      if (SHOW) removes.set(0);
-    }
-
-  }
-
-  static class FSsTobeAddedbackMultiple extends FSsTobeAddedback {
-  
-    // impl note: for support of allow_multiple_add_to_indexes, each entry is two List elements:
-    //   the count
-    //   the ref to the view
-    final Map<Integer, List<?>> fss2views = new HashMap<Integer, List<?>>();
-    
-    final CASImpl cas;
-    
-    FSsTobeAddedbackMultiple(CASImpl cas) {
-      this.cas = cas;
-    }
-    
-    @Override
-    void recordRemove(int fsAddr, FSIndexRepositoryImpl view) {
-      log(fsAddr, view);
-      @SuppressWarnings("unchecked")
-      List<FSIndexRepositoryImpl> irList = (List<FSIndexRepositoryImpl>) fss2views.get(fsAddr);
-      if (null == irList) {
-        fss2views.put(fsAddr,  irList = new ArrayList<FSIndexRepositoryImpl>());
-      }
-      irList.add(view);
-    }
-          
-    @Override
-    void addback() {
-      for (Entry<Integer, List<?>> e : fss2views.entrySet()) {
-        final int fsAddr = e.getKey();
-        @SuppressWarnings("unchecked")
-        final List<FSIndexRepositoryImpl> views = (List<FSIndexRepositoryImpl>) e.getValue();
-        for (FSIndexRepositoryImpl ir : views) {
-          ir.ll_addback(fsAddr, 1);
-        }
-      }
-      clear();
-      cas.dropProtectIndexesLevel();
-    }
-    
-    @Override
-    void clear() {
-      fss2views.clear();
-//      if (SHOW) removes.set(0);
-    }
-  }
-  
-  static class FSsTobeAddedbackMultipleCounts extends FSsTobeAddedbackMultiple {
-     
-    public FSsTobeAddedbackMultipleCounts(CASImpl cas) {
-      super(cas);
-    }
-    
-    @Override
-    void recordRemove(int fsAddr, FSIndexRepositoryImpl view, int count) {
-      log(fsAddr, view, count);
-      @SuppressWarnings("unchecked")
-      List<Object> countsAndViews = (List<Object>) fss2views.get(fsAddr);
-      if (null == countsAndViews) {
-        fss2views.put(fsAddr,  countsAndViews = new ArrayList<Object>());
-      }
-      countsAndViews.add(count);
-      countsAndViews.add(view);
-    }
-    
-    @Override
-    void addback() {
-      for (Entry<Integer, List<?>> e : fss2views.entrySet()) {
-        final int fsAddr = e.getKey();
-        final List<?> countsAndViews = e.getValue();
-      
-        for (int i = 0; i < countsAndViews.size(); ) {
-          final int count = (Integer) countsAndViews.get(i++);
-          final FSIndexRepositoryImpl view = (FSIndexRepositoryImpl) countsAndViews.get(i++);
-          view.ll_addback(fsAddr, count);
-        }  
-      }
-      clear();
-    }
-    
-    @Override
-    void clear() {
-      fss2views.clear();
-//      if (SHOW) removes.set(0);
-    }
-  }
-  
-  /**
-   * @return an impl of this class
-   */
-  public static FSsTobeAddedback createSingle() {
-    return (FSIndexRepositoryImpl.IS_ALLOW_DUP_ADD_2_INDEXES) ?
-        new FSsTobeAddedbackSingleCounts() :
-        new FSsTobeAddedbackSingle();
-  }
-  
-  public static FSsTobeAddedback createMultiple(CASImpl cas) {
-    return (FSIndexRepositoryImpl.IS_ALLOW_DUP_ADD_2_INDEXES) ?
-       new FSsTobeAddedbackMultipleCounts(cas) :
-       new FSsTobeAddedbackMultiple(cas);
-  }
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.cas.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.uima.cas.FSIndexRepository;
+import org.apache.uima.internal.util.IntVector;
+
+
+/**
+ * Record information on what was removed, from which view, and (optionally) how many times.
+ * 
+ * 4 varieties:
+ *   1) for a single FS
+ *      a) without count
+ *      b) with count
+ *   2) for multiple FSs
+ *      a) without count
+ *      b) with count   
+ */
+abstract class FSsTobeAddedback implements AutoCloseable {
+  
+  final static boolean SHOW = false;
+  final static AtomicInteger removes = new AtomicInteger(0);
+  
+  /**
+   * does an add back if needed 
+   */
+  public void close() { addback();}
+
+  protected void logPart(FSIndexRepository view) {
+    System.out.format("%,d tobeReindexed: view: %s", removes.incrementAndGet(), view);
+  }
+  
+  protected void log(FSIndexRepositoryImpl view, int count) {
+    if (SHOW) {
+      logPart(view);
+      System.out.format(",  count = %d%n", count);
+    }
+  }
+  
+  private void logPart(int fsAddr, FSIndexRepositoryImpl view) {
+    log(view);
+    System.out.format(",  fsAddr = %,d", fsAddr);
+  }
+  
+  protected void log(int fsAddr, FSIndexRepositoryImpl view, int count) {
+    if (SHOW) {
+      log(fsAddr, view);
+      System.out.format(",  count = %d%n", count);
+    }
+  }
+
+  protected void log(FSIndexRepositoryImpl view) {
+    if (SHOW) {
+      logPart(view);
+      System.out.println();
+    }
+  }
+  
+  protected void log(int fsAddr, FSIndexRepositoryImpl view) {
+    if (SHOW) {
+      logPart(fsAddr, view);
+      System.out.println();
+    }
+  }
+  
+  void recordRemove(FSIndexRepositoryImpl view)                        {throw new UnsupportedOperationException();}
+  void recordRemove(FSIndexRepositoryImpl view, int count)             {
+    if (count == 1) {
+      recordRemove(view);
+    } else {
+      throw new UnsupportedOperationException();
+    }
+  }
+  void recordRemove(int fsAddr, FSIndexRepositoryImpl view)            {throw new UnsupportedOperationException();}
+  void recordRemove(int fsAddr, FSIndexRepositoryImpl view, int count) {
+    if (count == 1) {
+      recordRemove(fsAddr, view);
+    } else { 
+      throw new UnsupportedOperationException();
+    }
+  }
+  
+  void addback()                                                       {throw new UnsupportedOperationException();}
+  void addback(int fsAddr)                                             {throw new UnsupportedOperationException();}
+  abstract void clear();
+
+  static class FSsTobeAddedbackSingle extends FSsTobeAddedback {
+    final List<FSIndexRepositoryImpl> views = new ArrayList<FSIndexRepositoryImpl>();
+    
+    @Override
+    void recordRemove(FSIndexRepositoryImpl view) {
+      log(view);
+      views.add(view);
+    }
+    
+    @Override
+    void recordRemove(int fsAddr, FSIndexRepositoryImpl view) {
+      recordRemove(view);
+    }
+    
+    @Override
+    void recordRemove(int fsAddr, FSIndexRepositoryImpl view, int count) {
+      if (count != 1) {
+        throw new RuntimeException("internal error");
+      }
+      recordRemove(view);
+    }
+          
+    @Override
+    void addback(int fsAddr) {
+      for (FSIndexRepositoryImpl ir : views) {
+        ir.ll_addback(fsAddr, 1);
+      }
+      clear();
+    }
+    
+    @Override
+    void clear() {
+      views.clear();     
+//      if (SHOW) removes.set(0);
+    }
+  }
+  
+  static class FSsTobeAddedbackSingleCounts extends FSsTobeAddedbackSingle {
+    final IntVector counts = new IntVector(4);
+    
+    @Override
+    void recordRemove(FSIndexRepositoryImpl view, int count) {
+      log(view, count);
+      views.add(view);
+      counts.add(count);
+    }
+          
+    @Override
+    void addback(int fsAddr) {
+      int i = 0;
+      for (FSIndexRepositoryImpl ir : views) {
+        ir.ll_addback(fsAddr, counts.get(i++));
+      }
+      clear();
+    }
+    
+    @Override
+    void clear() {
+      views.clear();
+      counts.removeAllElementsAdjustSizeDown();
+//      if (SHOW) removes.set(0);
+    }
+
+  }
+
+  static class FSsTobeAddedbackMultiple extends FSsTobeAddedback {
+  
+    // impl note: for support of allow_multiple_add_to_indexes, each entry is two List elements:
+    //   the count
+    //   the ref to the view
+    final Map<Integer, List<?>> fss2views = new HashMap<Integer, List<?>>();
+    
+    final CASImpl cas;
+    
+    FSsTobeAddedbackMultiple(CASImpl cas) {
+      this.cas = cas;
+    }
+    
+    @Override
+    void recordRemove(int fsAddr, FSIndexRepositoryImpl view) {
+      log(fsAddr, view);
+      @SuppressWarnings("unchecked")
+      List<FSIndexRepositoryImpl> irList = (List<FSIndexRepositoryImpl>) fss2views.get(fsAddr);
+      if (null == irList) {
+        fss2views.put(fsAddr,  irList = new ArrayList<FSIndexRepositoryImpl>());
+      }
+      irList.add(view);
+    }
+          
+    @Override
+    void addback() {
+      for (Entry<Integer, List<?>> e : fss2views.entrySet()) {
+        final int fsAddr = e.getKey();
+        @SuppressWarnings("unchecked")
+        final List<FSIndexRepositoryImpl> views = (List<FSIndexRepositoryImpl>) e.getValue();
+        for (FSIndexRepositoryImpl ir : views) {
+          ir.ll_addback(fsAddr, 1);
+        }
+      }
+      clear();
+//      cas.dropProtectIndexesLevel();
+    }
+    
+    @Override
+    void clear() {
+      fss2views.clear();
+//      if (SHOW) removes.set(0);
+    }
+  }
+  
+  static class FSsTobeAddedbackMultipleCounts extends FSsTobeAddedbackMultiple {
+     
+    public FSsTobeAddedbackMultipleCounts(CASImpl cas) {
+      super(cas);
+    }
+    
+    @Override
+    void recordRemove(int fsAddr, FSIndexRepositoryImpl view, int count) {
+      log(fsAddr, view, count);
+      @SuppressWarnings("unchecked")
+      List<Object> countsAndViews = (List<Object>) fss2views.get(fsAddr);
+      if (null == countsAndViews) {
+        fss2views.put(fsAddr,  countsAndViews = new ArrayList<Object>());
+      }
+      countsAndViews.add(count);
+      countsAndViews.add(view);
+    }
+    
+    @Override
+    void addback() {
+      for (Entry<Integer, List<?>> e : fss2views.entrySet()) {
+        final int fsAddr = e.getKey();
+        final List<?> countsAndViews = e.getValue();
+      
+        for (int i = 0; i < countsAndViews.size(); ) {
+          final int count = (Integer) countsAndViews.get(i++);
+          final FSIndexRepositoryImpl view = (FSIndexRepositoryImpl) countsAndViews.get(i++);
+          view.ll_addback(fsAddr, count);
+        }  
+      }
+      clear();
+    }
+    
+    @Override
+    void clear() {
+      fss2views.clear();
+//      if (SHOW) removes.set(0);
+    }
+  }
+  
+  /**
+   * @return an impl of this class
+   */
+  public static FSsTobeAddedback createSingle() {
+    return (FSIndexRepositoryImpl.IS_ALLOW_DUP_ADD_2_INDEXES) ?
+        new FSsTobeAddedbackSingleCounts() :
+        new FSsTobeAddedbackSingle();
+  }
+  
+  public static FSsTobeAddedback createMultiple(CASImpl cas) {
+    return (FSIndexRepositoryImpl.IS_ALLOW_DUP_ADD_2_INDEXES) ?
+       new FSsTobeAddedbackMultipleCounts(cas) :
+       new FSsTobeAddedbackMultiple(cas);
+  }
+}
+
diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/impl/ProtectIndexTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/impl/ProtectIndexTest.java
new file mode 100644
index 0000000..c545a99
--- /dev/null
+++ b/uimaj-core/src/test/java/org/apache/uima/cas/impl/ProtectIndexTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.cas.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.Assert;
+import junit.framework.TestCase;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.TaeDescription;
+import org.apache.uima.analysis_engine.TextAnalysisEngine;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.resource.Resource;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.test.junit_extension.JUnitExtension;
+import org.apache.uima.util.CasCreationUtils;
+import org.apache.uima.util.XMLInputSource;
+
+
+public class ProtectIndexTest extends TestCase {
+
+  public void testProtectIndex() throws CASException, ResourceInitializationException {
+    JCas jcas = CasCreationUtils.createCas((TypeSystemDescription)null, null, null).getJCas();
+    
+    Annotation a = new Annotation(jcas, 0, 2);
+    
+    jcas.protectIndexes(() ->
+      { a.setBegin(a.getBegin() + 1);
+      });
+      
+    assertEquals(a.getBegin(),  1);  
+  }
+}