Re: Connection validation, auto reconnect FIXED
Re: Connection validation, auto reconnect FIXED
- Subject: Re: Connection validation, auto reconnect FIXED
- From: Chuck Hill <email@hidden>
- Date: Thu, 20 Dec 2012 08:50:06 -0800
See https://github.com/projectwonder/wonder/wiki/Creating-and-submitting-an-acceptable-patch
On 2012-12-20, at 8:14 AM, JR Ruggentaler wrote:
> 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
>
> <PHY242612.patch> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/gvc/practical_webobjects
Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C!
Global Village Consulting ranks 76th in 24th annual PROFIT 200 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden