Skip to content
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

HOTFIX - (ADF) suppress exceptions during deserialization #1338

Merged
merged 1 commit into from Aug 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -261,6 +261,26 @@ public void ValidateLinkedServiceWithDictionaryPropertyThrowsForMissingRequiredP
Assert.Throws<InvalidOperationException>(() => this.TestLinkedServiceValidation(json));
Assert.Contains("is required", ex.Message);
}

[Theory]
[InlineData(@"{
name: ""MyLinkedService"",
properties:
{
type: ""AzureSqlDatabase"",
typeProperties: {
connectionString: null
}
}
}")]
[Trait(TraitName.TestType, TestType.Unit)]
[Trait(TraitName.Function, TestType.Conversion)]

public void CanConvertLinkedServiceWithNullTypePropertyValuesTest(string json)
{
JsonSampleInfo sample = new JsonSampleInfo("LinkedServiceWithNullTypePropertyValues", json, null);
this.TestLinkedServiceJson(sample);
}
#endif

#endregion Tests
Expand Down
Expand Up @@ -179,6 +179,38 @@ public void UnknownCopySourceDoesNotThrowExceptionTest(string json)
Assert.Null(((CopyActivity)pipeline.Properties.Activities[0].TypeProperties).Source);
}

[Theory]
[InlineData(@"{
name: ""MyPipelineName"",
properties:
{
activities:
[
{
type: ""Copy"",
name: ""TestActivity"",
description: ""Test activity description"",
typeProperties:
{
source: null,
sink: null
},
inputs: [ { name: ""InputSqlDA"" } ],
outputs: [ { name: ""OutputBlobDA"" } ],
linkedServiceName: ""MyLinkedServiceName""
}
]
}
}")]
[Trait(TraitName.TestType, TestType.Unit)]
[Trait(TraitName.Function, TestType.Conversion)]

public void CanConvertPipelineWithNullTypePropertyValuesTest(string json)
{
JsonSampleInfo sample = new JsonSampleInfo("PipelineWithNullTypePropertyValues", json, null);
this.TestPipelineJson(sample);
}

[Theory, InlineData(PipelineJsonSamples.HDInsightPipeline)]
[Trait(TraitName.TestType, TestType.Unit)]
[Trait(TraitName.Function, TestType.Conversion)]
Expand Down
Expand Up @@ -106,6 +106,31 @@ public void TableUnregisteredTypeTest(string unregisteredTypeJson)
Assert.IsType<GenericDataset>(table.Properties.TypeProperties);
}

[Theory]
[InlineData(@"{
name: ""MyTable"",
properties:
{
type: ""AzureBlob"",
linkedServiceName: ""MyBlobLinkedService"",
typeProperties: {
connectionString: null
},
availability: {
frequency: ""Day"",
interval: 1
}
}
}")]
[Trait(TraitName.TestType, TestType.Unit)]
[Trait(TraitName.Function, TestType.Conversion)]

public void CanConvertTableWithNullTypePropertyValuesTest(string json)
{
JsonSampleInfo sample = new JsonSampleInfo("TableWithNullTypePropertyValues", json, null);
this.TestTableJson(sample);
}

private void TestTableJson(JsonSampleInfo info)
{
string json = info.Json;
Expand Down
Expand Up @@ -108,7 +108,7 @@ public bool TryGetRegisteredType(string typeName, out Type type)
}
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
protected override object ReadJsonWrapper(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
JObject obj = JObject.Load(reader);

Expand Down
Expand Up @@ -42,6 +42,23 @@ static PolymorphicTypeConverter()
ReservedTypesList = new Lazy<Dictionary<string, Type>>(GetReservedTypes);
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
try
{
return this.ReadJsonWrapper(reader, objectType, existingValue, serializer);
}
catch (Exception)
{
// Suppress any exception during deserialization;
// we should assume that the service sends back valid JSON,
// so return null if there is any problem deserializing.
return null;
}
}

protected abstract object ReadJsonWrapper(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer);

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
JObject obj = JObject.FromObject(
Expand Down
Expand Up @@ -28,7 +28,7 @@ internal class TypePropertiesConverter : PolymorphicTypeConverter<TypeProperties
private readonly CamelCasePropertyNamesContractResolver camelCaseResolver =
new CamelCasePropertyNamesContractResolver();

public override object ReadJson(
protected override object ReadJsonWrapper(
JsonReader reader,
Type objectType,
object existingValue,
Expand Down
Expand Up @@ -5,7 +5,7 @@
Microsoft.Azure.Management.DataFactories
-->
<SdkNuGetPackage Include="Microsoft.Azure.Management.DataFactories">
<PackageVersion>2.0.0</PackageVersion>
<PackageVersion>2.0.1</PackageVersion>
<Folder>$(MSBuildThisFileDirectory)</Folder>
</SdkNuGetPackage>
</ItemGroup>
Expand Down
Expand Up @@ -21,7 +21,7 @@
[assembly: AssemblyDescription("Provides Microsoft Azure Data Factory management operations.")]

[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]

[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
Expand Down