Good catch; I wrote that before the finalization changes went in. Changing...
-Patrick -- Patrick Linskey BEA Systems, Inc. _______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. > -----Original Message----- > From: Abe White > Sent: Wednesday, February 28, 2007 11:41 AM > To: open-jpa-dev@incubator.apache.org > Subject: Re: svn commit: r512906 - in > /incubator/openjpa/trunk: > openjpa-kernel/src/main/java/org/apache/openjpa/conf/ > openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ > openjpa-project/src/doc/manual/ > > > > + public Object newInstance(String clsName, Class type, > > Configuration conf, > > + boolean fatal) { > > + if (BrokerImpl.class.getName().equals(clsName)) { > > + // This is not synchronized. If there are concurrent > > invocations > > + // while _templateBroker is null, we'll just end up > > with extra > > + // template brokers, which will get safely garbage > > collected. > > + if (_templateBroker == null) > > + _templateBroker = (BrokerImpl) super.newInstance( > > + clsName, type, conf, fatal); > > + try { > > + return _templateBroker.clone(); > > + } catch (CloneNotSupportedException e) { > > + throw new InternalException(e); > > + } > > + } else { > > + return super.newInstance(clsName, type, conf, fatal); > > + } > > + } > > +} > > Don't we want FinalizingBrokerImpls to clone too? And possible > subclasses? How about: > > Cloneable _templateBroker = null; > boolean _templateTried = false; > > ... > > if (!_templateTried) { > Object broker = super.newInstance(clsName, type, conf, false); > if (broker instanceof Cloneable) > _templateBroker = (Cloneable) broker; > _templateTried = true; > } > > if (_templateBroker != null) { > return _templateBroker.clone... > } > return super.newInstance... > > And for completeness we should set _templateTrid to false on set/ > setString. > ______________________________________________________________ > _________ > Notice: This email message, together with any attachments, > may contain > information of BEA Systems, Inc., its subsidiaries and > affiliated > entities, that may be confidential, proprietary, > copyrighted and/or > legally privileged, and is intended solely for the use of the > individual > or entity named in this message. If you are not the intended > recipient, > and have received this message in error, please immediately > return this > by email and then delete it. >