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

GStringTemplateEngine shares binding

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2.2
    • Component/s: None
    • Labels:
      None

      Description

      The following test case fails, because GStringTemplateEngine doesn't handle the binding correctly. It is shared among calls:

          void testShouldNotShareBinding() {
              String text = "<% println delegate.books; books = books.split(\",\"); out << books %>";
      
              StringWriter sw = new StringWriter();
              GStringTemplateEngine engine = new GStringTemplateEngine();
      
              Template template = engine.createTemplate(text);
      
              Map data = [books: 'a,b,c,d']
      
      
              // round one sucess
              template.make(data).writeTo(sw);
              assert sw.toString() == '[a, b, c, d]'
      
              sw = new StringWriter();
              // round two fails
              data = [books: 'e,f,g,h']
              template.make(data).writeTo(sw);
              assert sw.toString() == '[e, f, g, h]'
      
          }
      
      

        Attachments

          Activity

            People

            • Assignee:
              melix Cédric Champeau
              Reporter:
              melix Cédric Champeau
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: