stefanseifert commented on a change in pull request #11:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/11#discussion_r762438504



##########
File path: 
src/main/java/org/apache/sling/models/impl/model/ModelClassConstructor.java
##########
@@ -49,16 +50,49 @@ public ModelClassConstructor(Constructor<ModelType> 
constructor, StaticInjectAnn
         }
     }
 
-    public Constructor<ModelType> getConstructor() {
+    /**
+     * Proxies the call to {@link Constructor#newInstance(Object...)}, 
checking (and
+     * setting) accessibility first.
+     * 
+     * @param parameters
+     *            the constructor parameters that are passed to
+     *            {@link Constructor#newInstance(Object...)}
+     * @return The constructed object
+     * 
+     * @throws InstantiationException when {@link 
Constructor#newInstance(Object...)} would throw
+     * @throws IllegalAccessException when {@link 
Constructor#newInstance(Object...)} would throw
+     * @throws IllegalArgumentException when {@link 
Constructor#newInstance(Object...)} would throw
+     * @throws InvocationTargetException when {@link 
Constructor#newInstance(Object...)} would throw
+     * 
+     * @see Constructor#newInstance(Object...)
+     */
+    @SuppressWarnings({"java:S3011","java:S1874"})
+    public M newInstance(Object... parameters) throws InstantiationException, 
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+        synchronized (constructor) {

Review comment:
       yes, i also think it would be worth to create a ticket to revisit that 
in the future. would be interesting to have a bit measurement. i would also 
tend to just set accessible(true), without resetting and synchronization here 
and on the other places.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to