2 Replies Latest reply on Sep 14, 2010 5:37 AM by teknix1

    List/DSC issue


      Hi all,

      I'm currently building a DSC which takes in a list (java.util.List) of ints and returns the modified list. In workbench I am mapping the input and output lists to the same variable. Basically the idea behind the DSC is to modify a list and return it. Normally the variable (in LC) should simply hold the new contents of the list. Unfortunately this is not what happens. I ran different tests and basically I can see the contents of my returned list being added to the list that is specified in the output variable. I don't know why the server would do that but that's what I see.

      Here's an example:
      1. My input list holds 0 items.
      2. Invoke the DSC, it adds the number 5 to the list and returns it.
      3. My input list now holds 1 item: 5.
      4. Invoke the DSC again and this time add the number 10.
      5. Inspecting the list though the recording, you will see that it now holds 4 items: 5,10,5,10


      The reason behind the result in step 5 is that the list is passed in as a reference and that that same reference is returned.
      So basically since LC holds a reference to the list, it is already updated by the time the list is returned from my DSC. And when it is returned the returned list contents gets added to itself.


      Here's the method from the DSC:


      public java.util.List<Integer> Test1(java.util.List<Integer> lst, int item)
      return lst;

      Any help is greatly appreciated!