Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"null" wrongly injected into Java method after "before" or "after" statement use with Php #1464

Open
fjtheknight opened this issue Jun 21, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@fjtheknight
Copy link
Contributor

commented Jun 21, 2019

Using "after" or "before" statements to produce Php code results in the injection of "null" into the body of the Java method

  • The next example demonstrates the problem:
class TestMultiLang {

  name;
  public String customGetName () Java{
  }

   before customGetName Php {
  //this is a custom get method for Php
  }
  
  before customGetName Ruby {
    //this is a custom get method for Ruby
  }
  
}

Generated customGetName() method for Java:

  // line 8 "model.ump"
   public String customGetName(){
    // line 10 "model.ump"
    null
    // END OF UMPLE BEFORE INJECTION
    // line 14 "model.ump"
    
    // END OF UMPLE BEFORE INJECTION
    
  }
  • Using both "after" and "before" statements
   before customGetName Php {
  //this is a custom get method for Php
  }
    
   after customGetName Php {
  //this is after a custom get method for Php
  }

results in the injection of two "null" strings:

  // line 8 "model.ump"
   public String customGetName(){
    // line 10 "model.ump"
    null
    // END OF UMPLE BEFORE INJECTION
    
    // line 14 "model.ump"
    null
    // END OF UMPLE AFTER INJECTION
  }
  • Using the same statement multiple times:
 before customGetName Php {
  //this is a custom get method for Php
  }
    
   before customGetName Php {
  //this is the same custom get method for Php
  }

will generate "null" string only once:

  // line 8 "model.ump"
   public String customGetName(){
    // line 10 "model.ump"
    null
    // END OF UMPLE BEFORE INJECTION
    // line 14 "model.ump"
    
    // END OF UMPLE BEFORE INJECTION
    
  }
@TimLethbridge

This comment has been minimized.

Copy link
Member

commented Jun 21, 2019

@fjtheknight Good catch! I leave this for you to solve.

@fjtheknight

This comment has been minimized.

Copy link
Contributor Author

commented Jun 27, 2019

The comments used for the header and footer of the injection (//something) are not compatible with Ruby (should be #something). This is a problem with any code injected into a Ruby method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.