Skip to content

Commit 4e82bf3

Browse files
committed
TransactionSynchronization declared with default methods
Issue: SPR-14432
1 parent e4741b8 commit 4e82bf3

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronization.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -52,22 +52,25 @@ public interface TransactionSynchronization extends Flushable {
5252
* Supposed to unbind resources from TransactionSynchronizationManager if managing any.
5353
* @see TransactionSynchronizationManager#unbindResource
5454
*/
55-
void suspend();
55+
default void suspend() {
56+
}
5657

5758
/**
5859
* Resume this synchronization.
5960
* Supposed to rebind resources to TransactionSynchronizationManager if managing any.
6061
* @see TransactionSynchronizationManager#bindResource
6162
*/
62-
void resume();
63+
default void resume() {
64+
}
6365

6466
/**
6567
* Flush the underlying session to the datastore, if applicable:
6668
* for example, a Hibernate/JPA session.
6769
* @see org.springframework.transaction.TransactionStatus#flush()
6870
*/
6971
@Override
70-
void flush();
72+
default void flush() {
73+
}
7174

7275
/**
7376
* Invoked before transaction commit (before "beforeCompletion").
@@ -83,7 +86,8 @@ public interface TransactionSynchronization extends Flushable {
8386
* (note: do not throw TransactionException subclasses here!)
8487
* @see #beforeCompletion
8588
*/
86-
void beforeCommit(boolean readOnly);
89+
default void beforeCommit(boolean readOnly) {
90+
}
8791

8892
/**
8993
* Invoked before transaction commit/rollback.
@@ -96,7 +100,8 @@ public interface TransactionSynchronization extends Flushable {
96100
* @see #beforeCommit
97101
* @see #afterCompletion
98102
*/
99-
void beforeCompletion();
103+
default void beforeCompletion() {
104+
}
100105

101106
/**
102107
* Invoked after transaction commit. Can perform further operations right
@@ -113,7 +118,8 @@ public interface TransactionSynchronization extends Flushable {
113118
* @throws RuntimeException in case of errors; will be <b>propagated to the caller</b>
114119
* (note: do not throw TransactionException subclasses here!)
115120
*/
116-
void afterCommit();
121+
default void afterCommit() {
122+
}
117123

118124
/**
119125
* Invoked after transaction commit/rollback.
@@ -133,6 +139,7 @@ public interface TransactionSynchronization extends Flushable {
133139
* @see #STATUS_UNKNOWN
134140
* @see #beforeCompletion
135141
*/
136-
void afterCompletion(int status);
142+
default void afterCompletion(int status) {
143+
}
137144

138145
}

0 commit comments

Comments
 (0)