You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2017/12/08 15:26:57 UTC
[sling-org-apache-sling-models-impl] branch master updated:
SLING-7292 - only register the callback registry if it isn't empty
This is an automated email from the ASF dual-hosted git repository.
justin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git
The following commit(s) were added to refs/heads/master by this push:
new 56acddf SLING-7292 - only register the callback registry if it isn't empty
56acddf is described below
commit 56acddf62e55653283d750a938228aea3030b78b
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Dec 8 10:25:43 2017 -0500
SLING-7292 - only register the callback registry if it isn't empty
---
.../sling/models/impl/ModelAdapterFactory.java | 33 +++++++++++++---------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java b/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
index 1897a51..9b1bdc1 100644
--- a/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
+++ b/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
@@ -588,11 +588,6 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
MapBackedInvocationHandler handler = new MapBackedInvocationHandler(methods);
DisposalCallbackRegistryImpl registry = new DisposalCallbackRegistryImpl();
- if (adaptable instanceof ServletRequest) {
- registerRequestCallbackRegistry((ServletRequest) adaptable, registry);
- } else {
- registerCallbackRegistry(handler, registry);
- }
final Map<ValuePreparer, Object> preparedValues = new HashMap<>(VALUE_PREPARERS_COUNT);
@@ -603,7 +598,16 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
missingElements.addMissingElementExceptions(new MissingElementException(method.getAnnotatedElement(), t));
}
}
- registry.seal();
+
+ if (!registry.callbacks.isEmpty()) {
+ registry.seal();
+
+ if (adaptable instanceof ServletRequest) {
+ registerRequestCallbackRegistry((ServletRequest) adaptable, registry);
+ } else {
+ registerCallbackRegistry(handler, registry);
+ }
+ }
if (!missingElements.isEmpty()) {
return new Result<>(missingElements);
}
@@ -665,12 +669,6 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
}
}
- if (adaptable instanceof SlingHttpServletRequest) {
- registerRequestCallbackRegistry((SlingHttpServletRequest) adaptable, registry);
- } else {
- registerCallbackRegistry(object, registry);
- }
-
InjectCallback callback = new SetFieldCallback(object);
InjectableField[] injectableFields = modelClass.getInjectableFields();
@@ -683,7 +681,16 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
}
}
- registry.seal();
+ if (!registry.callbacks.isEmpty()) {
+ registry.seal();
+
+ if (adaptable instanceof SlingHttpServletRequest) {
+ registerRequestCallbackRegistry((SlingHttpServletRequest) adaptable, registry);
+ } else {
+ registerCallbackRegistry(object, registry);
+ }
+
+ }
if (!missingElements.isEmpty()) {
return new Result<>(missingElements);
}
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].