private static void warnWhenTooMany()

in archaius2-core/src/main/java/com/netflix/archaius/ConfigProxyFactory.java [562:579]


    private static <T> void warnWhenTooMany(Map<T, Integer> counters, T countKey, int limit, Supplier<String> objectDescription) {
        int currentCount = counters.merge(countKey, 1, Integer::sum);

        // Emit warning if we're over the limit BUT only when the current count is a multiple of the limit :-)
        // This is to avoid being *too* noisy
        if (LOG.isWarnEnabled() &&
            currentCount >= limit &&
            (currentCount % limit == 0 )) {

                LOG.warn(
                        "Too many {} objects are being created ({} so far).\n" +
                        "Please review the calling code to prevent memory leaks.\n" +
                        "Normal usage for ConfigProxyFactory is to create singletons via your DI mechanism.\n" +
                        "For special use cases that *require* creating multiple instances you can tune reporting\n" +
                        "by setting the `{}` config key to a higher threshold.\nStack trace for debugging follows:",
                        objectDescription.get(), currentCount, EXCESSIVE_PROXIES_LIMIT, new Throwable());
        }
    }