You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/08/14 14:15:39 UTC

[GitHub] vvraskin closed pull request #67: remove hardcoded env variables for run handler

vvraskin closed pull request #67: remove hardcoded env variables for run handler
URL: https://github.com/apache/incubator-openwhisk-runtime-java/pull/67
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java b/core/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java
index dc6c861..209f436 100644
--- a/core/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java
+++ b/core/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java
@@ -28,6 +28,8 @@
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
 import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
 
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
@@ -136,14 +138,15 @@ public void handle(HttpExchange t) throws IOException {
             try {
                 InputStream is = t.getRequestBody();
                 JsonParser parser = new JsonParser();
-                JsonElement ie = parser.parse(new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)));
-                JsonObject inputObject = ie.getAsJsonObject().getAsJsonObject("value");
+                JsonObject body = parser.parse(new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))).getAsJsonObject();
+                JsonObject inputObject = body.getAsJsonObject("value");
 
                 HashMap<String, String> env = new HashMap<String, String>();
-                for (String p : new String[] { "api_key", "namespace", "action_name", "activation_id", "deadline" }) {
+                Set<Map.Entry<String, JsonElement>> entrySet = body.entrySet();
+                for(Map.Entry<String, JsonElement> entry : entrySet){
                     try {
-                        String val = ie.getAsJsonObject().getAsJsonPrimitive(p).getAsString();
-                        env.put(String.format("__OW_%s", p.toUpperCase()), val);
+                        if(!entry.getKey().equalsIgnoreCase("value"))
+                            env.put(String.format("__OW_%s", entry.getKey().toUpperCase()), entry.getValue().getAsString());
                     } catch (Exception e) {}
                 }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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