Skip to content

Commit

Permalink
JDBC-344 FBXADataSource closes ResultSet in managed transaction as if…
Browse files Browse the repository at this point in the history
… in auto-commit
  • Loading branch information
mrotteveel committed Apr 7, 2014
1 parent 699a4d3 commit 8c91911
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 57 deletions.
18 changes: 15 additions & 3 deletions src/main/org/firebirdsql/jca/FBManagedConnection.java
Expand Up @@ -585,7 +585,7 @@ public void commit(Xid id, boolean onePhase) throws XAException {
* The <code>internalCommit</code> method performs the requested commit
* and may throw a GDSException to be interpreted by the caller.
*
* @param id
* @param xid
* a <code>Xid</code> value
* @param onePhase
* a <code>boolean</code> value
Expand Down Expand Up @@ -654,15 +654,23 @@ public void end(Xid id, int flags) throws XAException {
internalEnd(id, flags);
mcf.notifyEnd(this, id);
inDistributedTransaction = false;

try {
// This will reset the managed environment of the associated connections and set the transaction coordinator to local
// TODO This is a bit of a hack; need to find a better way; this doesn't work with connectionSharing = true
setManagedEnvironment(isManagedEnvironment());
} catch (ResourceException ex) {
throw new FBXAException("Reset of managed state failed", XAException.XAER_RMERR);
}
}

/**
* The <code>internalEnd</code> method ends the xid as requested if
* approprriate and throws a GDSException including the appropriate XA error
* appropriate and throws a GDSException including the appropriate XA error
* code and a message if not. The caller can decode the exception as
* necessary.
*
* @param id
* @param xid
* a <code>Xid</code> value
* @param flags
* an <code>int</code> value
Expand Down Expand Up @@ -1114,6 +1122,10 @@ public void start(Xid id, int flags) throws XAException {
mcf.notifyStart(this, id);

inDistributedTransaction = true;

// This will reset the managed environment of the associated connections and set the transaction coordinator to managed
// TODO This is a bit of a hack; need to find a better way; this doesn't work with connectionSharing = true
setManagedEnvironment(isManagedEnvironment());

} catch (GDSException ge) {
throw new FBXAException(ge.getXAErrorCode());
Expand Down
2 changes: 1 addition & 1 deletion src/main/org/firebirdsql/jdbc/FBConnection.java
Expand Up @@ -473,7 +473,7 @@ public synchronized void setManagedEnvironment(boolean managedConnection) throws
checkValidity();

InternalTransactionCoordinator.AbstractTransactionCoordinator coordinator;
if (managedConnection && mc.inTransaction()) {
if (managedConnection && mc.inDistributedTransaction()) {
coordinator = new InternalTransactionCoordinator.ManagedTransactionCoordinator(this);
this.autoCommit = false;
} else {
Expand Down

0 comments on commit 8c91911

Please sign in to comment.