You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lécharny (Jira)" <ji...@apache.org> on 2022/07/27 03:09:00 UTC
[jira] [Commented] (DIRAPI-379) NPE on ill formed error response
[ https://issues.apache.org/jira/browse/DIRAPI-379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17571708#comment-17571708 ]
Emmanuel Lécharny commented on DIRAPI-379:
------------------------------------------
Sorry for the **LONG**delay...
This is right. The {{RequestID}} is optional and should be treated as is in the code - aka ignored -.
I have fixed the code to set -1 in this case (and also in other messages where the {{requestID}} is optional.
> NPE on ill formed error response
> --------------------------------
>
> Key: DIRAPI-379
> URL: https://issues.apache.org/jira/browse/DIRAPI-379
> Project: Directory Client API
> Issue Type: Bug
> Affects Versions: 2.0.0.AM2
> Reporter: Patrick Peer
> Priority: Minor
>
> When one passes a presumably ill formed response to an instance of
> Dsmlv2ResponseParser, a NullPointerException might be thrown.
> Example Response:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
> <soap:Header>
> <Action xmlns="http://www.w3.org/2005/08/addressing">urn:ihe:iti:2010:ProviderInformationFeedResponse</Action>
> <MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:e7b4def8-0ad7-46d9-b9db-3389b6c3c7f7</MessageID>
> <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
> <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:e529d797-d54f-41c0-8cea-d5e2c194afbf</RelatesTo>
> </soap:Header>
> <soap:Body>
> <batchResponse xmlns="urn:oasis:names:tc:DSML:2:0:core" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <errorResponse type="couldNotConnect">
> <message>ERR_04110_CANNOT_CONNECT_TO_SERVER Cannot connect to the server: Connection refused</message>
> </errorResponse>
> </batchResponse>
> </soap:Body>
> </soap:Envelope>
> {code}
> Relevant parts of the stacktrace:
> {noformat}
> java.lang.NullPointerException: Cannot invoke "org.apache.directory.api.dsmlv2.response.ErrorResponse.getTypeDescr(org.apache.directory.api.dsmlv2.response.ErrorResponse$ErrorResponseType)" because "errorResponse" is null
> at org.apache.directory.api.dsmlv2.response.Dsmlv2ResponseGrammar$9.action(Dsmlv2ResponseGrammar.java:524) ~[api-all-2.0.0.AM2.jar:2.0.0.AM2]
> at org.apache.directory.api.dsmlv2.AbstractGrammar.processTag(AbstractGrammar.java:162) ~[api-all-2.0.0.AM2.jar:2.0.0.AM2]
> at org.apache.directory.api.dsmlv2.AbstractGrammar.executeAction(AbstractGrammar.java:123) ~[api-all-2.0.0.AM2.jar:2.0.0.AM2]
> at org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser.parse(Dsmlv2ResponseParser.java:127) ~[api-all-2.0.0.AM2.jar:2.0.0.AM2]
> {noformat}
> Relevant part of the code:
> {code:java}
> public final class Dsmlv2ResponseGrammar extends AbstractGrammar implements Grammar
> {
> ...
> private final GrammarAction errorResponseCreation = new GrammarAction( "Create Error Response" )
> {
> public void action( Dsmlv2Container container ) throws XmlPullParserException
> {
> ErrorResponse errorResponse = null;
> ...
> attributeValue = xpp.getAttributeValue( "", "requestID" );
> if ( attributeValue != null )
> {
> errorResponse = new ErrorResponse( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ), null );
> ...
> }
>
> attributeValue = xpp.getAttributeValue( "", "type" );
> if ( attributeValue != null )
> {
> // When errorResponse was not initialized with the requestID attributeValue, an NPE will be raised here
> if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.NOT_ATTEMPTED ) ) )
> ...
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@directory.apache.org
For additional commands, e-mail: dev-help@directory.apache.org