Index: ehcache-core/src/main/java/net/sf/ehcache/pool/impl/DefaultSizeOfEngine.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/**\n *  Copyright Terracotta, Inc.\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\");\n *  you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software\n *  distributed under the License is distributed on an \"AS IS\" BASIS,\n *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  See the License for the specific language governing permissions and\n *  limitations under the License.\n */\n\npackage net.sf.ehcache.pool.impl;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.net.URL;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\n\nimport net.sf.ehcache.CacheException;\nimport net.sf.ehcache.pool.Size;\nimport net.sf.ehcache.pool.SizeOfEngine;\nimport net.sf.ehcache.pool.sizeof.AgentSizeOf;\nimport net.sf.ehcache.pool.sizeof.ReflectionSizeOf;\nimport net.sf.ehcache.pool.sizeof.SizeOf;\nimport net.sf.ehcache.pool.sizeof.UnsafeSizeOf;\nimport net.sf.ehcache.pool.sizeof.MaxDepthExceededException;\nimport net.sf.ehcache.pool.sizeof.filter.AnnotationSizeOfFilter;\nimport net.sf.ehcache.pool.sizeof.filter.CombinationSizeOfFilter;\nimport net.sf.ehcache.pool.sizeof.filter.ResourceSizeOfFilter;\nimport net.sf.ehcache.pool.sizeof.filter.SizeOfFilter;\nimport net.sf.ehcache.util.ClassLoaderUtil;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\n/**\n * @author Alex Snaps\n */\npublic class DefaultSizeOfEngine implements SizeOfEngine {\n\n    /**\n     * System property defining a user specific resource based size-of filter.\n     * <p>\n     * The resource pointed to by this property must be a list of fully qualified\n     * field or class names, one per line:\n     * <pre>\n     * # This is a comment\n     * org.mycompany.domain.MyType\n     * org.mycompany.domain.MyOtherType.myField\n     * </pre>\n     * Fields or types matching against lines in this resource will be ignored\n     * when calculating the size of the object graph.\n     */\n    public static final String USER_FILTER_RESOURCE = \"net.sf.ehcache.sizeof.filter\";\n    \n    private static final Logger LOG = LoggerFactory.getLogger(DefaultSizeOfEngine.class.getName());\n    private static final String VERBOSE_DEBUG_LOGGING = \"net.sf.ehcache.sizeof.verboseDebugLogging\";\n\n    private static final SizeOfFilter DEFAULT_FILTER;\n    private static final boolean USE_VERBOSE_DEBUG_LOGGING;\n\n    static {\n        Collection<SizeOfFilter> filters = new ArrayList<SizeOfFilter>();\n        filters.add(new AnnotationSizeOfFilter());\n        try {\n            filters.add(new ResourceSizeOfFilter(SizeOfEngine.class.getResource(\"builtin-sizeof.filter\")));\n        } catch (IOException e) {\n            LOG.warn(\"Built-in sizeof filter could not be loaded: {}\", e);\n        }\n        SizeOfFilter userFilter = getUserFilter();\n        if (userFilter != null) {\n            filters.add(userFilter);\n        }\n        DEFAULT_FILTER = new CombinationSizeOfFilter(filters.toArray(new SizeOfFilter[filters.size()]));\n\n        USE_VERBOSE_DEBUG_LOGGING = getVerboseSizeOfDebugLogging();\n    }\n\n    private final SizeOf sizeOf;\n    private final int maxDepth;\n    private final boolean abortWhenMaxDepthExceeded;\n\n    /**\n     * Creates a default size of engine using the best available sizing algorithm.\n     * @param maxDepth the max object graph that will be traversed.\n     * @param abortWhenMaxDepthExceeded true if the object traversal should be aborted when the max depth is exceeded\n     */\n    public DefaultSizeOfEngine(int maxDepth, boolean abortWhenMaxDepthExceeded) {\n        this(maxDepth, abortWhenMaxDepthExceeded, false);\n    }\n\n    /**\n     * Creates a default size of engine using the best available sizing algorithm.\n     * @param maxDepth the max object graph that will be traversed.\n     * @param abortWhenMaxDepthExceeded true if the object traversal should be aborted when the max depth is exceeded\n     * @param silent true if no info log explaining which agent was chosen should be printed\n     */\n    public DefaultSizeOfEngine(int maxDepth, boolean abortWhenMaxDepthExceeded, boolean silent) {\n        this.maxDepth = maxDepth;\n        this.abortWhenMaxDepthExceeded = abortWhenMaxDepthExceeded;\n        SizeOf bestSizeOf;\n        try {\n            bestSizeOf = new AgentSizeOf(DEFAULT_FILTER);\n            if (!silent) {\n                LOG.info(\"using Agent sizeof engine\");\n            }\n        } catch (UnsupportedOperationException e) {\n            try {\n                bestSizeOf = new UnsafeSizeOf(DEFAULT_FILTER);\n                if (!silent) {\n                    LOG.info(\"using Unsafe sizeof engine\");\n                }\n            } catch (UnsupportedOperationException f) {\n                try {\n                    bestSizeOf = new ReflectionSizeOf(DEFAULT_FILTER);\n                    if (!silent) {\n                        LOG.info(\"using Reflection sizeof engine\");\n                    }\n                } catch (UnsupportedOperationException g) {\n                    throw new CacheException(\"A suitable SizeOf engine could not be loaded: \" + e + \", \" + f + \", \" + g);\n                }\n            }\n        }\n\n        this.sizeOf = bestSizeOf;\n    }\n\n    private DefaultSizeOfEngine(DefaultSizeOfEngine defaultSizeOfEngine, int maxDepth, boolean abortWhenMaxDepthExceeded) {\n        this.sizeOf = defaultSizeOfEngine.sizeOf;\n        this.maxDepth = maxDepth;\n        this.abortWhenMaxDepthExceeded = abortWhenMaxDepthExceeded;\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    public SizeOfEngine copyWith(int maxDepth, boolean abortWhenMaxDepthExceeded) {\n        return new DefaultSizeOfEngine(this, maxDepth, abortWhenMaxDepthExceeded);\n    }\n\n    private static SizeOfFilter getUserFilter() {\n        String userFilterProperty = System.getProperty(USER_FILTER_RESOURCE);\n\n        if (userFilterProperty != null) {\n            List<URL> filterUrls = new ArrayList<URL>();\n            try {\n                filterUrls.add(new URL(userFilterProperty));\n            } catch (MalformedURLException e) {\n                LOG.debug(\"MalformedURLException using {} as a URL\", userFilterProperty);\n            }\n            try {\n                filterUrls.add(new File(userFilterProperty).toURI().toURL());\n            } catch (MalformedURLException e) {\n                LOG.debug(\"MalformedURLException using {} as a file URL\", userFilterProperty);\n            }\n            filterUrls.add(ClassLoaderUtil.getStandardClassLoader().getResource(userFilterProperty));\n            for (URL filterUrl : filterUrls) {\n                SizeOfFilter filter;\n                try {\n                    filter = new ResourceSizeOfFilter(filterUrl);\n                    LOG.info(\"Using user supplied filter @ {}\", filterUrl);\n                    return filter;\n                } catch (IOException e) {\n                    LOG.debug(\"IOException while loading user size-of filter resource\", e);\n                }\n            }\n        }\n        return null;\n    }\n\n    private static boolean getVerboseSizeOfDebugLogging() {\n\n        String verboseString = System.getProperty(VERBOSE_DEBUG_LOGGING, \"false\").toLowerCase();\n\n        return verboseString.equals(\"true\");\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    public Size sizeOf(final Object key, final Object value, final Object container) {\n        Size size;\n        try {\n            size = sizeOf.deepSizeOf(maxDepth, abortWhenMaxDepthExceeded, key, value, container);\n        } catch (MaxDepthExceededException e) {\n            LOG.warn(e.getMessage());\n            LOG.warn(\"key type: \" + key.getClass().getName());\n            LOG.warn(\"key: \" + key);\n            LOG.warn(\"value type: \" + value.getClass().getName());\n            LOG.warn(\"value: \" + value);\n            LOG.warn(\"container: \" + container);\n            size = new Size(e.getMeasuredSize(), false);\n        }\n\n        if (USE_VERBOSE_DEBUG_LOGGING && LOG.isDebugEnabled()) {\n            LOG.debug(\"size of {}/{}/{} -> {}\", new Object[]{key, value, container, size.getCalculated()});\n        }\n        return size;\n    }\n}\n
===================================================================
--- ehcache-core/src/main/java/net/sf/ehcache/pool/impl/DefaultSizeOfEngine.java	(revision 8343)
+++ ehcache-core/src/main/java/net/sf/ehcache/pool/impl/DefaultSizeOfEngine.java	(revision )
@@ -191,12 +191,7 @@
         try {
             size = sizeOf.deepSizeOf(maxDepth, abortWhenMaxDepthExceeded, key, value, container);
         } catch (MaxDepthExceededException e) {
-            LOG.warn(e.getMessage());
-            LOG.warn("key type: " + key.getClass().getName());
-            LOG.warn("key: " + key);
-            LOG.warn("value type: " + value.getClass().getName());
-            LOG.warn("value: " + value);
-            LOG.warn("container: " + container);
+            logMaxDepthExceeded(key, value, container, e);
             size = new Size(e.getMeasuredSize(), false);
         }
 
@@ -204,5 +199,14 @@
             LOG.debug("size of {}/{}/{} -> {}", new Object[]{key, value, container, size.getCalculated()});
         }
         return size;
+    }
+
+    protected void logMaxDepthExceeded(final Object key, final Object value, final Object container, final MaxDepthExceededException e) {
+        LOG.warn(e.getMessage());
+        LOG.warn("key type: " + key.getClass().getName());
+        LOG.warn("key: " + key);
+        LOG.warn("value type: " + value.getClass().getName());
+        LOG.warn("value: " + value);
+        LOG.warn("container: " + container);
     }
 }
