Skip to content

Commit

Permalink
Updated bindings to fix CA-285680, whereby the health check upload re…
Browse files Browse the repository at this point in the history
…quests

were broken due to the Json library changing the format of date strings
even when they were deserialized as strings.

Signed-off-by: Konstantina Chremmou <[email protected]>
  • Loading branch information
kc284 authored and MihaelaStoica committed Mar 22, 2018
1 parent 29cdf22 commit 8250e08
Show file tree
Hide file tree
Showing 2 changed files with 2,057 additions and 2,038 deletions.
23 changes: 21 additions & 2 deletions XenModel/XenAPI/JsonRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public string JsonRPC

internal abstract class JsonResponse<T>
{
[JsonProperty("id", Required = Required.AllowNull )] public int Id = 0;
[JsonProperty("id", Required = Required.AllowNull)] public int Id = 0;

[JsonProperty("result", Required = Required.Default)] public T Result = default(T);

Expand Down Expand Up @@ -211,8 +211,9 @@ private T Rpc<T>(string callName, JToken parameters, JsonSerializer serializer)
// for performance reasons it's preferable to deserialize directly
// from the Stream rather than allocating strings inbetween
// therefore the latter will be done only in DEBUG mode

#if DEBUG
var settings = new JsonSerializerSettings {Formatting = Formatting.Indented, Converters = serializer.Converters};
var settings = CreateSettings(serializer.Converters);
#endif

using (var str = webRequest.GetRequestStream())
Expand Down Expand Up @@ -278,5 +279,23 @@ private T Rpc<T>(string callName, JToken parameters, JsonSerializer serializer)
}
}
}

private JsonSerializerSettings CreateSettings(IList<JsonConverter> converters)
{
return new JsonSerializerSettings
{
#if DEBUG
Formatting = Formatting.Indented,
#endif
Converters = converters,
DateParseHandling = DateParseHandling.None
};
}

private JsonSerializer CreateSerializer(IList<JsonConverter> converters)
{
var settings = CreateSettings(converters);
return JsonSerializer.Create(settings);
}
}
}
Loading

0 comments on commit 8250e08

Please sign in to comment.