You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use json-schema in a multi-threaded environment, and as outlined in issues #310 and #242, the heavy use of caching at the class level could potentially lead to race conditions.
We encounter this problem intermittently. In trying to reproduce the issue, I discovered a problem with the JSON::Util::URI.normalize_ref method, which can be reproduced even without using multiple threads:
The errors disappear if the cache is cleared between assertions. Apparently, the implementation of the .normalize_ref method stores parsed #foo in the cache and subsequently modifies it by extending it with the base URL. Therefore, the same ref could be resolved differently, ignoring the base argument entirely.
We use
json-schema
in a multi-threaded environment, and as outlined in issues #310 and #242, the heavy use of caching at the class level could potentially lead to race conditions.We encounter this problem intermittently. In trying to reproduce the issue, I discovered a problem with the
JSON::Util::URI.normalize_ref
method, which can be reproduced even without using multiple threads:The test above fails with the following output:
The errors disappear if the cache is cleared between assertions. Apparently, the implementation of the
.normalize_ref
method stores parsed#foo
in the cache and subsequently modifies it by extending it with the base URL. Therefore, the sameref
could be resolved differently, ignoring thebase
argument entirely.Steps to Reproduce
Run the following test:
Observe the failure and the incorrect URI being returned due to cache usage.
Clear the cache (
JSON::Util::URI.clear_cache
) between assertions to see the errors go away.You can find the problem reproduced in this PR #515
Expected Behavior
The
JSON::Util::URI.normalize_ref
method should respect thebase
argument and resolve the reference correctly for each call.Actual Behavior
The method caches the parsed
ref
argument and incorrectly resolves it by ignoring thebase
argument on subsequent calls.The text was updated successfully, but these errors were encountered: