From 4e82bf30c6b1fe144f9581cf277c381f03f8a2f9 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 14 Mar 2017 15:18:53 +0100 Subject: [PATCH] TransactionSynchronization declared with default methods Issue: SPR-14432 --- .../support/TransactionSynchronization.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronization.java b/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronization.java index c3733d477d..def22e57a5 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronization.java +++ b/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronization.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,14 +52,16 @@ public interface TransactionSynchronization extends Flushable { * Supposed to unbind resources from TransactionSynchronizationManager if managing any. * @see TransactionSynchronizationManager#unbindResource */ - void suspend(); + default void suspend() { + } /** * Resume this synchronization. * Supposed to rebind resources to TransactionSynchronizationManager if managing any. * @see TransactionSynchronizationManager#bindResource */ - void resume(); + default void resume() { + } /** * Flush the underlying session to the datastore, if applicable: @@ -67,7 +69,8 @@ public interface TransactionSynchronization extends Flushable { * @see org.springframework.transaction.TransactionStatus#flush() */ @Override - void flush(); + default void flush() { + } /** * Invoked before transaction commit (before "beforeCompletion"). @@ -83,7 +86,8 @@ public interface TransactionSynchronization extends Flushable { * (note: do not throw TransactionException subclasses here!) * @see #beforeCompletion */ - void beforeCommit(boolean readOnly); + default void beforeCommit(boolean readOnly) { + } /** * Invoked before transaction commit/rollback. @@ -96,7 +100,8 @@ public interface TransactionSynchronization extends Flushable { * @see #beforeCommit * @see #afterCompletion */ - void beforeCompletion(); + default void beforeCompletion() { + } /** * Invoked after transaction commit. Can perform further operations right @@ -113,7 +118,8 @@ public interface TransactionSynchronization extends Flushable { * @throws RuntimeException in case of errors; will be propagated to the caller * (note: do not throw TransactionException subclasses here!) */ - void afterCommit(); + default void afterCommit() { + } /** * Invoked after transaction commit/rollback. @@ -133,6 +139,7 @@ public interface TransactionSynchronization extends Flushable { * @see #STATUS_UNKNOWN * @see #beforeCompletion */ - void afterCompletion(int status); + default void afterCompletion(int status) { + } }