Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8186

Builder ExternalStrategy constructors have trouble with private fields

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.x, 2.5.x
    • Fix Version/s: 2.5.0-beta-2
    • Component/s: None
    • Labels:
      None

      Description

      An undocumented feature of @Builder is that the builder's constructor can set default values for the fields. See http://stackoverflow.com/questions/35066664/default-values-in-groovy-builder-ast

      I tried creating an ExternalStrategy @Builder annotation for BaseClientDetails with a constructor that set a default scope. I received a MissingMethodException exception, which I thought was odd.

      I added some tests to BuilderTransformTest that demonstrate apparent problems using the external builder in two situations:
      1) A groovy class with private fields and manually defined setters.
      2) A java class with a private Set field and a setter that takes a Collection

      The tests are here: https://github.com/jterhune/groovy/commit/5b2eb74cc8184235b5235b7fd4c80b241799bbc5

      I noticed this in 2.4.x. My tests fail in the 2.5.x branch also.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                paulk Paul King
                Reporter:
                jktw Jason Terhune-Wold
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: