Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5675

java.lang.ClassCastException: java.net.URI cannot be cast to java.lang.String when adding Location to Response

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.0-milestone2
    • Fix Version/s: 3.0
    • Component/s: JAX-RS
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Exception:

      java.lang.ClassCastException: java.net.URI cannot be cast to java.lang.String

      Test:

       Response response = getWebClient()
                      .path("/blob")
                      .type(MediaType.MULTIPART_FORM_DATA)
                      .post(multipartBody);
      

      serverside resource:

              URI blobId = UriBuilder.fromResource(getClass()).build(gridFSDBFile.getId());
              return Response.created(blobId).build();
      

      because inside WebClient handleResponse -> AbstractClient the values are assumed to be string arrays, but is an URI object:

       boolean splitHeaders = 
                  MessageUtils.isTrue(outMessage.getContextualProperty(HEADER_SPLIT_PROPERTY));
              for (Map.Entry<String, List<String>> entry : protocolHeaders.entrySet()) {
                  if (null == entry.getKey()) {
                      continue;
                  }
                  if (entry.getValue().size() > 0) {
                      if (HttpUtils.isDateRelatedHeader(entry.getKey())) {
                          currentResponseBuilder.header(entry.getKey(), entry.getValue().get(0));
                          continue;                    
                      }
                      for (String val : entry.getValue()) {
                          if (splitHeaders) {
                              String[] values;
                              if (val == null || val.length() == 0) {
      
      

        Attachments

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              davidkarlsen@gmail.com David J. M. Karlsen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: