Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-1251

NPE in ObjectWritable.toString

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.1-incubating
    • io
    • None

    Description

      ObjectWritable is a fancy wrapper around single reference named t.

      ObjectWritable is internally inconsistent about whether t==null is allowed.

      toString suggests that t==null is an illegal state, since it throws NPE:

          public String toString() {
              return this.t.toString();
          }
      

      Compare with isEmpty, which suggests that t==null is a legal state:

          public boolean isEmpty() {
              return null == this.t;
          }
      

      IMO toString should just tolerate null.

      Why does this matter? One case where this toString gets invoked is Java serialization with debugging info turned on ("sun.io.serialization.extendedDebugInfo" sys prop). When so configured, Java serialization code (ObjectOutputStream) invokes toString on the objects it processes. If toString throws this NPE, serialization fails. This is frustrating, since serialization of null ObjectWritables works fine with debugging info suppressed, but breaks with debugging info enabled.

      Attachments

        Activity

          People

            okram Marko A. Rodriguez
            dalaro Dan LaRocque
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: