mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2424 Change error for transaction register(Callback) when no active transaction from PersistenceException to NullPointerException
Ah ok, so in being more strict on null for currentTransaction() that shows up the code that registers transaction callbacks as checking for null and throwing PersistenceException. This is inconsistent with LOTS of other methods that use currentTransaction() and would result in NPE. The concept here is that PersistenceException for this case isn't better than NPE and NPE is actually more consistence wrt using currentTransaction().
This commit is contained in:
1 parent
5178b76431
commit
4d34c9e868
1 file changed
+2
-2
@@ -72,12 +72,12 @@ public class TestTransactionCallback extends BaseTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_noActiveTransaction() {
|
public void test_noActiveTransaction() {
|
||||||
assertThrows(PersistenceException.class, () -> DB.register(new MyCallback()));
|
assertThrows(NullPointerException.class, () -> DB.register(new MyCallback()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_noActiveTransaction_withDatabase() {
|
public void test_noActiveTransaction_withDatabase() {
|
||||||
assertThrows(PersistenceException.class, () -> DB.getDefault().register(new MyCallback()));
|
assertThrows(NullPointerException.class, () -> DB.getDefault().register(new MyCallback()));
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyCallback extends TransactionCallbackAdapter {
|
class MyCallback extends TransactionCallbackAdapter {
|
||||||
|
|||||||
Reference in new issue
Block a user