Author: seanahn
Date: Wed Oct 21 01:35:16 2009
New Revision: 827863

URL: http://svn.apache.org/viewvc?rev=827863&view=rev
Log:
Another NullPointerException safe

Modified:
    
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java
    
ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java

Modified: 
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java?rev=827863&r1=827862&r2=827863&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java
 Wed Oct 21 01:35:16 2009
@@ -32,10 +32,10 @@
         if (server.isDeployed(bundleName)) server.undeployProcess(bundleName);
         server.deployProcess(bundleName);
 
-        new Thread() {
+        new Thread("SECOND CLIENT") {
             public void run() {
                 try {
-                    Thread.sleep(2000);
+                    Thread.sleep(3000);
                     String response = 
server.sendRequestFile("http://localhost:8888/ode/processes/OnEventCorrelation/";,
                             bundleName, "testRequest.soap");
                 } catch( Exception e ) {
@@ -44,30 +44,35 @@
             }
         }.start();
 
-        new Thread() {
+        new Thread("THIRD CLIENT") {
           public void run() {
               try {
-                  Thread.sleep(4000);
+                  Thread.sleep(6000);
                   
server.sendRequestFile("http://localhost:8888/ode/processes/OnEventCorrelation/";,
                             bundleName, "testRequest.soap");
               } catch( Exception e ) {
                   fail(e.getMessage());
               } finally {
+                  try {
+                      Thread.sleep(1000);
+                  } catch( Exception e2 ) {
+                  }
                   server.undeployProcess(bundleName);
               }
           }
         }.start();
 
         try {
-               
server.sendRequestFile("http://localhost:8888/ode/processes/OnEventCorrelation/";,
+            Thread.currentThread().setName("FIRST CLIENT");
+            
server.sendRequestFile("http://localhost:8888/ode/processes/OnEventCorrelation/";,
                 bundleName, "testRequest.soap");
-            Thread.sleep(6000);
+            Thread.sleep(9000);
         } catch( Exception e ) {
             fail(e.getMessage());
         }
     }
 
-       public String getODEConfigDir() {
+    public String getODEConfigDir() {
         return HIB_DERBY_CONF_DIR;
-       }
+    }
 }

Modified: 
ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java?rev=827863&r1=827862&r2=827863&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java
 Wed Oct 21 01:35:16 2009
@@ -231,9 +231,14 @@
     }
 
     public <T> T execTransaction(Callable<T> transaction) throws Exception, 
ContextException {
+        TransactionManager txm = _txm;
+        if( txm == null ) {
+            throw new ContextException("Cannot locate the transaction manager; 
the server might be shutting down.");
+        }
+        
         boolean existingTransaction = false;
         try {
-            existingTransaction = _txm.getTransaction() != null;
+            existingTransaction = txm.getTransaction() != null;
         } catch (Exception ex) {
             String errmsg = "Internal Error, could not get current 
transaction.";
             throw new ContextException(errmsg, ex);
@@ -250,7 +255,7 @@
         do {
             try {
                 if (__log.isDebugEnabled()) __log.debug("Beginning a new 
transaction");
-                _txm.begin();
+                txm.begin();
             } catch (Exception e) {
                 String errmsg = "Internal Error, could not begin transaction.";
                 throw new ContextException(errmsg, e);
@@ -263,15 +268,15 @@
                 ex = e;
             } finally {
                 if (ex == null) {
-                    if (__log.isDebugEnabled()) __log.debug("Commiting on " + 
_txm + "...");
+                    if (__log.isDebugEnabled()) __log.debug("Commiting on " + 
txm + "...");
                     try {
-                        _txm.commit();
+                        txm.commit();
                     } catch( Exception e2 ) {
                         ex = e2;
                     }
                 } else {
-                    if (__log.isDebugEnabled()) __log.debug("Rollbacking on " 
+ _txm + "...");
-                    _txm.rollback();
+                    if (__log.isDebugEnabled()) __log.debug("Rollbacking on " 
+ txm + "...");
+                    txm.rollback();
                 }
                 
                 if( ex != null && immediateRetryCount > 0 ) {
@@ -285,12 +290,22 @@
     }
 
     public void setRollbackOnly() throws Exception {
-        _txm.setRollbackOnly();
+        TransactionManager txm = _txm;
+        if( txm == null ) {
+            throw new ContextException("Cannot locate the transaction manager; 
the server might be shutting down.");
+        }
+        
+        txm.setRollbackOnly();
     }
 
     public void registerSynchronizer(final Synchronizer synch) throws 
ContextException {
+        TransactionManager txm = _txm;
+        if( txm == null ) {
+            throw new ContextException("Cannot locate the transaction manager; 
the server might be shutting down.");
+        }
+        
         try {
-            _txm.getTransaction().registerSynchronization(new 
Synchronization() {
+            txm.getTransaction().registerSynchronization(new Synchronization() 
{
 
                 public void beforeCompletion() {
                     synch.beforeCompletion();
@@ -605,8 +620,13 @@
     }
 
     public boolean isTransacted() {
+        TransactionManager txm = _txm;
+        if( txm == null ) {
+            throw new ContextException("Cannot locate the transaction manager; 
the server might be shutting down.");
+        }
+        
         try {
-            Transaction tx = _txm.getTransaction();
+            Transaction tx = txm.getTransaction();
             return (tx != null && tx.getStatus() != 
Status.STATUS_NO_TRANSACTION);
         } catch (SystemException e) {
             throw new ContextException("Internal Error: Could not obtain 
transaction status.");


Reply via email to