Copilot commented on code in PR #6272:
URL: https://github.com/apache/shenyu/pull/6272#discussion_r2693474435


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java:
##########
@@ -335,13 +340,24 @@ public DiscoveryUpstreamDTO mapToDTO(DiscoveryUpstreamDO 
discoveryUpstreamDO) {
             return discoveryUpstreamDTO;
         }).orElse(null);
     }
-    
+
     /**
      * mapToDiscoveryUpstreamData.
+     * 
      * @param commonUpstream commonUpstream
      * @return DiscoveryUpstreamData
      */
     public DiscoveryUpstreamData mapToDiscoveryUpstreamData(CommonUpstream 
commonUpstream) {
-        return 
mapToData(CommonUpstreamUtils.buildDefaultDiscoveryUpstreamDTO(commonUpstream.getUpstreamUrl().split(":")[0],
 Integer.valueOf(commonUpstream.getUpstreamUrl().split(":")[1]), 
commonUpstream.getProtocol(),commonUpstream.getNamespaceId()));
+        DiscoveryUpstreamDTO discoveryUpstreamDTO = 
CommonUpstreamUtils.buildDefaultDiscoveryUpstreamDTO(
+                commonUpstream.getUpstreamUrl().split(":")[0],
+                Integer.valueOf(commonUpstream.getUpstreamUrl().split(":")[1]),

Review Comment:
   Potential uncaught 'java.lang.NumberFormatException'.
   ```suggestion
           String upstreamUrl = commonUpstream.getUpstreamUrl();
           String[] parts = Optional.ofNullable(upstreamUrl)
                   .map(url -> url.split(":", 2))
                   .orElseThrow(() -> new IllegalArgumentException("Upstream 
URL must not be null"));
           if (parts.length < 2) {
               throw new IllegalArgumentException("Invalid upstream URL, 
expected 'host:port' format but was: " + upstreamUrl);
           }
           String host = parts[0];
           int port;
           try {
               port = Integer.parseInt(parts[1]);
           } catch (NumberFormatException ex) {
               throw new IllegalArgumentException("Invalid port in upstream 
URL: " + upstreamUrl, ex);
           }
           DiscoveryUpstreamDTO discoveryUpstreamDTO = 
CommonUpstreamUtils.buildDefaultDiscoveryUpstreamDTO(
                   host,
                   port,
   ```



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java:
##########
@@ -335,13 +340,24 @@ public DiscoveryUpstreamDTO mapToDTO(DiscoveryUpstreamDO 
discoveryUpstreamDO) {
             return discoveryUpstreamDTO;
         }).orElse(null);
     }
-    
+
     /**
      * mapToDiscoveryUpstreamData.
+     * 
      * @param commonUpstream commonUpstream
      * @return DiscoveryUpstreamData
      */

Review Comment:
   Inconsistent spacing in JavaDoc. Line 346 has a trailing space after the 
period. Remove the trailing space to maintain consistent formatting.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to