Index: doc/release-notes.xml =================================================================== RCS file: /scm/castor/castor/src/doc/release-notes.xml,v retrieving revision 1.236 diff -u -r1.236 release-notes.xml --- doc/release-notes.xml 13 Apr 2006 19:44:43 -0000 1.236 +++ doc/release-notes.xml 13 Apr 2006 20:58:28 -0000 @@ -42,6 +42,26 @@ + + + Improved exception chaining for various JDO-related exceptions. + + + Werner Guttmann + werner.guttmann@gmx.net + + + Werner Guttmann + werner.guttmann@gmx.net + + + Yegor Borovikov + yegorb@intresys.com + + Bug + JDO + 20060413 + Refactored ClassMolder.update() to complete transfer to strategy pattern. Index: etc/CHANGELOG =================================================================== RCS file: /scm/castor/castor/src/etc/CHANGELOG,v retrieving revision 1.387 diff -u -r1.387 CHANGELOG --- etc/CHANGELOG 13 Apr 2006 19:44:43 -0000 1.387 +++ etc/CHANGELOG 13 Apr 2006 20:58:31 -0000 @@ -2,6 +2,11 @@ Version (CVS) ------------- +JDO: Fixed bug CASTOR-1402 using contribution from Werner Guttmann [werner.guttmann@gmx.net] + Improved exception chaining for various JDO-related exceptions. + Details: http://jira.codehaus.org/browse/CASTOR-1388 + (Werner - 20060413) + JDO: Fixed bug CASTOR-1388 using contribution from Werner Guttmann [werner.guttmann@gmx.net] Refactor ClassMolder.update() to complete transfer to strategy pattern. Details: http://jira.codehaus.org/browse/CASTOR-1388 Index: main/org/castor/persist/proxy/SingleProxy.java =================================================================== RCS file: /scm/castor/castor/src/main/org/castor/persist/proxy/SingleProxy.java,v retrieving revision 1.6 diff -u -r1.6 SingleProxy.java --- main/org/castor/persist/proxy/SingleProxy.java 13 Apr 2006 16:49:49 -0000 1.6 +++ main/org/castor/persist/proxy/SingleProxy.java 13 Apr 2006 20:58:32 -0000 @@ -112,7 +112,7 @@ _log.error(msg, ex); } throw new ObjectNotFoundException("lazy loading error - " - + ex.getMessage()); + + ex.getMessage(), ex); } } Index: main/org/exolab/castor/jdo/engine/SQLStatementCreate.java =================================================================== RCS file: /scm/castor/castor/src/main/org/exolab/castor/jdo/engine/SQLStatementCreate.java,v retrieving revision 1.5 diff -u -r1.5 SQLStatementCreate.java --- main/org/exolab/castor/jdo/engine/SQLStatementCreate.java 13 Apr 2006 13:37:48 -0000 1.5 +++ main/org/exolab/castor/jdo/engine/SQLStatementCreate.java 13 Apr 2006 20:58:33 -0000 @@ -320,7 +320,7 @@ isDupKey = _factory.isDuplicateKeyException(except); if (Boolean.TRUE.equals(isDupKey)) { - throw new DuplicateIdentityException(Messages.format("persist.duplicateIdentity", _type, identity)); + throw new DuplicateIdentityException(Messages.format("persist.duplicateIdentity", _type, identity), except); } else if (Boolean.FALSE.equals(isDupKey)) { throw new PersistenceException(Messages.format("persist.nested", except), except); } Index: main/org/exolab/castor/jdo/oql/ParseTreeWalker.java =================================================================== RCS file: /scm/castor/castor/src/main/org/exolab/castor/jdo/oql/ParseTreeWalker.java,v retrieving revision 1.16 diff -u -r1.16 ParseTreeWalker.java --- main/org/exolab/castor/jdo/oql/ParseTreeWalker.java 4 Jan 2006 00:47:47 -0000 1.16 +++ main/org/exolab/castor/jdo/oql/ParseTreeWalker.java 13 Apr 2006 20:58:34 -0000 @@ -275,7 +275,7 @@ _objClass = _classLoader.loadClass(_fromClassName); } } catch (ClassNotFoundException except) { - throw new QueryException("Could not find class " + _fromClassName); + throw new QueryException("Could not find class " + _fromClassName, except); } _engine = (SQLEngine) _dbEngine.getPersistence(_objClass); if (_engine == null) { Index: main/org/exolab/castor/persist/LockEngine.java =================================================================== RCS file: /scm/castor/castor/src/main/org/exolab/castor/persist/LockEngine.java,v retrieving revision 1.32 diff -u -r1.32 LockEngine.java --- main/org/exolab/castor/persist/LockEngine.java 11 Apr 2006 21:26:05 -0000 1.32 +++ main/org/exolab/castor/persist/LockEngine.java 13 Apr 2006 20:58:35 -0000 @@ -406,9 +406,9 @@ _log.debug(Messages.format("jdo.loading.with.id", typeInfo.molder.getName(), oid.getIdentity())); } } - } catch ( ObjectDeletedWaitingForLockException except ) { + } catch (ObjectDeletedWaitingForLockException except) { // This is equivalent to object does not exist - throw new ObjectNotFoundException( Messages.format("persist.objectNotFound", oid.getName(), oid.getIdentity())); + throw new ObjectNotFoundException(Messages.format("persist.objectNotFound", oid.getName(), oid.getIdentity()), except); } catch (LockNotGrantedException e) { if (lock != null) { lock.release(tx); @@ -501,11 +501,11 @@ return oid; // should catch some other exception if destory is not succeed - } catch ( LockNotGrantedException except ) { + } catch (LockNotGrantedException except) { // Someone else is using the object, definite duplicate key - throw new DuplicateIdentityException( Messages.format( + throw new DuplicateIdentityException(Messages.format( "persist.duplicateIdentity", object.getClass().getName(), - oid.getIdentity() ) ); + oid.getIdentity()), except); } catch ( DuplicateIdentityException except ) { // we got a write lock and the persistence storage already // recorded. Should destory the lock @@ -684,11 +684,11 @@ if ( accessMode == AccessMode.ReadOnly ) typeInfo.release( oid, tx ); */ - } catch ( ObjectModifiedException e ) { + } catch (ObjectModifiedException e) { throw e; - } catch ( ObjectDeletedWaitingForLockException except ) { + } catch (ObjectDeletedWaitingForLockException except) { // This is equivalent to object not existing - throw new ObjectNotFoundException( Messages.format("persist.objectNotFound", oid.getName(), oid.getIdentity()) ); + throw new ObjectNotFoundException(Messages.format("persist.objectNotFound", oid.getName(), oid.getIdentity()), except); } finally { if ( lock != null ) lock.confirm( tx, succeed ); Index: main/org/exolab/castor/persist/ObjectDeletedWaitingForLockException.java =================================================================== RCS file: /scm/castor/castor/src/main/org/exolab/castor/persist/ObjectDeletedWaitingForLockException.java,v retrieving revision 1.3 diff -u -r1.3 ObjectDeletedWaitingForLockException.java --- main/org/exolab/castor/persist/ObjectDeletedWaitingForLockException.java 10 Apr 2006 22:39:19 -0000 1.3 +++ main/org/exolab/castor/persist/ObjectDeletedWaitingForLockException.java 13 Apr 2006 20:58:35 -0000 @@ -63,15 +63,18 @@ private static final long serialVersionUID = 1774245493143153091L; - ObjectDeletedWaitingForLockException() - { - super( Messages.message( "persist.deletedWaitingForLock" ) ); + ObjectDeletedWaitingForLockException() { + super(Messages.message("persist.deletedWaitingForLock")); } - - ObjectDeletedWaitingForLockException( String msg ) { + ObjectDeletedWaitingForLockException(String msg) { super( msg ); } + public ObjectDeletedWaitingForLockException(String message, Throwable exception) { + super(message, exception); + } + + } Index: main/org/exolab/castor/persist/ObjectLock.java =================================================================== RCS file: /scm/castor/castor/src/main/org/exolab/castor/persist/ObjectLock.java,v retrieving revision 1.8 diff -u -r1.8 ObjectLock.java --- main/org/exolab/castor/persist/ObjectLock.java 10 Apr 2006 22:39:19 -0000 1.8 +++ main/org/exolab/castor/persist/ObjectLock.java 13 Apr 2006 20:58:36 -0000 @@ -394,8 +394,8 @@ try { _waitCount++; wait(); - } catch ( InterruptedException e ) { - throw new LockNotGrantedException("Thread interrupted acquiring lock!"); + } catch (InterruptedException e) { + throw new LockNotGrantedException("Thread interrupted acquiring lock!", e); } finally { _waitCount--; } @@ -463,10 +463,10 @@ try { long waittime = endtime - System.currentTimeMillis(); wait( waittime<0? 0: waittime ); - } catch ( InterruptedException except ) { + } catch (InterruptedException except) { // If the thread is interrupted, come out with the proper message - throw new LockNotGrantedException( write ? "persist.writeLockTimeout" : - "persist.readLockTimeout" + _oid + "/" + _id + " by " + tx ); + throw new LockNotGrantedException(write ? "persist.writeLockTimeout" : + "persist.readLockTimeout" + _oid + "/" + _id + " by " + tx, except); } if ( _deleted ) @@ -506,8 +506,8 @@ while ( _deleted ) { wait(); } - } catch ( InterruptedException e ) { - throw new LockNotGrantedException("Thread interrupted acquiring lock!"); + } catch (InterruptedException e) { + throw new LockNotGrantedException("Thread interrupted acquiring lock!", e); } finally { _waitCount--; } @@ -543,8 +543,8 @@ if ( _deleted ) { throw new ObjectDeletedWaitingForLockException("Object deleted!"); }*/ - } catch ( InterruptedException e ) { - throw new LockNotGrantedException("Thread interrupted acquiring lock!"); + } catch (InterruptedException e) { + throw new LockNotGrantedException("Thread interrupted acquiring lock!", e); } finally { _waitCount--; } @@ -581,9 +581,9 @@ try { long waittime = endtime - System.currentTimeMillis(); wait( waittime<0? 0: waittime ); - } catch ( InterruptedException except ) { + } catch (InterruptedException except) { // If the thread is interrupted, come out with the proper message - throw new LockNotGrantedException( Messages.message ("persist.writeLockTimeout") + _oid + "/" + _id + " by " + tx ); + throw new LockNotGrantedException(Messages.message("persist.writeLockTimeout") + _oid + "/" + _id + " by " + tx, except); } if ( _deleted ) @@ -791,9 +791,9 @@ try { long waittime = endtime - System.currentTimeMillis(); wait( waittime<0? 0: waittime ); - } catch ( InterruptedException except ) { + } catch (InterruptedException except) { // If the thread is interrupted, come out with the proper message - throw new LockNotGrantedException( "persist.writeLockTimeout" ); + throw new LockNotGrantedException("persist.writeLockTimeout", except); } if ( _deleted )