Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the same transaction when creating a path for a new resource #2954

Open
wants to merge 1 commit into
base: 4.6.x-old
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.wso2.carbon.registry.core.jdbc.dataaccess.AbstractConnection;
import org.wso2.carbon.registry.core.jdbc.dataaccess.ConnectionWrapper;
import org.wso2.carbon.registry.core.jdbc.dataaccess.JDBCDataAccessManager;
import org.wso2.carbon.registry.core.jdbc.dataaccess.JDBCDatabaseTransaction;
import org.wso2.carbon.registry.core.session.CurrentSession;
import org.wso2.carbon.registry.core.utils.RegistryUtils;
import org.wso2.carbon.utils.DBUtils;
Expand Down Expand Up @@ -84,18 +85,9 @@ public int addEntry(String path, int parentPathId) throws SQLException, Registry
log.error(msg);
throw new RegistryException(msg);
}
DataSource dataSource = ((JDBCDataAccessManager)dataAccessManager).getDataSource();
AbstractConnection conn = new ConnectionWrapper(dataSource.getConnection(),
RegistryUtils.getConnectionId(dataSource));
if (conn != null) {
if (conn.getTransactionIsolation() != Connection.TRANSACTION_READ_COMMITTED) {
conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
}
conn.setAutoCommit(false);
} else {
log.error("Unable to acquire connection to database.");
return -1;
}
JDBCDatabaseTransaction.ManagedRegistryConnection conn =
JDBCDatabaseTransaction.getConnection();

boolean success = false;
int pathId = 0;

Expand Down