Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-21

[cli] clone method in Option should use super.clone()

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1
    • Component/s: CLI-1.x
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

    • Bugzilla Id:
      29908

      Description

      In
      org.apache.commons.cli.Option
      public method clone is implemented by creating a new instance through one of
      the class Constructors, and then assigning values as required through the
      setter methods.

      This means that any subclasses of the Option class will not return a true
      clone, but a new Option instance instead.

      A proper implementation of clone should use super.clone() to create a new
      instance, rather than calling the class constructor. This allows shallows
      clones to propogate correctly down to subclasses.

        Attachments

        1. CLI-21.patch
          0.8 kB
          Henri Yandell
        2. bug21.patch
          3 kB
          Brian Egge

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nathan.mcdonald@optusnet.com.au Nathan McDonald
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: