You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Thomas Mueller (Jira)" <ji...@apache.org> on 2022/01/03 16:04:00 UTC
[jira] [Comment Edited] (SLING-9896) change statuscode in SlingPostServlet for PersistenceException
[ https://issues.apache.org/jira/browse/SLING-9896?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17468075#comment-17468075 ]
Thomas Mueller edited comment on SLING-9896 at 1/3/22, 4:03 PM:
----------------------------------------------------------------
Ah the problem is in
https://github.com/apache/sling-org-apache-sling-servlets-post/blob/org.apache.sling.servlets.post-2.4.2/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java#L105
{noformat}
public void run(final SlingHttpServletRequest request,
final PostResponse response,
final SlingPostProcessor[] processors) throws PreconditionViolatedPersistenceException, TemporaryPersistenceException {
final VersioningConfiguration versionableConfiguration = getVersioningConfiguration(request);
try {
...
doRun(request, response, changes); <<== here
...
} catch (Exception e) {
log.error("Exception during response processing.", e);
response.setError(e);
} finally {
...
}
}
{noformat}
So the fix in the SlingPostServlet won't work in this case.
This is because the class AbstractPostOperation catches the PersistenceException (any exception, actually), and logs "Exception during response processing." (this is what I see in the log file), and then... doesn't re-throw the PersistenceException.
was (Author: tmueller):
Ah the problem is in
https://github.com/apache/sling-org-apache-sling-servlets-post/blob/org.apache.sling.servlets.post-2.4.2/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java#L105
{noformat}
public void run(final SlingHttpServletRequest request,
final PostResponse response,
final SlingPostProcessor[] processors) throws PreconditionViolatedPersistenceException, TemporaryPersistenceException {
final VersioningConfiguration versionableConfiguration = getVersioningConfiguration(request);
try {
...
doRun(request, response, changes); <<== here
...
} catch (Exception e) {
log.error("Exception during response processing.", e);
response.setError(e);
} finally {
...
}
}
{noformat}
So the fix in the SlingPostServlet won't work in this case.
> change statuscode in SlingPostServlet for PersistenceException
> --------------------------------------------------------------
>
> Key: SLING-9896
> URL: https://issues.apache.org/jira/browse/SLING-9896
> Project: Sling
> Issue Type: Improvement
> Components: Servlets
> Affects Versions: Servlets Post 2.3.36
> Reporter: Joerg Hoh
> Assignee: Robert Munteanu
> Priority: Major
> Fix For: Servlets POST 2.4.2
>
> Time Spent: 9h 20m
> Remaining Estimate: 0h
>
> When the SlingPostServlet receives a PersistenceExceptions while trying to persist the changes, it should not throw an internal server error, but a statuscode of 405, because this behavior is expected.
> Example stacktrace:
> {noformat}
> 11.11.2020 11:18:38.418 *ERROR* [172.16.123.101 [1605093518414] POST /foo/bar.html HTTP/1.1] org.apache.sling.servlets.post.impl.operations.ModifyOperation
> Exception during response processing.
> org.apache.sling.api.resource.PersistenceException: Unable to create node at /foo/bar.html
> at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.create(JcrResourceProvider.java:477) [org.apache.sling.jcr.resource:3.0.22]
> at org.apache.sling.resourceresolver.impl.providers.stateful.AuthenticatedResourceProvider.create(AuthenticatedResourceProvider.java:182) [org.apache.sling.resourceresolver:1.7.0]
> at org.apache.sling.resourceresolver.impl.helper.ResourceResolverControl.create(ResourceResolverControl.java:381) [org.apache.sling.resourceresolver:1.7.0]
> at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.create(ResourceResolverImpl.java:979) [org.apache.sling.resourceresolver:1.7.0]
> at org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateResource(AbstractCreateOperation.java:598) [org.apache.sling.servlets.post:2.3.36]
> at org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:146) [org.apache.sling.servlets.post:2.3.36]
> at org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83) [org.apache.sling.servlets.post:2.3.36]
> at org.apache.sling.servlets.post.impl.operations.AbstractPostOperation.run(AbstractPostOperation.java:99) [org.apache.sling.servlets.post:2.3.36]
> at org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:233) [org.apache.sling.servlets.post:2.3.36]
> at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:146) [org.apache.sling.api:2.22.0]
> at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:342) [org.apache.sling.api:2.22.0]
> [...]
> Caused by: javax.jcr.nodetype.ConstraintViolationException: No default node type available for /foo/bar.html
> at org.apache.jackrabbit.oak.plugins.tree.TreeUtil.addChild(TreeUtil.java:234) [org.apache.jackrabbit.oak-security-spi:1.35.0]
> at org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.addChild(NodeDelegate.java:690) [org.apache.jackrabbit.oak-jcr:1.35.0]
> at org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:314) [org.apache.jackrabbit.oak-jcr:1.35.0]
> at org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:280) [org.apache.jackrabbit.oak-jcr:1.35.0]
> at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:209) [org.apache.jackrabbit.oak-jcr:1.35.0]
> at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) [org.apache.jackrabbit.oak-jcr:1.35.0]
> at org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.java:280) [org.apache.jackrabbit.oak-jcr:1.35.0]
> at org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.java:265) [org.apache.jackrabbit.oak-jcr:1.35.0]
> at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.create(JcrResourceProvider.java:448) [org.apache.sling.jcr.resource:3.0.22]
> ... 154 common frames omitted
> {noformat}
> Discussion at https://www.mail-archive.com/dev@sling.apache.org/msg100122.html (dev@sling)
> PR: https://github.com/apache/sling-org-apache-sling-servlets-post/pull/7
--
This message was sent by Atlassian Jira
(v8.20.1#820001)