Idan -
Perhaps you could remove the StateManager from each Entity before you
serialize it, then put the SM back when you're done? I'm not entirely sure
the implications of doing this when/if you have fields which are proxied
types (ie: Collection, Map).
This is just off the top of my head, so take it as direction.... not an
answer. :-)
public Collection<Exception> flush(Collection<OpenJPAStateManager>
states) {
for (OpenJPAStateManager sm : states) {
PersistenceCapable pc = sm.getPersistenceCapable();
pc.pcReplaceStateManager(null);
// serialize here
pc.pcReplaceStateManager(sm);
}
Thanks,
Rick
On Sun, Nov 21, 2010 at 7:17 AM, idan <[email protected]> wrote:
>
> Hey,
>
> While implementing my own StoreManager.flush method i encountered a
> deadlock
> caused by the following situation:
> My flush method creates a second thread which serializes the persistent
> entities which leads to the following stack trace:
> Daemon Thread [Thread2] (Suspended)
> Unsafe.park(boolean, long) line: not available [native method]
> LockSupport.park(Object) line: not available
>
>
> ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).parkAndCheckInterrupt()
> line: not available
>
>
> ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquireQueued(AbstractQueuedSynchronizer$Node,
> int) line: not available
> ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquire(int)
> line:
> not available
> ReentrantLock$NonfairSync.lock() line: not available
> ReentrantLock.lock() line: not available
> FinalizingBrokerImpl(BrokerImpl).lock() line: 4366
> FinalizingBrokerImpl(BrokerImpl).beginOperation(boolean) line: 1893
> FinalizingBrokerImpl(BrokerImpl).isActive() line: 1865
> DetachManager.flushDirty(StateManagerImpl) line: 225
> DetachManager.preSerialize(StateManagerImpl) line: 92
> StateManagerImpl.serializing() line: 1454
> Pet.pcSerializing() line: not available
> Pet.writeObject(ObjectOutputStream) line: not available
> GeneratedMethodAccessor14.invoke(Object, Object[]) line: not
> available
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not
> available
> Method.invoke(Object, Object...) line: not available
>
> The main thread waits until the 2nd thread finishes but the 2nd thread is
> stuck since the 1st one locked FinalizingBrokerImpl...
>
> Is there a way to serialize my entities without passing through OpenJPA's
> code?
>