Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 8989 invoked from network); 8 Nov 2003 17:35:00 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 8 Nov 2003 17:35:00 -0000 Received: (qmail 85711 invoked by uid 500); 8 Nov 2003 17:34:53 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 85480 invoked by uid 500); 8 Nov 2003 17:34:51 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 85439 invoked from network); 8 Nov 2003 17:34:51 -0000 Received: from unknown (HELO mail.gmx.net) (213.165.64.20) by daedalus.apache.org with SMTP; 8 Nov 2003 17:34:51 -0000 Received: (qmail 32107 invoked by uid 65534); 8 Nov 2003 17:34:53 -0000 Received: from adsl-62-167-86-10.adslplus.ch (EHLO gmx.ch) (62.167.86.10) by mail.gmx.net (mp014) with SMTP; 08 Nov 2003 18:34:53 +0100 X-Authenticated: #15507884 Message-ID: <3FAD290B.9090006@gmx.ch> Date: Sat, 08 Nov 2003 18:34:03 +0100 From: Jakob Braeuchi User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: OJB Developers List Subject: Re: Better error for ClassCastException in ProxyHelper.getRealObject(Object) References: <20031106162841.GA20549@mail.oculan.com> In-Reply-To: <20031106162841.GA20549@mail.oculan.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N hi justis, scarab does have some problems thats's why i stopped using it :( anyway, i added the additional catch of ClassCastException. hth jakob Justis Peters wrote: > Hi All, > > I'm not sure if this is the right place to send this. Yet again, an issue I submitted to scarab ended up getting assigned the same ID as an existing bug, and I can't get back to it. Anyhow, here's the issue: > > I recommend that we modify ProxyHelper.getRealObject(Object) to more gracefully handle the case where someone uses their own implementation of java.lang.reflect.InvocationHandler instead of the expected org.apache.ojb.broker.accesslayer.IndirectionHandler. Here is the line that was causing my ClassCastExcpetion: > handler = (IndirectionHandler) Proxy.getInvocationHandler(objectOrProxy); > > Obviously, the expectation is that we should be using an IndirectionHandler. If that is the case, we should either check ahead of time (with "instanceof") or we should catch the ClassCastException, log it, and throw a PersistenceBrokerException: > > try > { > handler = (IndirectionHandler) Proxy.getInvocationHandler(objectOrProxy); > return handler.getRealSubject(); > } > catch (ClassCastException e) > { > log.error("The InvocationHandler for the provided Proxy was not an instance of org.apache.ojb.broker.accesslayer.IndirectionHandler."); > throw new PersistenceBrokerException("The InvocationHandler for the provided Proxy was not an instance of org.apache.ojb.broker.accesslayer.IndirectionHandler.", e); > } > catch (IllegalArgumentException e) > { > log.error("Could not retrieve real object for given Proxy: "+objectOrProxy); > throw new PersistenceBrokerException(e); > } > catch (PersistenceBrokerException e) > { > log.error("Could not retrieve real object for given Proxy: "+objectOrProxy); > throw e; > } > > > This isn't a really big deal. The only reason I ask for it is because it would have saved me a decent amount of time if I had received an error message of that sort the first time around. > > Thanks in advance for your consideration! > > Sincerely, > Justis Peters > Oculan Corp. > www.oculan.com > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org > For additional commands, e-mail: ojb-dev-help@db.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org