[OJB-developers] ODMG Bug
Brought to you by:
thma
From: Matthew B. <ma...@so...> - 2002-05-06 05:34:38
|
At risk of sounding like the boy who cried wolf, by not making sure it actually was a bug ;) Here I go again. - InMemoryLockMapImpl's setWriter is called with an Object obj - while creating a new LockEntry, LockStrategyFactory.getIsolationLevel(obj.getClass()) is called - inside getIsolationLevel, the first thing we do is Class c = obj.getClass(); - later on inside getIsolationLevel we call getClassDescriptor(c) this series of steps is functionally equivalent to: Object fooObj = new SomeObjectFoo(); Object obj = fooObj.getClass(); Class c = obj.getClass(); at this point, we've lost what type of class it is, and we only have java.lang.Class as c since java.lang.Class isn't mapped in the repository (this doesn't make sense anyway) we run into problems. I saw these problems this weekend while upgrading to 0.8.400 There are a couple other places this happens, I can provide a list if someone can confirm this is a bug. cheers, Matthew public boolean setWriter(TransactionImpl tx, Object obj) { removeTimedOutLocks(AbstractLockStrategy.DEFAULT_LOCK_TIMEOUT); Identity oid = new Identity(obj); LockEntry writer = new LockEntry(oid.toString(), tx.getGUID(), System.currentTimeMillis(), LockStrategyFactory.getIsolationLevel(obj.getClass()), LockEntry.LOCK_WRITE); ObjectLocks objectLocks = (ObjectLocks) locktable.get(oid.toString()); if (objectLocks == null) { objectLocks = new ObjectLocks(); locktable.put(oid.toString(), objectLocks); } objectLocks.setWriter(writer); return true; } public static int getIsolationLevel(Object obj) { Class c = obj.getClass(); int isolationLevel = IsolationLevels.IL_READ_UNCOMMITTED; // for proxies use the class of the real subject if (Proxy.isProxyClass(c)) { IndirectionHandler handler = (IndirectionHandler) Proxy.getInvocationHandler(obj); c = handler.getIdentity().getObjectsClass(); } if (obj instanceof VirtualProxy) { IndirectionHandler handler = VirtualProxy.getIndirectionHandler((VirtualProxy) obj); c = handler.getIdentity().getObjectsClass(); } try { ClassDescriptor cld = ((TransactionImpl) OJB.getInstance().currentTransaction()).getBroker().getClassDescriptor(c); isolationLevel = cld.getIsolationLevel(); } catch (Exception e) { e.printStackTrace(); } return isolationLevel; } |