Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6889654

SAXParseException should have a better toString method

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6u14
    • Fix Version/s: 1.4.0
    • Component/s: xml
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      h1180
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      SAXParseException retains a very useful information regarding where the error occurred, yet this information is not displayed unless the caller specifically looks for SAXParseException and prints it. This is especially problematic when SAXParseException shows up in a nested exception of an exception chaining.

      To fix this, SAXParseException should implement the toString() method that returns a reasonable String representation of all the information that it holds. Something like:

          public String toString() {
              StringBuilder buf = new StringBuilder(getClass().getName());
              String message = getLocalizedMessage();
              if (message!=null) buf.append(": ").append(message);
              if (publicId!=null) buf.append(":publicId=").append(publicId);
              if (systemId!=null) buf.append(":systemId=").append(publicId);
              if (lineNumber!=-1) buf.append(":lineNumber=").append(lineNumber);
              if (columnNumber!=-1) buf.append(":columnNumber=").append(columnNumber);
              return buf.toString();
          }

      This change doesn't affect the signature, so the spec revision is not necessary.

        Attachments

          Activity

            People

            • Assignee:
              joehw Joe Wang
              Reporter:
              kkawagucsunw Kohsuke Kawaguchi (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: