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

Problems transport big collection of bigdecimal - probably b

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

• 1. Re: Problems transport big collection of bigdecimal - probab

I find the bug.
It is in the cache of jboss serialization = 1.0.0.RC1

http://jira.jboss.com/jira/browse/JBSER-61

Fix in 1.0.0CR6 of jboss-serialization, but performance degree.

"Rare Duplications On System.identityHashMap can cause exception"

Warning: May cause a lot of errors, like a "select sum(*) from salary" in a database return 111658.90
and iterate a collection of java objects return 111500.90.

Glauber