You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "xingfudeshi (via GitHub)" <gi...@apache.org> on 2024/09/05 02:37:31 UTC

[PR] Fix NPE when getting branchType in a non-global transaction context [incubator-seata]

xingfudeshi opened a new pull request, #6816:
URL: https://github.com/apache/incubator-seata/pull/6816

   <!-- Please make sure you have read and understood the contributing guidelines -->
   
   - [ ] I have registered the PR [changes](../changes).
   
   ### Ⅰ. Describe what this PR did
   Fix NPE when getting branchType in a non-global transaction context.
   
   ### Ⅱ. Does this pull request fix one issue?
   <!-- If that, add "fixes #xxx" below in the next line, for example, fixes #97. -->
   fixes #6815 
   
   ### Ⅲ. Why don't you add test cases (unit test/integration test)? 
   
   
   ### Ⅳ. Describe how to verify it
   
   
   ### Ⅴ. Special notes for reviews
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix:Fix NPE when getting branchType in a non-global transaction context [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6816:
URL: https://github.com/apache/incubator-seata/pull/6816#discussion_r1744728123


##########
compatible/src/main/java/io/seata/core/context/RootContext.java:
##########
@@ -168,7 +172,12 @@ public static void bindBranchType(@Nonnull BranchType branchType) {
      */
     @Nullable
     public static BranchType unbindBranchType() {
-        return convertIoSeata(org.apache.seata.core.context.RootContext.unbindBranchType());
+        org.apache.seata.core.model.BranchType branchType = org.apache.seata.core.context.RootContext.unbindBranchType();
+        if (branchType != null) {
+            return convertIoSeata(branchType);

Review Comment:
   为什么不统一放到convertIoSeata这个方法中判空呢?
   Why not uniformly put it in the convertIoSeata method to rule out emptiness?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix:Fix NPE when getting branchType in a non-global transaction context [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes merged PR #6816:
URL: https://github.com/apache/incubator-seata/pull/6816


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix:Fix NPE when getting branchType in a non-global transaction context [incubator-seata]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #6816:
URL: https://github.com/apache/incubator-seata/pull/6816#issuecomment-2330501115

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/6816?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `0%` with `3 lines` in your changes missing coverage. Please review.
   > Project coverage is 52.43%. Comparing base [(`242d92c`)](https://app.codecov.io/gh/apache/incubator-seata/commit/242d92c4e881100adcea4cc6faa0df3568cbaa98?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`aaf3e04`)](https://app.codecov.io/gh/apache/incubator-seata/commit/aaf3e047341aae8df86075dc5170e1e1509656df?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata/pull/6816?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...c/main/java/io/seata/core/context/RootContext.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6816?src=pr&el=tree&filepath=compatible%2Fsrc%2Fmain%2Fjava%2Fio%2Fseata%2Fcore%2Fcontext%2FRootContext.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29tcGF0aWJsZS9zcmMvbWFpbi9qYXZhL2lvL3NlYXRhL2NvcmUvY29udGV4dC9Sb290Q29udGV4dC5qYXZh) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/6816?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/incubator-seata/pull/6816/graphs/tree.svg?width=650&height=150&src=pr&token=tbmHt2ZfxO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/incubator-seata/pull/6816?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@             Coverage Diff              @@
   ##                2.x    #6816      +/-   ##
   ============================================
   + Coverage     52.30%   52.43%   +0.13%     
   + Complexity     6387     6383       -4     
   ============================================
     Files          1080     1080              
     Lines         37552    37554       +2     
     Branches       4447     4447              
   ============================================
   + Hits          19641    19693      +52     
   + Misses        15977    15912      -65     
   - Partials       1934     1949      +15     
   ```
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata/pull/6816?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...c/main/java/io/seata/core/context/RootContext.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6816?src=pr&el=tree&filepath=compatible%2Fsrc%2Fmain%2Fjava%2Fio%2Fseata%2Fcore%2Fcontext%2FRootContext.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29tcGF0aWJsZS9zcmMvbWFpbi9qYXZhL2lvL3NlYXRhL2NvcmUvY29udGV4dC9Sb290Q29udGV4dC5qYXZh) | `14.28% <0.00%> (-1.10%)` | :arrow_down: |
   
   ... and [16 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/6816/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix:Fix NPE when getting branchType in a non-global transaction context [incubator-seata]

Posted by "xingfudeshi (via GitHub)" <gi...@apache.org>.
xingfudeshi commented on code in PR #6816:
URL: https://github.com/apache/incubator-seata/pull/6816#discussion_r1744731476


##########
compatible/src/main/java/io/seata/core/context/RootContext.java:
##########
@@ -168,7 +172,12 @@ public static void bindBranchType(@Nonnull BranchType branchType) {
      */
     @Nullable
     public static BranchType unbindBranchType() {
-        return convertIoSeata(org.apache.seata.core.context.RootContext.unbindBranchType());
+        org.apache.seata.core.model.BranchType branchType = org.apache.seata.core.context.RootContext.unbindBranchType();
+        if (branchType != null) {
+            return convertIoSeata(branchType);

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix:Fix NPE when getting branchType in a non-global transaction context [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6816:
URL: https://github.com/apache/incubator-seata/pull/6816#discussion_r1744754609


##########
compatible/src/main/java/io/seata/core/context/RootContext.java:
##########
@@ -16,12 +16,11 @@
  */
 package io.seata.core.context;
 
-import java.util.Map;
+import io.seata.core.model.BranchType;

Review Comment:
   ```suggestion
   ```



##########
compatible/src/main/java/io/seata/core/context/RootContext.java:
##########
@@ -16,12 +16,11 @@
  */
 package io.seata.core.context;
 
-import java.util.Map;
+import io.seata.core.model.BranchType;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-
-import io.seata.core.model.BranchType;
+import java.util.Map;

Review Comment:
   ```suggestion
   import java.util.Map;
   
   import io.seata.core.model.BranchType;
   ```



##########
compatible/src/main/java/io/seata/core/context/RootContext.java:
##########
@@ -41,8 +40,12 @@ public class RootContext {
      */
     public static final String KEY_BRANCH_TYPE = "TX_BRANCH_TYPE";
 
-    private static BranchType convertIoSeata(org.apache.seata.core.model.BranchType branchType) {
-        return BranchType.get(branchType.name());
+    private static BranchType convertIoSeata(@Nonnull org.apache.seata.core.model.BranchType branchType) {

Review Comment:
   ```suggestion
       private static BranchType convertIoSeata(org.apache.seata.core.model.BranchType branchType) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org