gleono commented on code in PR #92:
URL:
https://github.com/apache/openwhisk-runtime-dotnet/pull/92#discussion_r1796216015
##########
core/net6.0/proxy/Apache.OpenWhisk.Runtime.Common/Init.cs:
##########
@@ -54,58 +53,52 @@ public async Task<Run> HandleRequest(HttpContext
httpContext)
{
await httpContext.Response.WriteError("Cannot initialize
the action more than once.");
Console.Error.WriteLine("Cannot initialize the action more
than once.");
- return (new Run(Type, Method, Constructor,
AwaitableMethod));
+ return new Run(_type, _method, _constructor,
_awaitableMethod);
}
- string body = await new
StreamReader(httpContext.Request.Body).ReadToEndAsync();
+ using StreamReader reader = new(httpContext.Request.Body);
+ string body = await reader.ReadToEndAsync();
JObject inputObject = JObject.Parse(body);
- if (!inputObject.ContainsKey("value"))
+ if (!inputObject.TryGetValue("value", out JToken? message) ||
message is not JObject valueObj)
{
await httpContext.Response.WriteError("Missing main/no
code to execute.");
- return (null);
+ return null;
}
- JToken message = inputObject["value"];
+ string main = valueObj.TryGetValue("main", out JToken?
mainToken) ? mainToken.ToString() : string.Empty;
+ string code = valueObj.TryGetValue("code", out JToken?
codeToken) ? codeToken.ToString() : string.Empty;
+ bool binary = valueObj.TryGetValue("binary", out JToken?
binaryToken) && binaryToken.ToObject<bool>();
- if (message["main"] == null || message["binary"] == null ||
message["code"] == null)
+ if (string.IsNullOrWhiteSpace(main) ||
string.IsNullOrWhiteSpace(code))
Review Comment:
These are checking only for white space because `main` and `code` are
guaranteed to not be `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]