rombert commented on PR #18:
URL: 
https://github.com/apache/sling-org-apache-sling-models-jacksonexporter/pull/18#issuecomment-3836427737

   I tried a real basic fix in the Sling models impl
   
   ```diff
   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 b0624c0..5b7fb8e 100644
   --- a/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
   +++ b/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
   @@ -48,6 +48,7 @@ import jakarta.servlet.ServletRequest;
    import jakarta.servlet.ServletRequestEvent;
    import jakarta.servlet.ServletRequestListener;
    import org.apache.commons.lang3.StringUtils;
   +import org.apache.sling.api.SlingHttpServletRequest;
    import org.apache.sling.api.SlingJakartaHttpServletRequest;
    import org.apache.sling.api.adapter.Adaptable;
    import org.apache.sling.api.adapter.AdapterFactory;
   @@ -826,7 +827,9 @@ public class ModelAdapterFactory implements 
AdapterFactory, Runnable, ModelFacto
                final Class<?>[] paramTypes = 
constructor.getConstructor().getParameterTypes();
                if (paramTypes.length == 1) {
                    Class<?> paramType = 
constructor.getConstructor().getParameterTypes()[0];
   -                if (paramType.isInstance(adaptable)) {
   +                if (paramType.isInstance(adaptable)
   +                        || (paramType == SlingHttpServletRequest.class
   +                                && adaptable instanceof 
SlingJakartaHttpServletRequest)) {
                        return constructor;
                    }
                }
   ```
   
   with that change on top of the two metioned PRs I get a different failure
   
   ```
   [ERROR] Tests run: 8, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 
5.431 s <<< FAILURE! -- in 
org.apache.sling.models.jacksonexporter.it.testing.exporter.ExporterIT
   [ERROR] 
org.apache.sling.models.jacksonexporter.it.testing.exporter.ExporterIT.testFailedExport
 -- Time elapsed: 3.116 s <<< ERROR!
   org.apache.sling.models.factory.ModelClassException: Could not yet find an 
adapter factory for the model class 
org.apache.sling.models.jacksonexporter.it.testbundle.exporter.BaseComponent 
from adaptable class 
org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource
        at 
org.apache.sling.models.impl.ModelAdapterFactory.getImplementationTypeForAdapterType(ModelAdapterFactory.java:340)
        at 
org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:379)
        at 
org.apache.sling.models.impl.ModelAdapterFactory.exportModelForResource(ModelAdapterFactory.java:1385)
        at 
org.apache.sling.models.jacksonexporter.it.testing.exporter.ExporterIT.testFailedExport(ExporterIT.java:381)
   ```
   
   The test fails in a different way than expected
   
   
https://github.com/apache/sling-org-apache-sling-models-jacksonexporter/blob/ffd1bc74726601977a97320919e998a9298c0098/src/test/java/org/apache/sling/models/jacksonexporter/it/testing/exporter/ExporterIT.java#L374-L390


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