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

Remove unnecessary synchronization from endpoint reader/writer caches #167

Merged
merged 2 commits into from
Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -675,19 +675,14 @@ protected EP_CONFIG _endpointForWriting(Object value, Class<?> type, Type generi
return _configForWriting(locateMapper(type, mediaType), annotations, _defaultWriteView);
}

EP_CONFIG endpoint;
AnnotationBundleKey key = new AnnotationBundleKey(annotations, type);
synchronized (_writers) {
endpoint = _writers.get(key);
}
EP_CONFIG endpoint = _writers.get(key);
// not yet resolved (or not cached any more)? Resolve!
if (endpoint == null) {
MAPPER mapper = locateMapper(type, mediaType);
endpoint = _configForWriting(mapper, annotations, _defaultWriteView);
// and cache for future reuse
synchronized (_writers) {
_writers.put(key.immutableKey(), endpoint);
}
_writers.put(key.immutableKey(), endpoint);
}
return endpoint;
}
Expand Down Expand Up @@ -836,19 +831,14 @@ protected EP_CONFIG _endpointForReading(Class<Object> type, Type genericType, An
return _configForReading(locateMapper(type, mediaType), annotations, _defaultReadView);
}

EP_CONFIG endpoint;
AnnotationBundleKey key = new AnnotationBundleKey(annotations, type);
synchronized (_readers) {
endpoint = _readers.get(key);
}
EP_CONFIG endpoint = _readers.get(key);
// not yet resolved (or not cached any more)? Resolve!
if (endpoint == null) {
MAPPER mapper = locateMapper(type, mediaType);
endpoint = _configForReading(mapper, annotations, _defaultReadView);
// and cache for future reuse
synchronized (_readers) {
_readers.put(key.immutableKey(), endpoint);
}
_readers.put(key.immutableKey(), endpoint);
}
return endpoint;
}
Expand Down