Commits

jhouse  committed aceea72

Issue number: QUARTZ-316
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: Issue number:
CVS: If this change addresses one or more issues,
CVS: then enter the issue number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to the project by someone else; i.e.,
CVS: they sent us a patch or a set of diffs, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.

git-svn-id: http://svn.opensymphony.com/svn/quartz/branches/b_quartz_1-5-x@30569f7d36a-ea1c-0410-88ea-9fd03e4c9665

  • Participants
  • Parent commits 512b033
  • Branches b_quartz_1-5-x

Comments (0)

Files changed (3)

File src/java/org/quartz/impl/jdbcjobstore/JobStoreCMT.java

             throw new JobPersistenceException("Error recovering jobs: "
                     + e.getMessage(), e);
         } finally {
-            if (conn != null) {
+        	try {
                 releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
                 closeConnection(conn);
-            }
+        	}
         }
     }
 
             throw new JobPersistenceException("Error cleaning volatile data: "
                     + e.getMessage(), e);
         } finally {
-            if (conn != null) {
+        	try {
                 releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-              
+        	} finally {
                 closeConnection(conn);
-            }
+        	}
         }
     }
 
             storeTrigger(conn, ctxt, newTrigger, newJob, false,
                     Constants.STATE_WAITING, false, false);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
             
             storeJob(conn, ctxt, newJob, replaceExisting);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-
-          closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
 
             return removeJob(conn, ctxt, jobName, groupName, true);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
             storeTrigger(conn, ctxt, newTrigger, null, replaceExisting,
                     STATE_WAITING, false, false);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
 
             return removeTrigger(conn, ctxt, triggerName, groupName);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
 
             return replaceTrigger(conn, ctxt, triggerName, groupName, newTrigger);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
     
             
             storeCalendar(conn, ctxt, calName, calendar, replaceExisting, updateTriggers);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, lockOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, lockOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
     public boolean removeCalendar(SchedulingContext ctxt, String calName)
             throws JobPersistenceException {
         Connection conn = getConnection();
+        boolean lockOwner = false;
         try {
             getLockHandler().obtainLock(conn, LOCK_CALENDAR_ACCESS);
+            lockOwner = true;
 
             return removeCalendar(conn, ctxt, calName);
         } finally {
-            releaseLock(conn, LOCK_CALENDAR_ACCESS, true);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, lockOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
 
             pauseTrigger(conn, ctxt, triggerName, groupName);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
 
             pauseTriggerGroup(conn, ctxt, groupName);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
                                                                          .getGroup());
             }
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
                 }
             }
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
 
             resumeTrigger(conn, ctxt, triggerName, groupName);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
 
             resumeTriggerGroup(conn, ctxt, groupName);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
                                                                           .getGroup());
             }
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
                 }
             }
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
 
             pauseAll(conn, ctxt);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
 
             resumeAll(conn, ctxt);
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+                releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+                closeConnection(conn);
+        	}
         }
     }
 
                     "Error acquiring next firable trigger: " + e.getMessage(),
                     e);
         } finally {
-            if (conn != null) {
+        	try {
                 releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-              
+        	} finally {
                 closeConnection(conn);
-            }
+        	}
         }
     }
 
             throw new JobPersistenceException(
                     "Error releasing acquired trigger: " + e.getMessage(), e);
         } finally {
-            if (conn != null) {
+        	try {
                 releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-              
+        	} finally {
                 closeConnection(conn);
-            }
+        	}
         }
     }
 
             throw new JobPersistenceException("TX failure: " + e.getMessage(),
                     e);
         } finally {
-            if (conn != null) {
+        	try {
                 releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-              
+        	} finally {
                 closeConnection(conn);
-            }
+        	}
         }
     }
 
             throw new JobPersistenceException("TX failure: " + e.getMessage(),
                     e);
         } finally {
-            if (conn != null) {
+        	try {
                 releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-              
+        	} finally {
                 closeConnection(conn);
-            }
+        	}
         }
     }
 
             throw new JobPersistenceException("TX failure: " + e.getMessage(),
                     e);
         } finally {
-            if (conn != null) {
+        	try {
                 releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-              
+        	} finally {
                 closeConnection(conn);
-            }
+        	}
         }
 
     }
             throw new JobPersistenceException("TX failure: " + e.getMessage(),
                     e);
         } finally {
-            if (conn != null) {
-              releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-              releaseLock(conn, LOCK_STATE_ACCESS, transStateOwner);
-              
-              closeConnection(conn);
-            }
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+            	try {
+            		releaseLock(conn, LOCK_STATE_ACCESS, transStateOwner);
+            	} finally {
+            		closeConnection(conn);
+            	}
+        	}
         }
 
         firstCheckIn = false;
                     "Could not get connection from DataSource '"
                             + getNonManagedTXDataSource() + "'"); }
 
-            if (!isDontSetNonManagedTXConnectionAutoCommitFalse())
-                    conn.setAutoCommit(false);
-
-            if (isTxIsolationLevelReadCommitted())
-                conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
+            try {
+	            if (!isDontSetNonManagedTXConnectionAutoCommitFalse())
+	                    conn.setAutoCommit(false);
+	
+	            if (isTxIsolationLevelReadCommitted())
+	                conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
+            } catch (SQLException ingore) {
+            } catch (Exception e) {
+            	if(conn != null)
+            		try { conn.close(); } catch(Throwable tt) {}
+            		throw new JobPersistenceException(
+            				"Failure setting up connection.", e);
+            }
 
             return conn;
         } catch (SQLException sqle) {

File src/java/org/quartz/impl/jdbcjobstore/JobStoreSupport.java

                 if(isTxIsolationLevelSerializable())
                   conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
             } catch (SQLException ingore) {
+            } catch (Exception e) {
+            	if(conn != null)
+            		try { conn.close(); } catch(Throwable tt) {}
+            		throw new JobPersistenceException(
+            				"Failure setting up connection.", e);
             }
 
             return conn;

File src/java/org/quartz/impl/jdbcjobstore/JobStoreTX.java

             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, lockOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, lockOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
     public boolean removeCalendar(SchedulingContext ctxt, String calName)
             throws JobPersistenceException {
         Connection conn = getConnection();
+        boolean lockOwner = false;
         try {
-            getLockHandler().obtainLock(conn, LOCK_CALENDAR_ACCESS);
+            getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);
+            lockOwner = true;
 
             boolean removed = removeCalendar(conn, ctxt, calName);
             commitConnection(conn);
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_CALENDAR_ACCESS, true);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, lockOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-          
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+        		closeConnection(conn);
+        	}
         }
     }
 
             rollbackConnection(conn);
             throw e;
         } finally {
-            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
-            releaseLock(conn, LOCK_STATE_ACCESS, transStateOwner);
-            
-            closeConnection(conn);
+        	try {
+        		releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
+        	} finally {
+            	try {
+            		releaseLock(conn, LOCK_STATE_ACCESS, transStateOwner);
+            	} finally {
+            		closeConnection(conn);
+            	}
+        	}
         }
 
         firstCheckIn = false;