Skip to content

Commit

Permalink
Bugfix xa not throw (#72)
Browse files Browse the repository at this point in the history
* public xa constructor

* Adjust XaGlobalTransaction Excecute function signatures

* throw XaGlobalTransaction ExecuteAsync Exception
  • Loading branch information
JackBOBO authored Jul 12, 2023
1 parent fe25d97 commit 37e4945
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Dtmcli/Xa/Xa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public sealed class Xa : TransBase
{
private readonly IDtmClient _dtmClient;

internal Xa(IDtmClient dtmHttpClient, string gid)
public Xa(IDtmClient dtmHttpClient, string gid)
{
this._dtmClient = dtmHttpClient;
this.Gid = gid;
this.TransType = DtmCommon.Constant.TYPE_XA;
this.BranchIDGen = new BranchIDGen();
}

internal Xa(IDtmClient dtmHttpClient)
public Xa(IDtmClient dtmHttpClient)
{
this._dtmClient = dtmHttpClient;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Dtmcli/Xa/XaGlobalTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public XaGlobalTransaction(IDtmClient dtmClient, ILoggerFactory factory)
public async Task<string> ExcecuteAsync(Func<Xa, Task> xa_cb, CancellationToken cancellationToken = default)
{
var gid = await _dtmClient.GenGid(cancellationToken);
await this.Excecute(gid, xa_cb, cancellationToken);
await this.ExcecuteAsync(gid, xa_cb, cancellationToken);
return gid;
}

public async Task Excecute(string gid, Func<Xa, Task> xa_cb, CancellationToken cancellationToken = default)
public async Task ExcecuteAsync(string gid, Func<Xa, Task> xa_cb, CancellationToken cancellationToken = default)
{
await ExcecuteAsync(gid, null, xa_cb, cancellationToken);
}
Expand All @@ -46,6 +46,7 @@ public async Task ExcecuteAsync(string gid, Action<Xa> custom, Func<Xa, Task> xa
xa.RollbackReason = ex.Message.Substring(0, ex.Message.Length > 1023 ? 1023 : ex.Message.Length);
_logger.LogError(ex, "prepare or submitting global transaction error");
await _dtmClient.TransCallDtm(null, xa, Constant.Request.OPERATION_ABORT, cancellationToken);
throw;
}
}
}
Expand Down

0 comments on commit 37e4945

Please sign in to comment.