You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "kerwin612 (via GitHub)" <gi...@apache.org> on 2024/04/03 06:32:48 UTC

[PR] Fixed NPE issue [shenyu]

kerwin612 opened a new pull request, #5530:
URL: https://github.com/apache/shenyu/pull/5530

   <!-- Describe your PR here; e.g. Fixes #issueNo -->
   Fixed apache/shenyu-dashboard#438
   
   Before:
   ![84c8448d3d1032dcb2ce0f2a4fe1a1c](https://github.com/apache/shenyu/assets/3371163/a1467046-0d37-4b4c-b0f4-bf18456f9285)
   After:
   ![backend-fixed](https://github.com/apache/shenyu/assets/3371163/f00b4e02-fbb1-4e49-9567-482f245cafa8)
   
   <!--
   Thank you for proposing a pull request. This template will guide you through the essential steps necessary for a pull request.
   -->
   Make sure that:
   
   - [x] You have read the [contribution guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [ ] You submit test cases (unit or integration tests) that back your changes.
   - [x] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true`.
   


-- 
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@shenyu.apache.org

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


Re: [PR] Fixed NPE issue [shenyu]

Posted by "moremind (via GitHub)" <gi...@apache.org>.
moremind merged PR #5530:
URL: https://github.com/apache/shenyu/pull/5530


-- 
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@shenyu.apache.org

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


Re: [PR] Fixed NPE issue [shenyu]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #5530:
URL: https://github.com/apache/shenyu/pull/5530#issuecomment-2033686537

   ## [Codecov](https://app.codecov.io/gh/apache/shenyu/pull/5530?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 `15 lines` in your changes are missing coverage. Please review.
   > Project coverage is 61.57%. Comparing base [(`c1abc7b`)](https://app.codecov.io/gh/apache/shenyu/commit/c1abc7bd7bf50c03e9c2850c235574fb90223770?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`779a10f`)](https://app.codecov.io/gh/apache/shenyu/pull/5530?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 2 commits behind head on master.
   
   | [Files](https://app.codecov.io/gh/apache/shenyu/pull/5530?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...pache/shenyu/admin/transfer/DiscoveryTransfer.java](https://app.codecov.io/gh/apache/shenyu/pull/5530?src=pr&el=tree&filepath=shenyu-admin%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshenyu%2Fadmin%2Ftransfer%2FDiscoveryTransfer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2hlbnl1LWFkbWluL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGVueXUvYWRtaW4vdHJhbnNmZXIvRGlzY292ZXJ5VHJhbnNmZXIuamF2YQ==) | 0.00% | [9 Missing and 6 partials :warning: ](https://app.codecov.io/gh/apache/shenyu/pull/5530?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>
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #5530      +/-   ##
   ============================================
   + Coverage     61.54%   61.57%   +0.02%     
   - Complexity     8832     8838       +6     
   ============================================
     Files          1261     1261              
     Lines         39230    39245      +15     
     Branches       3723     3723              
   ============================================
   + Hits          24145    24165      +20     
   + Misses        12911    12902       -9     
   - Partials       2174     2178       +4     
   ```
   
   
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/shenyu/pull/5530?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
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@shenyu.apache.org

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


Re: [PR] Fixed NPE issue [shenyu]

Posted by "moremind (via GitHub)" <gi...@apache.org>.
moremind commented on code in PR #5530:
URL: https://github.com/apache/shenyu/pull/5530#discussion_r1555458973


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java:
##########
@@ -53,6 +53,7 @@ public enum DiscoveryTransfer {
      * @return DiscoveryUpstreamDO
      */
     public DiscoveryUpstreamDO mapToDo(DiscoveryUpstreamData discoveryUpstreamData) {
+        if (discoveryUpstreamData == null)    return null;
         return DiscoveryUpstreamDO.builder()

Review Comment:
   Bad grammar



-- 
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@shenyu.apache.org

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


Re: [PR] Fixed NPE issue [shenyu]

Posted by "moremind (via GitHub)" <gi...@apache.org>.
moremind commented on code in PR #5530:
URL: https://github.com/apache/shenyu/pull/5530#discussion_r1565176871


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java:
##########
@@ -187,16 +213,19 @@ public DiscoveryUpstreamData mapToData(DiscoveryUpstreamDTO discoveryUpstreamDTO
      * @return ProxySelectorData
      */
     public ProxySelectorData mapToData(ProxySelectorDTO proxySelectorDTO) {
-        ProxySelectorData proxySelectorData = new ProxySelectorData();
-        proxySelectorData.setId(proxySelectorDTO.getId());
-        proxySelectorData.setName(proxySelectorDTO.getName());
-        proxySelectorData.setPluginName(proxySelectorDTO.getPluginName());
-        proxySelectorData.setType(proxySelectorDTO.getType());
-        proxySelectorData.setForwardPort(proxySelectorDTO.getForwardPort());
-        String props = proxySelectorDTO.getProps();
-        Properties properties = GsonUtils.getInstance().fromJson(props, Properties.class);
-        proxySelectorData.setProps(properties);
-        return proxySelectorData;
+        return Optional.ofNullable(proxySelectorDTO).map(data -> {
+            ProxySelectorData proxySelectorData = new ProxySelectorData();
+            proxySelectorData.setId(data.getId());
+            proxySelectorData.setName(data.getName());
+            proxySelectorData.setPluginName(data.getPluginName());
+            proxySelectorData.setType(data.getType());
+            proxySelectorData.setForwardPort(data.getForwardPort());
+            String props = data.getProps();
+            Properties properties = GsonUtils.getInstance().fromJson(props, Properties.class);
+            proxySelectorData.setProps(properties);
+            return proxySelectorData;
+        })
+        .orElse(null);

Review Comment:
   not change line



-- 
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@shenyu.apache.org

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