Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3524

When bean contains a property of type URL the json writer is trying to connect to the URL and retreive the contents rather than returning just the URL as a string

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.6
    • 2.2.3
    • Plugin - JSON
    • None
    • java 1.6 running under windows or linux

    • Important

    Description

      When a bean being serialized into a JSON string contains a member of type URL the JSONWriter identifys the URL itself as a bean type, this recusrivly looks at all the properties of the URL object and reteives the reader methods for each one which it invokes and repeats the process based on the returned object.

      The URL class contains a bunch of properties including content which has the getContent method as the reader.

      when this method is invoked the URL class will make the HTTP request and return the html content, if the URL is not valid it will thrown an exception.

      THe following is a list of the properties and the associated reader methods from the URL class

      Property name authority
      Accessor method is public java.lang.String java.net.URL.getAuthority()

      Property name content
      Accessor method is public final java.lang.Object java.net.URL.getContent() throws java.io.IOException

      Property name defaultPort
      Accessor method is public int java.net.URL.getDefaultPort()

      Property name file
      Accessor method is public java.lang.String java.net.URL.getFile()

      Property name host
      Accessor method is public java.lang.String java.net.URL.getHost()

      Property name path
      Accessor method is public java.lang.String java.net.URL.getPath()

      Property name port
      Accessor method is public int java.net.URL.getPort()

      Property name protocol
      Accessor method is public java.lang.String java.net.URL.getProtocol()

      Property name query
      Accessor method is public java.lang.String java.net.URL.getQuery()

      Property name ref
      Accessor method is public java.lang.String java.net.URL.getRef()

      Property name userInfo
      Accessor method is public java.lang.String java.net.URL.getUserInfo()

      i think the JSONWriter needs a special case for the URL object as you would not want the getContent method being invoked.

      Attachments

        1. WW-3524.patch
          2 kB
          Maurizio Cucchiara
        2. WW-3524-2.patch
          13 kB
          Maurizio Cucchiara

        Activity

          People

            maurizio.cucchiara Maurizio Cucchiara
            matt.cooper@jdwilliams.co.uk matthew cooper
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: