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/06/29 13:43:56 UTC

[uima-uimaj] 01/01: [UIMA-6249] avoid sync in getJCasRegisteredType

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

schor pushed a commit to branch UIMA-6249_getJCasRegisteredType
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git

commit ad579f5f18b969da3fde1d1e4b1cb9d5d65a71a4
Author: Marshall Schor <ms...@schor.com>
AuthorDate: Mon Jun 29 08:43:29 2020 -0500

    [UIMA-6249] avoid sync in getJCasRegisteredType
---
 .../src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java      | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java b/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
index 8b10dee..03a7c47 100644
--- a/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
+++ b/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
@@ -2620,7 +2620,11 @@ public class TypeSystemImpl implements TypeSystem, TypeSystemMgr, LowLevelTypeSy
    * @return - the type impl associated with that JCas cover class
    */
   public TypeImpl getJCasRegisteredType(int i) {
-    TypeImpl ti;
+    // first try without sync lock https://issues.apache.org/jira/browse/UIMA-6249
+    TypeImpl ti = (i >= jcasRegisteredTypes.size()) ? null : jcasRegisteredTypes.get(i);
+    if (ti != null) {
+      return ti;
+    }
     synchronized(jcasRegisteredTypes) {
       ti = (i >= jcasRegisteredTypes.size()) ? null : jcasRegisteredTypes.get(i);
     }