cjelger commented on a change in pull request #21:
URL:
https://github.com/apache/sling-org-apache-sling-models-impl/pull/21#discussion_r507682094
##########
File path: src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
##########
@@ -404,11 +430,7 @@ public boolean isModelClass(@NotNull Class<?> type) {
ModelType model = (ModelType)
Proxy.newProxyInstance(modelClass.getType().getClassLoader(), new Class<?>[] {
modelClass.getType() }, handlerResult.getValue());
if (modelAnnotation.cache()) {
- Map<Class<?>, SoftReference<Object>>
adaptableCache = adapterCache.get(cacheKey);
- if (adaptableCache == null) {
- adaptableCache =
Collections.synchronizedMap(new WeakHashMap<Class<?>, SoftReference<Object>>());
- adapterCache.put(cacheKey, adaptableCache);
- }
+ Map<Class<?>, SoftReference<Object>>
adaptableCache = getOrCreateCache(adaptable);
Review comment:
No, the same adaptable can be adapted to multiple types. For example,
the request could be adapted first to `MyFirstModel.class` and then to
`MySecondModel.class`: so in the first case there is no cache and of course no
cached model, but in the 2nd case, the cache exists but doesn't contain a
cached model for the `MySecondModel.class` (but would contain a cached model
for `MyFirstModel.class`).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]