Bigtop
  1. Bigtop
  2. BIGTOP-258

Compilation Error in sqoop-integration project when using Eclipse

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.1.0
    • Fix Version/s: 0.3.0
    • Component/s: Tests
    • Labels:
      None
    • Environment:

      RHEL 6.1, 64-bit
      Eclipse 3.7 SR1

      Description

      The squoop-integration project has a compiler error in these 2 files:
      1) IntegrationTestSqoopHBase.groovy
      2) IntegrationTestSqoopHive.groovy

      In both cases, the setUp method has a statement that's attempting to assign a value to a final field:
      MYSQL_ROOTPW = " -p$MYSQL_ROOTPW";

        Activity

        Hide
        Roman Shaposhnik added a comment -

        I'm actually pretty sure this is legitimate groovy. Now, with Groovy, of course, there's no standard so one has to rely on the implementation to determine things like that. Lets see:

        $ cat q.groovy
        class Q {
        private static final String S = System.getProperty("S", "");
        String getS()

        { return S; }

        }

        println new Q().getS();

        $ groovy -DS=roman q.groovy
        roman
        $

        Show
        Roman Shaposhnik added a comment - I'm actually pretty sure this is legitimate groovy. Now, with Groovy, of course, there's no standard so one has to rely on the implementation to determine things like that. Lets see: $ cat q.groovy class Q { private static final String S = System.getProperty("S", ""); String getS() { return S; } } println new Q().getS(); $ groovy -DS=roman q.groovy roman $
        Hide
        Will McQueen added a comment -

        Hi Roman,

        In the code shown with your comment, there's no problem because the final field "S" is not being re-assigned... it's assigned only once. Try compiling the following class with the standard groovyc:

        [will@will-laptop test]$ cat Test.groovy
        class Test {
        private static final CONSTANT = 42;

        public void foo()

        { CONSTANT = 43; }

        }

        I get this compile error:
        [will@will-laptop test]$ groovyc Test.groovy
        org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
        Test.groovy: 5: cannot modify static final field 'CONSTANT' outside of static initialization block.
        @ line 5, column 5.
        CONSTANT = 43;
        ^

        Do you get the same compiler error?

        I've att'd a patch that just removes the final field for the var in both files.

        Show
        Will McQueen added a comment - Hi Roman, In the code shown with your comment, there's no problem because the final field "S" is not being re-assigned... it's assigned only once. Try compiling the following class with the standard groovyc: [will@will-laptop test] $ cat Test.groovy class Test { private static final CONSTANT = 42; public void foo() { CONSTANT = 43; } } I get this compile error: [will@will-laptop test] $ groovyc Test.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Test.groovy: 5: cannot modify static final field 'CONSTANT' outside of static initialization block. @ line 5, column 5. CONSTANT = 43; ^ Do you get the same compiler error? I've att'd a patch that just removes the final field for the var in both files.
        Hide
        Will McQueen added a comment -

        Patch att'd – BIGTOP-258.patch

        Show
        Will McQueen added a comment - Patch att'd – BIGTOP-258 .patch
        Hide
        Roman Shaposhnik added a comment -

        Aha! So you're worried about the code in setUp(). That's a legitimate concern. But I think the proper way of fixing it is to change that code, since we're typically following a paradigm of having env. dependencies as final precisely so that they don't get altered inside of tests themselves. So perhaps something like:

        shell.exec("cat $DATA_DIR/mysql-create-db.sql | $MYSQL_COMMAND -u root $

        {''.equals(MYSQL_ROOTPW) ?: '-p' + MYSQL_ROOTPW}

        ");

        Show
        Roman Shaposhnik added a comment - Aha! So you're worried about the code in setUp(). That's a legitimate concern. But I think the proper way of fixing it is to change that code, since we're typically following a paradigm of having env. dependencies as final precisely so that they don't get altered inside of tests themselves. So perhaps something like: shell.exec("cat $DATA_DIR/mysql-create-db.sql | $MYSQL_COMMAND -u root $ {''.equals(MYSQL_ROOTPW) ?: '-p' + MYSQL_ROOTPW} ");
        Hide
        Will McQueen added a comment -

        Agreed, lgtm

        Show
        Will McQueen added a comment - Agreed, lgtm
        Hide
        Roman Shaposhnik added a comment -

        Could you, please, submit a patch?

        Show
        Roman Shaposhnik added a comment - Could you, please, submit a patch?
        Hide
        Will McQueen added a comment -

        Sure

        Show
        Will McQueen added a comment - Sure
        Hide
        Will McQueen added a comment -

        New patch submitted. Please see att'd BIGTOP-258-2.patch.

        Show
        Will McQueen added a comment - New patch submitted. Please see att'd BIGTOP-258 -2.patch.
        Hide
        Roman Shaposhnik added a comment -

        +1

        Show
        Roman Shaposhnik added a comment - +1

          People

          • Assignee:
            Will McQueen
            Reporter:
            Will McQueen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development