-
-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted list in Alias service. Fixes #2056
- Loading branch information
Showing
2 changed files
with
3 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3959378
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.
Håkan sorry on closer inspection it looks like the exception is due to the _jsonSettings for Newtonsoft in the following method (DistributedCache: Get(stringkey).
If you see the output (Immediate Window below) from two calls one without the _jsonSettings and one with you can see the Deserialization fails with the _jsonSettings passed in the JsonConvert.DeserializeObject call (see below output examples)
Piranha.Cache.DistributedCache
[Immediate Window]
?JsonConvert.DeserializeObject(json);
Count = 3
[0]: {Piranha.Services.AliasService.AliasUrlCacheEntry}
[1]: {Piranha.Services.AliasService.AliasUrlCacheEntry}
[2]: {Piranha.Services.AliasService.AliasUrlCacheEntry}
?JsonConvert.DeserializeObject(json, _jsonSettings);
Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll
As you can see from above the first call without _jsonSettings returns the data successfully, but with _jsonSettings an exception is thrown in the Newtonsoft.Json.dll
3959378
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.
Sounds weird since the test did confirm throwing the exception before the update, but the test passed fine after
ToList()
had been added to the code.3959378
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.
Interesting...do you have a unit test for Piranha.Cache.DistributedCache class method public T Get(string key) where the key passed returns JSON as a collection of Piranha.Services.AliasService.AliasUrlCacheEntry types and does that test pass?
3959378
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.
The test modified in the commit is run without cache, with memory cache and with distributed cache. When adding the additional api-call I verified the exception before the fix and then verified that it did not occur after the fix.
3959378
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 Håkan sounds good. I will wait until the next Nuget package release, as I am not in an immediate rush to upgrade, so will check this again in a future update. Thanks again for all your help investigating and resolving this issue.