Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338885 - Prevent redundant exception wrapping during preCommit
Summary: Prevent redundant exception wrapping during preCommit
Status: NEW
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.13   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords:
Depends on: 336318
Blocks:
  Show dependency tree
 
Reported: 2011-03-04 00:46 EST by Caspar D. CLA
Modified: 2020-12-11 10:38 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Caspar D. CLA 2011-03-04 00:46:22 EST
Any non-runtime exception thrown during #preCommit, will get wrapped in
a TransactionException, see CDOTransactionImpl.java:2401.

This then gets caught in #commit, and wrapped into a CommitException, 
see CDOTransactionImpl.java:1070. 

So if the original exception was already a CommitException (as is the 
case, for example, for CommitIntegrityExceptions), we end up throwing
a CommitException wrapped in a TransactionException wrapped in a
CommitException :S

The concepts 'TransactionException' and 'CommitException' seem pretty
redundant to me. But what I like about the former is that it's unchecked.
What is or should be our strategy here?
Comment 1 Eike Stepper CLA 2011-03-04 01:45:01 EST
> The concepts 'TransactionException' and 'CommitException' seem pretty
> redundant to me. But what I like about the former is that it's unchecked.
> What is or should be our strategy here?

TransactionException is the historical exception and it is unchecked. Late in the 3.0 cycle I decided that we should force the user to think about expectable problems during commit() processing like concurrent modification, referential integrity violation, lock timeouts, etc. The CommitException is supposed to be thrown only and directly from the client side commit() method.

TransactionException should not wrap other TransactionExceptions and possibly not other RuntimeExceptions.

I wonder if CommitException could unwrap possibly nested TransactionExceptions or if that would lead to information loss...
Comment 2 Caspar D. CLA 2011-03-04 04:03:39 EST
(In reply to comment #1)
> Late in the 3.0 cycle I decided that we should force the user to
> think about expectable problems during commit() processing like
> concurrent modification, referential integrity violation, lock
> timeouts, etc. 

I don't believe in forcing a client to do anything. Like all of
us, the client programmer will click "Quick fix > Surround with
try/catch" (or "Add throws decl" if he's of the orthodox
school), and get back to it when he feels the need.

> The CommitException is supposed to be thrown only and directly
> from the client side commit() method.

I suppose by "directly" you mean that it shouldn't be thrown from
any methods called from #commit? Then
CommitTransactionImpl.java:1070 is the only place in the codebase
where CommitEx should ever be instantiated. And it follows then
that its not meant to be a base class for any other exceptions.
(CommitIntegrityEx currently derives from CommitEx -- my bad.)

> TransactionException should not wrap other TransactionExceptions
> and possibly not other RuntimeExceptions.

That it doesn't do, as far as I've seen.

> I wonder if CommitException could unwrap possibly nested
> TransactionExceptions or if that would lead to information
> loss...

I don't think that would lead to information loss, as the
TransactionException seems to serve no purpose other than to
tunnel the checked exception up the call stack without having to
declare it. (IMO a tell-tale sign that we don't actually want
checked exceptions, but apparently feel obliged to pay some homage
to them.)

What I mostly don't get is that you seem to want to retain both
the TxEx and the CommitEx. Personally I think the TxEx is more
convenient and has been used more consistently. CommitEx's only
strong point is its better name.
Comment 3 Eike Stepper CLA 2011-06-23 03:58:58 EDT
Moving all open enhancement requests to 4.1
Comment 4 Eike Stepper CLA 2012-08-14 22:53:28 EDT
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
Comment 5 Eike Stepper CLA 2013-06-27 04:08:48 EDT
Moving all outstanding enhancements to 4.3
Comment 6 Eike Stepper CLA 2014-08-19 09:28:14 EDT
Moving all open enhancement requests to 4.4
Comment 7 Eike Stepper CLA 2014-08-19 09:37:30 EDT
Moving all open enhancement requests to 4.4
Comment 8 Eike Stepper CLA 2015-07-14 02:14:46 EDT
Moving all open bugzillas to 4.5.
Comment 9 Eike Stepper CLA 2016-07-31 00:57:45 EDT
Moving all unaddressed bugzillas to 4.6.
Comment 10 Eike Stepper CLA 2017-12-28 01:14:14 EST
Moving all open bugs to 4.7
Comment 11 Eike Stepper CLA 2019-11-08 02:08:51 EST
Moving all unresolved issues to version 4.8-
Comment 12 Eike Stepper CLA 2019-12-13 12:46:33 EST
Moving all unresolved issues to version 4.9
Comment 13 Eike Stepper CLA 2020-12-11 10:38:22 EST
Moving to 4.13.