podam icon indicating copy to clipboard operation
podam copied to clipboard

depth always reset

Open bakomchik opened this issue 11 years ago • 6 comments

podam-5.3.1.RELEASE /uk/co/jemos/podam/api/PodamFactoryImpl.java:1839

    Integer depth = pojos.get(realAttributeType);
            if (depth == null) {
                depth = -1;
            }
            if (depth <= strategy.getMaxDepth(pojo.getClass())) {

                pojos.put(realAttributeType, depth + 1);, //<-- increment depth

                attributeValue = this.manufacturePojoInternal(
                        realAttributeType, attributeMetadata, pojos, genericTypeArgsAll);
                pojos.put(realAttributeType, depth);//<-- put -1 again

            } 

bakomchik avatar Apr 29 '15 14:04 bakomchik

For example

class A {
    List<B> childs;
}
class B{
    A parentB;

}

will cause infinity loop Memorizing is not a option. Because list (childs) will be contain copy of same instance

bakomchik avatar Apr 29 '15 14:04 bakomchik

Two things:

  1. Depth limits traversal depth on the POJO's attribute tree. There is nothing wrong with it.
  2. I've tried example and there is no stack overflow: https://travis-ci.org/daivanov/podam/builds/60575048

daivanov avatar Apr 29 '15 18:04 daivanov

With 5.3.2-SNAPSHOT parent-children relation is correctly filled, when memoization enabled; https://travis-ci.org/daivanov/podam/builds/60601308

daivanov avatar Apr 30 '15 06:04 daivanov

Could I close this issue or will you update it with additional information how to reproduce the problem and/or stack trace?

daivanov avatar May 02 '15 09:05 daivanov

I think we can close this issue and if @bakomchik finds further issues he can log them here.

mtedone avatar May 02 '15 09:05 mtedone

Ok. Please create new issue, if anything further will be discovered!

daivanov avatar May 02 '15 10:05 daivanov