Buggy code:
@ SuppressWarnings ( "serial" ) public abstract class AbstractBrokerFactory implements BrokerFactory { private static final Localizer _loc = Localizer . forPackage ( AbstractBrokerFactory . class ) ; private static final Map < Object , AbstractBrokerFactory > _pool = Collections . synchronizedMap ( new HashMap < Object , AbstractBrokerFactory > ( ) ) ; private final OpenJPAConfiguration _conf ; private transient boolean _readOnly = false ; private transient boolean _closed = false ; private transient RuntimeException _closedException = null ; private Map < Object , Object > _userObjects = null ; private final ReentrantLock _lock = new ReentrantLock ( ) ; private transient ConcurrentHashMap < Object , Collection < Broker > > _transactional = new ConcurrentHashMap < Object , Collection < Broker > > ( ) ; private transient Set < Broker > _brokers ; private transient Collection < String > _pcClassNames = null ; private transient Collection < ClassLoader > _pcClassLoaders = null ; private transient boolean _persistentTypesLoaded = false ; private transient Map < Object , Class < ? > [ ] > _lifecycleListeners = null ; private transient List _transactionListeners = null ; private Object _poolKey ; private WriteBehindCallback _writeBehindCallback ; protected static Object toPoolKey ( Map map ) { } protected static void pool ( Object key , AbstractBrokerFactory factory ) { } public static AbstractBrokerFactory getPooledFactoryForKey ( Object key ) { } protected AbstractBrokerFactory ( OpenJPAConfiguration config ) { } public OpenJPAConfiguration getConfiguration ( ) { } public Broker newBroker ( ) { } public Broker newBroker ( String user , String pass ) { } public Broker newBroker ( boolean managed , int connRetainMode ) { } public Broker newBroker ( String user , String pass , boolean managed , int connRetainMode ) { } public Broker newBroker ( String user , String pass , boolean managed , int connRetainMode , boolean findExisting ) { } void initializeBroker ( boolean managed , int connRetainMode , BrokerImpl broker , boolean fromDeserialization ) { } protected void addListeners ( BrokerImpl broker ) { } private void loadPersistentTypes ( ClassLoader envLoader ) { } private boolean needsSub ( Class cls ) { } public void addLifecycleListener ( Object listener , Class [ ] classes ) { } public void removeLifecycleListener ( Object listener ) { } public void addTransactionListener ( Object listener ) { } public void removeTransactionListener ( Object listener ) { } public boolean isClosed ( ) { } public void close ( ) { } public Map < String , Object > getProperties ( ) { } public Set < String > getSupportedProperties ( ) { } public Object getUserObject ( Object key ) { } public Object putUserObject ( Object key , Object val ) { } public void lock ( ) { } public void unlock ( ) { } protected Object readResolve ( ) throws ObjectStreamException { } private Set newBrokerSet ( ) { } protected abstract StoreManager newStoreManager ( ) { } protected BrokerImpl findBroker ( String user , String pass , boolean managed ) { } protected BrokerImpl newBrokerImpl ( String user , String pass ) { } protected void setup ( ) { } protected BrokerImpl findTransactionalBroker ( String user , String pass ) { } protected void configureBroker ( BrokerImpl broker ) { } public void makeReadOnly ( ) { } protected Object getFactoryInitializationBanner ( ) { } private void assertOpen ( ) { } private void assertNoActiveTransaction ( ) { } boolean syncWithManagedTransaction ( BrokerImpl broker , boolean begin ) { } public Collection < Broker > getOpenBrokers ( ) { } protected void releaseBroker ( BrokerImpl broker ) { } public Object getPoolKey ( ) { } void setPoolKey ( Object key ) { } private class RemoveTransactionSync implements Synchronization { private final Object _trans ; public RemoveTransactionSync ( Object trans ) { } public void beforeCompletion ( ) { } public void afterCompletion ( int status ) { } } private Collection getPcClassLoaders ( ) { } protected DelegatingStoreManager createDelegatingStoreManager ( ) { } protected void initWriteBehindCallback ( ) { WriteBehindCache cache = _conf . getWriteBehindCacheManagerInstance ( ) . getSystemWriteBehindCache ( ) ; if ( cache != null ) { if ( ( ( _conf . getDataCacheManagerInstance ( ) . getSystemDataCache ( ) ) == null ) || ( ( _conf . getWriteBehindCallbackInstance ( ) ) == null ) ) { throw new WriteBehindConfigurationException ( ) ; } <START_BUG> Broker broker = newBroker ( _conf . getConnectionUserName ( ) , _conf . getConnectionPassword ( ) , _conf . isConnectionFactoryModeManaged ( ) , _conf . getConnectionRetainModeConstant ( ) , false ) ; <END_BUG> _transactional . remove ( broker ) ; _brokers . remove ( broker ) ; _writeBehindCallback = _conf . getWriteBehindCallbackInstance ( ) ; _writeBehindCallback . initialize ( broker , cache ) ; new Thread ( _writeBehindCallback ) . start ( ) ; } } }

Fix:
Broker broker = newBroker ( _conf . getConnectionUserName ( ) , _conf . getConnectionPassword ( ) , false , _conf . getConnectionRetainModeConstant ( ) , false ) ;