crossoverJie commented on code in PR #1850:
URL: https://github.com/apache/hertzbeat/pull/1850#discussion_r1580338329


##########
collector/src/main/java/org/apache/hertzbeat/collector/collect/http/SslCertificateCollectImpl.java:
##########
@@ -159,7 +159,7 @@ private void validateParams(Metrics metrics) throws 
Exception {
         }
         HttpProtocol httpProtocol = metrics.getHttp();
         String url = httpProtocol.getUrl();
-        if (StringUtils.hasText(url) || !url.startsWith(RIGHT_DASH)) {
+        if (url == null || StringUtils.hasText(url) || 
!url.startsWith(RIGHT_DASH)) {

Review Comment:
   I suggest that the same function:`StringUtils.isEmpty(url)` can be used for 
both of these string checks.



##########
collector/src/main/java/org/apache/hertzbeat/collector/collect/nginx/NginxCollectImpl.java:
##########
@@ -139,7 +139,7 @@ private void validateParams(Metrics metrics) throws 
Exception {
         
         String url = nginxProtocol.getUrl();
         
-        if (StringUtils.isEmpty(url) || !url.startsWith(RIGHT_DASH)) {
+        if (url == null || StringUtils.isEmpty(url) || 
!url.startsWith(RIGHT_DASH)) {

Review Comment:
   
   
![image](https://github.com/apache/hertzbeat/assets/15684156/3a7039de-5c0c-44d9-9aaa-b10f7812fade)
   
   The method `StringUtils.isEmpty(url)` has already checks whether string is 
null or empty.
   
   So maybe we don't need this check `url == null`.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to