Author: cwiklik
Date: Mon Mar  5 18:49:21 2012
New Revision: 1297163

URL: http://svn.apache.org/viewvc?rev=1297163&view=rev
Log:
UIMA-2377 Exit the jvm on java Error

Modified:
    
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaAsThreadFactory.java

Modified: 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaAsThreadFactory.java
URL: 
http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaAsThreadFactory.java?rev=1297163&r1=1297162&r2=1297163&view=diff
==============================================================================
--- 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaAsThreadFactory.java
 (original)
+++ 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaAsThreadFactory.java
 Mon Mar  5 18:49:21 2012
@@ -117,18 +117,17 @@ public class UimaAsThreadFactory impleme
             // TaskExecutor is terminated.
             r.run();
           } catch (Throwable e) {
-                 UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, 
getClass().getName(),
+            //   try to log. If this is OOM, logging may not succeed and we
+            //   get another OOM.
+            try {
+              UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, 
getClass().getName(),
                       "UimaAsThreadFactory", 
UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                       "UIMAEE_exception__WARNING", e);
-                 if ( controller != null ) {
-                 Exception ex;
-                 if ( e instanceof Exception ) {
-                         ex = (Exception)e;
-                 } else {
-                         ex = new Exception(e);
-                 }
-                 controller.notifyListenersWithInitializationStatus(ex);
-                 } 
+              System.out.println("Exiting UIMA AS Process Due to Uncaught 
Exception");
+            } catch( Throwable t ) {
+               // Failed during logging. We are tight on memory. Just exit 
+            }
+            System.exit(-1);
             return;
           } finally {
               if ( controller instanceof 
PrimitiveAnalysisEngineController_impl ) {
@@ -140,7 +139,11 @@ public class UimaAsThreadFactory impleme
                                                "UimaAsThreadFactory.run()", 
UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                                                
"UIMAEE_ae_instance_destroy_called__INFO", new Object[] 
{controller.getComponentName(),Thread.currentThread().getId()});
                                  if ( latchToCountNumberOfTerminatedThreads != 
null ) {
-                  latchToCountNumberOfTerminatedThreads.countDown();
+                  synchronized( latchToCountNumberOfTerminatedThreads ) {
+                    latchToCountNumberOfTerminatedThreads.countDown();
+                    System.out.println(".................... 
Thread:"+Thread.currentThread().getId()+" CountDownLatch 
Value:"+latchToCountNumberOfTerminatedThreads.getCount());
+                    System.out.flush();
+                  }
                                  }
               }
           }


Reply via email to