#992 - API Change - Change Transaction.close() to throw PersistenceException rather than IOException

This commit is contained in:
Rob Bygrave
2017-03-13 22:10:08 +13:00
parent 41a7f2c97e
commit 1d99a5c5a4
5 changed files with 95 additions and 10 deletions
+8 -3
View File
@@ -5,13 +5,12 @@ import io.ebean.config.DocStoreConfig;
import io.ebean.config.ServerConfig;
import javax.persistence.PersistenceException;
import java.io.Closeable;
import java.sql.Connection;
/**
* The Transaction object. Typically representing a JDBC or JTA transaction.
*/
public interface Transaction extends Closeable {
public interface Transaction extends AutoCloseable {
/**
* Read Committed transaction isolation. Same as
@@ -124,7 +123,13 @@ public interface Transaction extends Closeable {
/**
* If the transaction is active then perform rollback. Otherwise do nothing.
*/
void end() throws PersistenceException;
void end();
/**
* Synonym for end() to support AutoClosable.
*/
void close();
/**
* Return true if the transaction is active.
@@ -411,7 +411,7 @@ public class ScopedTransaction implements SpiTransaction {
}
@Override
public void close() throws IOException {
public void close() {
transaction.close();
}
}
@@ -1144,11 +1144,7 @@ public class JdbcTransaction implements SpiTransaction {
* Alias for end(), which enables this class to be used in try-with-resources.
*/
@Override
public void close() throws IOException {
try {
end();
} catch (PersistenceException ex) {
throw new IOException(ex);
}
public void close() {
end();
}
}