Skip to content

Commit

Permalink
[fix] 修复使用子事务屏障即使失败还返回成功的问题
Browse files Browse the repository at this point in the history
[fix] 修复使用子事务屏障即使失败还返回成功的问题
  • Loading branch information
PandaLIU-1111 authored Jul 11, 2023
2 parents e1a4284 + 93b6eca commit caeca3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Middleware/DtmMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$barrier = $this->config->get('dtm.barrier.apply', []);

$businessCall = function () use ($handler, $request) {
$handler->handle($request);
return $handler->handle($request);
};

if (in_array($class . '::' . $method, $barrier)) {
Expand Down
6 changes: 5 additions & 1 deletion src/MySqlBarrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use DtmClient\Constants\Branch;
use DtmClient\Constants\Operation;
use DtmClient\Constants\Result;
use DtmClient\Constants\TransType;
use DtmClient\DbTransaction\DBTransactionInterface;
use DtmClient\Exception\DuplicatedException;
Expand Down Expand Up @@ -59,7 +60,10 @@ public function call(callable $businessCall): bool
return true;
}

$businessCall();
$response = $businessCall();
if ($response->getStatusCode() !== Result::SUCCESS_STATUS) {
throw new FailureException();
}

$this->DBTransaction->commit();

Expand Down

0 comments on commit caeca3a

Please sign in to comment.