jacek-lewandowski commented on code in PR #2458:
URL: https://github.com/apache/cassandra/pull/2458#discussion_r1259467444


##########
src/java/org/apache/cassandra/locator/AbstractCloudMetadataServiceConnector.java:
##########
@@ -25,22 +25,41 @@
 import java.net.URL;
 import java.util.Map;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 abstract class AbstractCloudMetadataServiceConnector
 {
+    static final String METADATA_URL_PROPERTY = "metadata_url";
+
+    public static class DefaultCloudMetadataServiceConnector extends 
AbstractCloudMetadataServiceConnector
+    {
+        protected DefaultCloudMetadataServiceConnector(String 
metadataServiceUrl)
+        {
+            super(metadataServiceUrl);
+        }
+    }
+
     protected final String metadataServiceUrl;
 
+    @VisibleForTesting // for mockito
+    protected String getMetadataServiceUrl()
+    {
+        return metadataServiceUrl;
+    }
+
     protected AbstractCloudMetadataServiceConnector(String metadataServiceUrl)
     {
+        Preconditions.checkNotNull(metadataServiceUrl, METADATA_URL_PROPERTY + 
" for a connector can not be null");
         this.metadataServiceUrl = metadataServiceUrl;
     }
 
     public String apiCall(String query) throws IOException
     {
-        return apiCall(metadataServiceUrl, query, 200);
+        return apiCall(getMetadataServiceUrl(), query, 200);

Review Comment:
   Nevertheless, I think this is not needed. I saw your mock and the reason why 
it fails with NPE is passing `anyString()` as url arg for `apiCall` - simply 
change it to `any()` and it will accept nulls.
   



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