Uploaded image for project: 'Commons OGNL (Dormant)'
  1. Commons OGNL (Dormant)
  2. OGNL-126

Don't call setter properly

    XMLWordPrintableJSON

Details

    Description

      import ognl.Ognl;

      import ognl.OgnlContext;

      import com.opensymphony.xwork2.util.OgnlValueStack;

      import java.io.Serializable;

      public class OGNLDebug {

      public static void main(String[] argv)

      { Result result = new Result(); OgnlValueStack stack = new OgnlValueStack(); stack.push(result); stack.setValue("example.param", "0"); stack.setValue("brokenExample.param", "0"); System.out.println("example.param: " + result.getExample().getParam() ); System.out.println("brokenExample.param: " + result.getBrokenExample().getParam() ); }

      }

      class Result {

      private Example example = new Example();

      private BrokenExample brokenExample = new BrokenExample();

      public Result() {

      }

      public Example getExample()

      { return example; }

      public void setExample(Example example)

      { this.example = example; }

      public BrokenExample getBrokenExample()

      { return brokenExample; }

      public void setBrokenExample(BrokenExample brokenExample)

      { this.brokenExample = brokenExample; }

      }

      class Example {

      private Integer param;

      public Integer getParam()

      { return param; }



      public void setParam(Integer param) { this.param = param; }

      }



      interface Cracker<T extends Serializable>{ T getParam(); void setParam(T param); }



      class BrokenExample implements Cracker<Integer>{

      private Integer param;



      public Integer getParam() { return param; }

      public void setParam(Integer param)

      { this.param = param; }

      }

      Expected result

      example.param: 0

      brokenExample.param: 0

      Actual result:

      example.param: 0

      brokenExample.param : null

      Attachments

        Issue Links

          Activity

            People

              jkuhnert Jesse Kuhnert
              vladimir.balandin Vladimir A. Balandin
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: