Grails
  1. Grails
  2. GRAILS-8666

Multiple public methods of same name in controller cause compilation error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0 final
    • Fix Version/s: 2.0.1, 2.1-RC1
    • Component/s: Controllers
    • Labels:
      None

      Description

      If you have more than one public method of the same name in a controller, you get an error like this:

      | Compiling 1 source files.
      | Error Compilation error: startup failed:
      /Users/pledbrook/dev/projects/scratch/tmp20/grails-app/controllers/tmp20/TestController.groovy: 5: Repetitive method name/signature for method 'java.lang.Object tokenStr()' in class 'tmp20.TestController'.
       @ line 5, column 4.
            def tokenStr() {
            ^
      
      /Users/pledbrook/dev/projects/scratch/tmp20/grails-app/controllers/tmp20/TestController.groovy: -1: Repetitive method name/signature for method 'java.lang.Object tokenStr()' in class 'tmp20.TestController'.
       @ line -1, column -1.
      2 errors
      

      As methods are actions, it makes sense that you should only be allowed one method with such a name (although it this is the case, we should document it). But then the error should be far more informative, i.e. it should say that you can't have more than one public method with the name in a controller because they are treated as actions.

      Just try to compile the attached bug report to see the error.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jeff Scott Brown
            Reporter:
            Peter Ledbrook
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development