ehcache / sizeof

Configurable sizeOf engine for Ehcache
Apache License 2.0
105 stars 43 forks source link

ObjectGraphWalker throws the wrong exception type when max depth exceeded #28

Closed kennymacleod closed 8 years ago

kennymacleod commented 10 years ago

When ObjectGraphWalker exceeds the max depth, it throws an IllegalArgumentException. However EhcacheSizeOfEngine is expecting to catch a MaxDepthExceededException. The IllegalArgumentException bubbles up past that catch and a stack trace is logged.

This is odd, given that the sizeof engine in EhCache 2.8 throws the correct MaxDepthExceededException.

alexsnaps commented 10 years ago

This actually isn't a bug, but rather a "temporary state". The plan is to get rid of all ehcache deps in the code, which include that exception. Eventually this condition will be checked by the walker itself and Ehcache will inject the behavior (i.e. throw the exception when we've walked more than the max configured). I understand this is currently a bit confusing. But one thing we could do is have the IllegalArgException being caught and wrapped within a MaxDepthExceededException within the EhcacheSizeOfEngine, as this can (and does) reference Ehcache types, as it will eventually disappear from here and be moved to Ehcache when that only uses this code (eventually).

alexsnaps commented 8 years ago

If the "feature" is required now, it needs to be implemented using the VisitorListener (see #10)