You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/02/28 00:39:38 UTC

[GitHub] [flink-statefun] tzulitai commented on a change in pull request #38: [FLINK-16290][http] Add validation to the HTTP endpoint schema

tzulitai commented on a change in pull request #38: [FLINK-16290][http] Add validation to the HTTP endpoint schema
URL: https://github.com/apache/flink-statefun/pull/38#discussion_r385450514
 
 

 ##########
 File path: statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/JsonModule.java
 ##########
 @@ -251,7 +252,17 @@ private static InetSocketAddress functionAddress(JsonNode functionNode) {
 
   private static URI functionUri(JsonNode functionNode) {
     String uri = Selectors.textAt(functionNode, Pointers.Functions.FUNCTION_ENDPOINT);
-    return URI.create(uri);
+    URI typedUri = URI.create(uri);
+    @Nullable String schema = typedUri.getScheme();
+    if (schema == null) {
+      throw new IllegalArgumentException(
+          "Missing schema in " + uri + " an http or https schema must be provided.");
+    }
+    if (schema.equalsIgnoreCase("http") || schema.equalsIgnoreCase("https")) {
+      return typedUri;
+    }
+    throw new IllegalArgumentException(
 
 Review comment:
   nit: Seems like the branching here can be simplified a bit.
   
   e.g. change to 
   ```
   if (!isValidScheme(scheme)) {
       throw new IllegalArgumentException("...")
   }
   return typedUri;
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services