Skip to content

Commit 3474132

Browse files
committed
Merge branch '2.x' of github.com:elastic/elasticsearch-net into 2.x
2 parents 52360b9 + 36b3768 commit 3474132

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Elasticsearch.Net/Auditing/Audit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Audit(AuditEvent type, DateTime started)
4040

4141
public override string ToString()
4242
{
43-
var took = Started - Ended;
43+
var took = Ended - Started;
4444
return $"Node: {Node?.Uri}, Event: {Event.GetStringValue()} NodeAlive: {Node?.IsAlive}, Took: {took}";
4545
}
4646
}

src/Nest/CommonAbstractions/SerializationBehavior/JsonNetSerializer.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class JsonNetSerializer : IElasticsearchSerializer
3535
/// The size of the buffer to use when writing the serialized request
3636
/// to the request stream
3737
/// </summary>
38-
// Performance tests as part of https://github.com/elastic/elasticsearch-net/issues/1899 indicate this
38+
// Performance tests as part of https://github.com/elastic/elasticsearch-net/issues/1899 indicate this
3939
// to be a good compromise buffer size for performance throughput and bytes allocated.
4040
protected virtual int BufferSize => 1024;
4141

@@ -44,7 +44,8 @@ protected virtual void ModifyJsonSerializerSettings(JsonSerializerSettings setti
4444

4545
protected virtual IList<Func<Type, JsonConverter>> ContractConverters => null;
4646

47-
protected readonly ConcurrentDictionary<int, IPropertyMapping> Properties = new ConcurrentDictionary<int, IPropertyMapping>();
47+
protected ConcurrentDictionary<int, IPropertyMapping> Properties => throw new Exception("subclass of JsonNetSerializer should not call this field");
48+
protected readonly ConcurrentDictionary<string, IPropertyMapping> PropertiesFixed = new ConcurrentDictionary<string, IPropertyMapping>();
4849

4950
public JsonNetSerializer(IConnectionSettingsValues settings, Action<JsonSerializerSettings, IConnectionSettingsValues> settingsModifier) : this(settings, null, settingsModifier) { }
5051

@@ -102,9 +103,11 @@ public virtual void Serialize(object data, Stream writableStream, SerializationF
102103
public virtual IPropertyMapping CreatePropertyMapping(MemberInfo memberInfo)
103104
{
104105
IPropertyMapping mapping;
105-
if (Properties.TryGetValue(memberInfo.GetHashCode(), out mapping)) return mapping;
106+
var memberInfoString = $"{memberInfo.DeclaringType?.FullName}.{memberInfo.Name}";
107+
if (PropertiesFixed.TryGetValue(memberInfoString, out mapping))
108+
return mapping;
106109
mapping = PropertyMappingFromAttributes(memberInfo);
107-
this.Properties.TryAdd(memberInfo.GetHashCode(), mapping);
110+
this.PropertiesFixed.TryAdd(memberInfoString, mapping);
108111
return mapping;
109112
}
110113

0 commit comments

Comments
 (0)