{"record":{"id":"dfaab321c43ae51a","repo":"pinpoint-apm/pinpoint","slug":"negative-cache-size-size","errorCode":null,"errorMessage":"negative cache size:${size}","messagePattern":"negative cache size:(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/transformer/DefaultHierarchyCaches.java","lineNumber":35,"sourceCode":"\nimport com.github.benmanes.caffeine.cache.Cache;\nimport com.github.benmanes.caffeine.cache.Caffeine;\nimport com.github.benmanes.caffeine.cache.LoadingCache;\nimport com.navercorp.pinpoint.profiler.cache.CaffeineBuilder;\n\n/**\n * @author jaehong.kim\n */\npublic class DefaultHierarchyCaches implements HierarchyCaches {\n    private static final int MAX = 64;\n\n    private final LoadingCache<String, Hierarchy> caches;\n    private final int cacheSize;\n    private final int cacheEntrySize;\n\n    public DefaultHierarchyCaches(final int size, final int entrySize) {\n        if (size <= 0) {\n            throw new IllegalArgumentException(\"negative cache size:\" + size);\n        }\n\n        this.cacheSize = getCacheSize(size);\n\n        this.cacheEntrySize = getCacheEntrySize(entrySize);\n\n        this.caches = CaffeineBuilder.newBuilder()\n                .maximumSize(this.cacheSize)\n                .initialCapacity(this.cacheSize)\n                .build(this::loadEntry);\n    }\n\n    private Hierarchy loadEntry(String key) {\n        return new Hierarchy();\n    }\n\n    private int getCacheEntrySize(int entrySize) {\n        if (entrySize <= 0) {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/transformer/DefaultHierarchyCaches.java#L17-L53","documentation":"DefaultHierarchyCaches validates its constructor arguments: the cache size must be strictly positive. Passing size <= 0 throws IllegalArgumentException 'negative cache size:<size>' before any caching structure is built.","triggerScenarios":"Instantiating new DefaultHierarchyCaches(size, entrySize) with size = 0 or a negative value, typically from misconfigured profiler properties (e.g. profiler.jdbc.maxcachesize style settings).","commonSituations":"Config file sets a cache-size property to 0 or negative; property parsing yields 0 when a value is missing or unparseable and defaults are skipped.","solutions":["Set the cache size configuration to a positive integer","Check where the value is parsed and add a default fallback for empty/unparseable values","Validate configuration at startup before constructing the caches"],"exampleFix":"// before\nint size = Integer.parseInt(props.getProperty(\"cache.size\")); // \"0\"\nHierarchyCaches c = new DefaultHierarchyCaches(size, entrySize);\n// after\nint size = Math.max(1, Integer.parseInt(props.getProperty(\"cache.size\", \"1024\")));\nHierarchyCaches c = new DefaultHierarchyCaches(size, entrySize);","handlingStrategy":"validation","validationCode":"int size = Integer.parseInt(cfg.getProperty(\"cache.size\", \"1024\"));\nif (size <= 0) throw new IllegalArgumentException(\"cache.size must be > 0, got \" + size);","typeGuard":null,"tryCatchPattern":"try { caches = new DefaultHierarchyCaches(size, entrySize); } catch (IllegalArgumentException e) { log.error(\"bad cache config: {}\", e.getMessage()); caches = new DefaultHierarchyCaches(1024, 1024); }","preventionTips":["Validate cache size config at startup with sane defaults","Never allow 0/negative values from properties files","Document valid ranges for cache size settings"],"tags":["java","cache","configuration","validation","illegal-argument"],"backgroundTag":"invalid-config-value","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}