This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git
commit 20a5886646be4a819d93a7431d65eca9da9c2ecb Author: seanyinx <sean....@huawei.com> AuthorDate: Thu Jan 11 14:19:05 2018 +0800 SCB-212 better readability Signed-off-by: seanyinx <sean....@huawei.com> --- .../omega/transaction/SagaStartAnnotationProcessor.java | 14 +++++--------- .../transaction/SagaStartAnnotationProcessorTest.java | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java index 6e8556b..0aa8fab 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java @@ -31,15 +31,13 @@ class SagaStartAnnotationProcessor implements EventAwareInterceptor { @Override public void preIntercept(String parentTxId, String compensationMethod, Object... message) { - String globalTxId = globalTxId(); - // reuse the globalTxId as localTxId to differ localTxId in SagaStartedEvent and the first TxStartedEvent - sender.send(new SagaStartedEvent(globalTxId, globalTxId)); + initializeOmegaContext(); + sender.send(new SagaStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId())); } @Override public void postIntercept(String parentTxId, String compensationMethod) { - String globalTxId = omegaContext.globalTxId(); - sender.send(new SagaEndedEvent(globalTxId, globalTxId)); + sender.send(new SagaEndedEvent(omegaContext.globalTxId(), omegaContext.localTxId())); omegaContext.clear(); } @@ -50,9 +48,7 @@ class SagaStartAnnotationProcessor implements EventAwareInterceptor { omegaContext.clear(); } - private String globalTxId() { - String globalTxId = omegaContext.newGlobalTxId(); - omegaContext.setLocalTxId(globalTxId); - return globalTxId; + private void initializeOmegaContext() { + omegaContext.setLocalTxId(omegaContext.newGlobalTxId()); } } diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java index 8fa3568..e857356 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java @@ -70,8 +70,8 @@ public class SagaStartAnnotationProcessorTest { @Test public void sendsSagaEndedEvent() { - context.clear(); context.setGlobalTxId(globalTxId); + context.setLocalTxId(globalTxId); sagaStartAnnotationProcessor.postIntercept(null, null); -- To stop receiving notification emails like this one, please contact "commits@servicecomb.apache.org" <commits@servicecomb.apache.org>.