AVRO-4028: Avro.AvroException: Unable to find type 'IDictionary<string, Foo>' in all loaded assemblies#3072
AVRO-4028: Avro.AvroException: Unable to find type 'IDictionary<string, Foo>' in all loaded assemblies#3072kkkars wants to merge 3 commits intoapache:mainfrom
Conversation
|
|
||
| if (TryGetIDictionaryItemTypeName(name, out var itemTypesName)) | ||
| { | ||
| var key = itemTypesName[0].GetType().Name; |
There was a problem hiding this comment.
The logic on the line 135 (if (name == t.Name || name == t.FullName ..) compare in case sensetive way. So it's not able to handle string (system name is String)
.GetType().Name helps to handle string type correctly (changing string to String).
That is not a flexible solution and it requires key to always be a string. Changing the type names comparing logic also does not sound like a good idea.
| catch | ||
| { | ||
| } |
Check notice
Code scanning / CodeQL
Poor error handling: empty catch block
| catch | ||
| { | ||
| } |
Check notice
Code scanning / CodeQL
Generic catch clause
| case Schema.Type.Array: | ||
| { | ||
| ArraySchema arrSchema = schema as ArraySchema; | ||
| Type itemSchema = GetType(arrSchema.ItemSchema); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null
| { | ||
| return FindType(named.Fullname); | ||
| MapSchema mapSchema = schema as MapSchema; | ||
| Type itemSchema = GetType(mapSchema.ValueSchema); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null
What is the purpose of the change
This pull request improves type finding logic of ObjectCreator.cs helping to handle nested dictionaries (map in the map).
Fixes the issue https://issues.apache.org/jira/browse/AVRO-4028
Verifying this change
(Please pick one of the following options)
This change is a trivial rework. New test cases were added to an existing unit test (TestGetTypeAssignable(), ObjectCreatorTests.cs) to validate nested dictionaries are handled correctly.
Documentation
This pull request does not introduce a new feature