Uploaded image for project: 'Directory Client API'
  1. Directory Client API
  2. DIRAPI-379

NPE on ill formed error response

Watch issueLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.0.AM2
    • 2.1.1
    • None

    Description

      When one passes a presumably ill formed response to an instance of
      Dsmlv2ResponseParser, a NullPointerException might be thrown.

      Example Response:

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

      Relevant parts of the stacktrace:

      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]
      

      Relevant part of the code:

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

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            PatrickPeer Patrick Peer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment