-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't use Serializer context #59
Conversation
Relates:elastic/elasticsearch-net#4791 This commit updates the AttributesTableConverter and FeatureConverter to not use the serializer context when deserializing AttributesTable. The serializer context is not safe to use multithreaded, which can be the case when JsonConverters from NetTopologySuite.IO.GeoJson are added to an singleton instance of JsonSerializer not under the control of NetTopologySuite.IO.GeoJson.
@FObermaier have you written the JSON code or I'm wrong? can you check this? |
See RP #36 I think it has a test with a complex attribute table which was not merged... |
@HarelM ah ok, |
@HarelM the changes in this PR are only to deserialization of |
@russcam my bad, you are right. [GeoJsonIssueNumber(59)]
[Test]
public void TestGeoJsonWithNestedObjectsInProperties()
{
const string geojson =
@"{
""type"": ""Feature"",
""geometry"": {
""type"": ""Point"",
""coordinates"": [1, 2]
},
""properties"": {
""complex"": {
""a"": [""b"", ""c""],
""d"": [""e"", ""f""]
}
}
}
}";
Feature f = null;
Assert.That(() => f = new GeoJsonReader().Read<Feature>(geojson), Throws.Nothing);
Assert.That(f, Is.Not.Null);
Assert.That(f.Attributes["complex"], Is.InstanceOf<AttributesTable>());
var innerTable = f.Attributes["complex"] as AttributesTable;
Assert.That(innerTable["a"], Is.InstanceOf<List<object>>());
Assert.That(innerTable["d"], Is.InstanceOf<List<object>>());
}
} Which passed, so it seems that this commit does not break the reading of the properties. |
probably I made some confusion, the but we talk about it isn't directly related to @HarelM problem as far as I remember. |
@DGuidi I searched for I think removing the use of context is a good move as it'll ensure that the Json converters will work irrespective of how JsonSerializer is constructed, whether as a singleton or a new instance per usage. |
@russcam give a check and I've found no other usages of the context property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good catch.
thanks again for the contribution |
No worries! |
Relates:elastic/elasticsearch-net#4791
This commit updates the AttributesTableConverter and FeatureConverter to not use the serializer context when deserializing AttributesTable. The serializer context is not safe to use multithreaded, which can be the case when JsonConverters from NetTopologySuite.IO.GeoJson are added to an singleton instance of JsonSerializer not under the control of NetTopologySuite.IO.GeoJson.