1 Reply Latest reply on Apr 24, 2006 4:18 PM by Glauber Silva

    Problems transport big collection of bigdecimal - probably b

    Glauber Silva Newbie

      When I call a ejb3 method and this return a big collection (> 1000 items), in the moment which of pass the collection over net, some elements have values changes (sometimes :-( ). Very strange. See:


      @Stateless
      @Remote(MakeListOfBigDecimal.class)
      public class MakeListOfBigDecimalBean {
      
       public List makeList(){
      
       List list = new ArrayList(12020);
      
       for (int i = 0; i < 12020; i++) {
      
       BigDecimal anyValue = null;
       if (i % 2 == 0){
       anyValue = new BigDecimal("1.25");
       }else{
       anyValue = new BigDecimal("2.13");
       }
      
       anyValue = anyValue.setScale(2, BigDecimal.ROUND_HALF_EVEN);
       list.add(anyValue);
       }
      
      
       BigDecimal sum = BigDecimal.ZERO;
       sum = sum.setScale(2, BigDecimal.ROUND_HALF_EVEN);
      
       for (Iterator iter = list.iterator(); iter.hasNext();) {
       BigDecimal bd = (BigDecimal) iter.next();
       sum = sum.add(bd);
       }
      
       System.out.println("SUM INSIDE MakeListOfBigDecimalBean: " + sum);
      
      
       return list;
      
       }
      
      }
      


      @Stateless
      @Remote(ReadAndSumBigDecimalList.class)
      public class ReadAndSumBigDecimalListBean {
      
       @EJB
       private MakeListOfBigDecimal makeListOfBigDecimal;
      
       public void doSumAfterRemoteCall(){
      
       List list = makeListOfBigDecimal.makeList();
      
       BigDecimal sum = BigDecimal.ZERO;
       sum = sum.setScale(2, BigDecimal.ROUND_HALF_EVEN);
      
       for (Iterator iter = list.iterator(); iter.hasNext();) {
       BigDecimal bd = (BigDecimal) iter.next();
       sum = sum.add(bd);
       }
      
       System.out.println("SUM INSIDE ReadAndSumBigDecimalListBean: " + sum);
      
      
       }
      
      }
      


      The output after 4 calls:
      SUM INSIDE MakeListOfBigDecimalBean: 20313.80
      SUM INSIDE ReadAndSumBigDecimalListBean: 20312.04
      SUM INSIDE MakeListOfBigDecimalBean: 20313.80
      SUM INSIDE ReadAndSumBigDecimalListBean: 20313.80
      SUM INSIDE MakeListOfBigDecimalBean: 20313.80
      SUM INSIDE ReadAndSumBigDecimalListBean: 20312.04
      SUM INSIDE MakeListOfBigDecimalBean: 20313.80
      SUM INSIDE ReadAndSumBigDecimalListBean: 20314.68


      If I change @Remote and put @Local, all works fine..

      My JBoss version is - 4.0.4.CR2

      Glauber