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/26 14:32:57 UTC

[GitHub] [flink-statefun] igalshilman opened a new pull request #38: [FLINK-16290][http] Add validation to the HTTP endpoint schema

igalshilman opened a new pull request #38: [FLINK-16290][http] Add validation to the HTTP endpoint schema
URL: https://github.com/apache/flink-statefun/pull/38
 
 
   This PR adds a check for the user supplied endpoint (in `module.yaml`) to be a uri with
   a schema, that is either `http` or `https`.
   Failing to do so, would cause a `NPE` at runtime due to the way okhttp`s `HttpUrl` handles URIs with a missing schema.

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

[GitHub] [flink-statefun] tzulitai closed pull request #38: [FLINK-16290][http] Add validation to the HTTP endpoint schema

Posted by GitBox <gi...@apache.org>.
tzulitai closed pull request #38: [FLINK-16290][http] Add validation to the HTTP endpoint schema
URL: https://github.com/apache/flink-statefun/pull/38
 
 
   

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

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

Posted by GitBox <gi...@apache.org>.
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

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

Posted by GitBox <gi...@apache.org>.
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_r385449944
 
 

 ##########
 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();
 
 Review comment:
   `schema` should be renamed `scheme`

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

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

Posted by GitBox <gi...@apache.org>.
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