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 2017/10/04 15:15:04 UTC
svn commit: r1811087 - in /uima/uv3/uimaj-v3/trunk:
uima-docbook-v3-users-guide/src/docbook/
uimaj-core/src/main/java/org/apache/uima/cas/impl/
uimaj-core/src/main/java/org/apache/uima/jcas/
uimaj-core/src/main/java/org/apache/uima/util/
Author: schor
Date: Wed Oct 4 15:15:03 2017
New Revision: 1811087
URL: http://svn.apache.org/viewvc?rev=1811087&view=rev
Log:
no Jira - use / document protectIndexes with AutoCloseableNoException
Added:
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/AutoCloseableNoException.java
Modified:
uima/uv3/uimaj-v3/trunk/uima-docbook-v3-users-guide/src/docbook/uv3.new_extended_apis.xml
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java
Modified: uima/uv3/uimaj-v3/trunk/uima-docbook-v3-users-guide/src/docbook/uv3.new_extended_apis.xml
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uima-docbook-v3-users-guide/src/docbook/uv3.new_extended_apis.xml?rev=1811087&r1=1811086&r2=1811087&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uima-docbook-v3-users-guide/src/docbook/uv3.new_extended_apis.xml (original)
+++ uima/uv3/uimaj-v3/trunk/uima-docbook-v3-users-guide/src/docbook/uv3.new_extended_apis.xml Wed Oct 4 15:15:03 2017
@@ -320,6 +320,10 @@ public final static String _FeatName_sof
<para>The StringArray class has a new <code>contains(a_string)</code> method.</para>
+ <para>The CAS <code>protectIndexes</code> method returns an instance of AutoClosableNoException which is
+ a subtype where the close method doesn't throw an exception. This allows writing the try-with-resources
+ form without a catch block for Exception.</para>
+
<para>
Sometimes Annotators may log excessively, causing problems in production settings.
Although this could be controlled using logging configuration, sometimes when
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=1811087&r1=1811086&r2=1811087&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Wed Oct 4 15:15:03 2017
@@ -118,6 +118,7 @@ import org.apache.uima.jcas.cas.TOP;
import org.apache.uima.jcas.impl.JCasHashMap;
import org.apache.uima.jcas.impl.JCasImpl;
import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.util.AutoCloseableNoException;
import org.apache.uima.util.Level;
/**
@@ -4500,15 +4501,15 @@ public class CASImpl extends AbstractCas
* protectIndexes
*
* Within the scope of protectIndexes,
- * feature updates are checked, and if found to be a key, and the FS is in a corruptable index,
+ * feature updates are checked, and if found to be a key, and the FS is in a corruptible index,
* then the FS is removed from the indexes (in all necessary views) (perhaps multiple times
* if the FS was added to the indexes multiple times), and this removal is recorded on
* an new instance of FSsTobeReindexed appended to fssTobeAddedback.
*
- * Later, when the protectIndexes is closed, the tobe items are added back to the indies.
+ * Later, when the protectIndexes is closed, the tobe items are added back to the indexes.
*/
@Override
- public AutoCloseable protectIndexes() {
+ public AutoCloseableNoException protectIndexes() {
FSsTobeAddedback r = FSsTobeAddedback.createMultiple(this);
svd.fssTobeAddedback.add(r);
return r;
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java?rev=1811087&r1=1811086&r2=1811087&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java Wed Oct 4 15:15:03 2017
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.Atomi
import org.apache.uima.cas.FSIndexRepository;
import org.apache.uima.jcas.cas.TOP;
+import org.apache.uima.util.AutoCloseableNoException;
/**
@@ -40,7 +41,7 @@ import org.apache.uima.jcas.cas.TOP;
* a) without count
* b) with count
*/
-abstract class FSsTobeAddedback implements AutoCloseable {
+abstract class FSsTobeAddedback implements AutoCloseableNoException {
final static boolean SHOW = false;
final static AtomicInteger removes = new AtomicInteger(0);
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java?rev=1811087&r1=1811086&r2=1811087&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java Wed Oct 4 15:15:03 2017
@@ -253,12 +253,11 @@ public interface JCas extends AbstractCa
/**
* Gets the document annotation. The object returned from this method can be typecast to
- * org.apache.uima.jcas.tcas.DocumentAnnotation
+ * org.apache.uima.jcas.tcas.DocumentAnnotation if that class is loaded (it may not be...)
* <p>
- * The reason that the return type of this method is not DocumentAnnotation is because of problems
- * that arise when using the UIMA Extension ClassLoader to load annotator classes. The
- * DocumentAnnotation type may be defined in the UIMA extension ClassLoader, differently than in
- * the framework ClassLoader.
+ * The reason that the return type of this method is not DocumentAnnotation is because
+ * that class may not be loaded, or it may be loaded under a different class loader
+ * when using the UIMA Extension ClassLoader to load annotator classes.
*
* @return The one instance of the DocumentAnnotation annotation.
* @see org.apache.uima.cas.CAS#getDocumentAnnotation
Added: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/AutoCloseableNoException.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/AutoCloseableNoException.java?rev=1811087&view=auto
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/AutoCloseableNoException.java (added)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/AutoCloseableNoException.java Wed Oct 4 15:15:03 2017
@@ -0,0 +1,33 @@
+/*
+ * 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.util;
+
+/**
+ * protectIndexes returns instances of this, rather than AutoCloseable, to permit
+ * users to use try with resources without a catch for Exception.
+ */
+public interface AutoCloseableNoException extends AutoCloseable {
+
+ /* (non-Javadoc)
+ * @see java.lang.AutoCloseable#close()
+ */
+ @Override
+ void close();
+}