The ERXDatabaseContextDelegate class method 
databaseContextShouldHandleDatabaseException(EODatabaseContext databaseContext, 
Throwable throwable) only reconnects to the database if the exception message 
contains the string "_obtainOpenChannel". The string looks like something from 
the early WOAdaptor. I changed the code to make the string a property and 
changed the code to do String.matches() so anyone can configure which messages 
the ERXDatabaseContextDelegate will reconnect on.

How do I submit a patch? The patch is attached.

Here is the code with the change:

    /**

* Provides for a hook to get at the original exceptions from the JDBC

* driver, as opposed to the cooked EOGeneralAdaptorException you get from

* EOF. To see the exceptions trace, set the logger

* er.transaction.adaptor.Exceptions to DEBUG.

*

* @param databaseContext

* @param throwable

*/

public boolean databaseContextShouldHandleDatabaseException(EODatabaseContext 
databaseContext, Throwable throwable) {

if(!reportingError.canEnter(databaseContext)) return true;

try {

if(exLog.isDebugEnabled()) {

exLog.debug("Exception message: '" + throwable.getMessage() + "'");

exLog.debug("Database Exception occured: " + throwable, throwable);

} else if(exLog.isInfoEnabled()) {

exLog.info("Exception message: '" + throwable.getMessage() + "'");

exLog.info("Database Exception occured: " + throwable);

}

String exceptionsRegex = 
ERXProperties.stringForKeyWithDefault(ERX_ADAPTOR_EXCEPTIONS_REGEX, 
ERX_ADAPTOR_EXCEPTIONS_REGEX_DEFAULT);

boolean handled = 
ERXSQLHelper.newSQLHelper(databaseContext).handleDatabaseException(databaseContext,
 throwable);

if(!handled && throwable.getMessage() != null && 
exceptionsRegex.matches(throwable.getMessage())) {

NSArray models = databaseContext.database().models();

for(Enumeration e = models.objectEnumerator(); e.hasMoreElements(); ) {

EOModel model = (EOModel)e.nextElement();

NSDictionary connectionDictionary = model.connectionDictionary();

if (connectionDictionary != null) {

NSMutableDictionary mutableConnectionDictionary = 
connectionDictionary.mutableClone();

mutableConnectionDictionary.setObjectForKey("<password deleted for log>", 
"password");

connectionDictionary = mutableConnectionDictionary;

}

log.info(model.name() + ": " + (connectionDictionary == null ? "No connection 
dictionary!" : connectionDictionary.toString()));

}

if ("JDBC".equals(databaseContext.adaptorContext().adaptor().name())) {

new 
ERXJDBCConnectionAnalyzer(databaseContext.database().adaptor().connectionDictionary());

}

}

//EOEditingContext ec = ERXEC.newEditingContext();

//log.info(NSPropertyListSerialization.stringFromPropertyList(EOUtilities.modelGroup(ec).models().valueForKey("connectionDictionary")));

return !handled;

} finally {

reportingError.leave(databaseContext);

}

}


JR

Attachment: PHY242612.patch
Description: PHY242612.patch

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to