-Fixed infinite loop from an input error when reading an array and error handling is catching the error

-Fixed base object error not being handled when deserializing
This commit is contained in:
James Newton-King
2012-04-28 01:41:56 +12:00
parent d63e662bda
commit a0fd6bb3e0
5 changed files with 196 additions and 10 deletions
@@ -113,17 +113,32 @@ namespace Newtonsoft.Json.Serialization
JsonContract contract = GetContractSafe(objectType);
JsonConverter converter = GetConverter(contract, null, null);
if (reader.TokenType == JsonToken.None && !ReadForType(reader, contract, converter != null, false))
try
{
if (contract != null && !contract.IsNullable)
throw JsonSerializationException.Create(reader, "No JSON content found and type '{0}' is not nullable.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
JsonConverter converter = GetConverter(contract, null, null);
return null;
if (reader.TokenType == JsonToken.None && !ReadForType(reader, contract, converter != null, false))
{
if (contract != null && !contract.IsNullable)
throw JsonSerializationException.Create(reader, "No JSON content found and type '{0}' is not nullable.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
return null;
}
return CreateValueNonProperty(reader, objectType, contract, converter, null);
}
catch (Exception ex)
{
if (IsErrorHandled(null, contract, null, reader.Path, ex))
{
HandleError(reader, 0);
return null;
}
else
{
throw;
}
}
return CreateValueNonProperty(reader, objectType, contract, converter, null);
}
private JsonSerializerProxy GetInternalSerializer()