Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-3175

Make MediaRange parser linient to accept invalid Accept header generated by Oracle JDK HttpUrlConnection

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Servlets Post 2.3.2
    • Servlets Post 2.3.4
    • Servlets
    • None

    Description

      While making a call to Sling using Java URLConnection we get following exception [1]. The root cause is due to parsing of invalid Accept header being sent as part of request

      Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
      

      The problem here is that this header is added by JDK itself [0] and at times its not possible to change the request property of URLConnection created by third party library. Would be helpful to make Sling MediaRange parser more linient

      [0] http://hg.openjdk.java.net/jdk6/jdk6-gate/jdk/file/tip/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
      [1] 15.10.2013 16:51:01.646 WARN [10.40.247.115 [1381836061645] POST /rpc/protocol/model/rf HTTP/1.1] org.apache.sling.servlets.post.impl.helper.MediaRangeList Error registering media type *; q=.2 java.lang.ArrayIndexOutOfBoundsException: 1
      at org.apache.sling.servlets.post.impl.helper.MediaRangeList$MediaRange.setType(MediaRangeList.java:237)
      at org.apache.sling.servlets.post.impl.helper.MediaRangeList$MediaRange.<init>(MediaRangeList.java:191)
      at org.apache.sling.servlets.post.impl.helper.MediaRangeList.init(MediaRangeList.java:90)
      at org.apache.sling.servlets.post.impl.helper.MediaRangeList.<init>(MediaRangeList.java:56)
      at org.apache.sling.servlets.post.impl.SlingPostServlet.createPostResponse(SlingPostServlet.java:279)
      at org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:185)

      Attachments

        1. SLING-3175.patch
          3 kB
          Chetan Mehrotra

        Activity

          People

            chetanm Chetan Mehrotra
            chetanm Chetan Mehrotra
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: