{"record":{"id":"614bf8f81a312386","repo":"quarkusio/quarkus","slug":"incorrect-cp-igeldo-getcp","errorCode":null,"errorMessage":"Incorrect cp: \" + igeldo.getCp()","messagePattern":"Incorrect cp: \" \\+ igeldo\\.getCp\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java","lineNumber":577,"sourceCode":"            Pokemon igeldo = em.find(Pokemon.class, 3);\n            igeldo.setCp(2707);\n            Pokemon godzilla = em.find(Pokemon.class, 248);\n            godzilla.setCp(3834);\n            Pokemon blissey = em.find(Pokemon.class, 242);\n            blissey.setCp(2757);\n\n        });\n\n        assertRegionStats(expected, Pokemon.class.getName());\n    }\n\n    private void verifyFindByIdPokemons(int[] expectedCps, Counts expected) {\n        clearStatistics();\n\n        QuarkusTransaction.requiringNew().run(() -> {\n            Pokemon igeldo = em.find(Pokemon.class, 3);\n            if (igeldo.getCp() != expectedCps[0])\n                throw new RuntimeException(\"Incorrect cp: \" + igeldo.getCp());\n\n            Pokemon godzilla = em.find(Pokemon.class, 248);\n            if (godzilla.getCp() != expectedCps[1])\n                throw new RuntimeException(\"Incorrect cp: \" + godzilla.getCp());\n\n            Pokemon blissey = em.find(Pokemon.class, 242);\n            if (blissey.getCp() != expectedCps[2])\n                throw new RuntimeException(\"Incorrect cp: \" + blissey.getCp());\n\n        });\n\n        assertRegionStats(expected, Pokemon.class.getName());\n    }\n\n    private void storeTestPokemons(Counts expected) {\n        clearStatistics();\n\n        QuarkusTransaction.requiringNew().run(() -> {","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java#L559-L595","documentation":"RuntimeException thrown by verifyFindByIdPokemons when the Pokemon with ID 3 ('igeldo') has a combat-power (cp) value that does not match expectedCps[0]. This is a cached-entity value assertion: em.find returns the Pokemon (possibly from the second-level cache) and its cp must equal the value written by the preceding read/write phase.","triggerScenarios":"em.find(Pokemon.class, 3).getCp() != expectedCps[0] inside the verification transaction; the second-level cache served a stale entity from before the cp update, or the update transaction did not commit.","commonSituations":"Second-level cache retaining a pre-update cp for Pokemon 3; update phase rolled back or updated a different ID; running tests against a DB with leftover old cp values; cache invalidation on update not enabled for the Pokemon region.","solutions":["Confirm the update transaction that sets Pokemon 3's cp committed before verifyFindByIdPokemons runs","Check that updating an entity invalidates/updates its second-level cache entry (Hibernate does this by default; verify no custom region settings break it)","Pass the correct expectedCps array from testReadWrite matching the latest writes","Reset cache and DB between runs to avoid stale values"],"exampleFix":"// before\nPokemon igeldo = em.find(Pokemon.class, 3);\nif (igeldo.getCp() != expectedCps[0]) throw new RuntimeException(\"Incorrect cp: \" + igeldo.getCp());\n// after\nPokemon igeldo = em.find(Pokemon.class, 3);\nif (igeldo == null) throw new RuntimeException(\"Pokemon 3 missing\");\nif (igeldo.getCp() != expectedCps[0]) throw new RuntimeException(\"Incorrect cp for igeldo: \" + igeldo.getCp() + \", expected: \" + expectedCps[0]);","handlingStrategy":"validation","validationCode":"Pokemon p = em.find(Pokemon.class, 3);\nif (p == null) throw new IllegalStateException(\"Pokemon 3 not found\");\nif (p.getCp() != expectedCp) throw new IllegalStateException(\"Stale cp for Pokemon 3: \" + p.getCp() + \" != \" + expectedCp);","typeGuard":"boolean hasExpectedCp(Pokemon p, int expected) { return p != null && p.getCp() == expected; }","tryCatchPattern":"try {\n    verifyFindByIdPokemons(expectedCps, expectedCounts);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Incorrect cp\")) {\n        // evict Pokemon region and re-run write phase\n    }\n}","preventionTips":["Commit updates before cached reads and rely on Hibernate update-through-cache/invalidation","Clear or evict the region between independent test runs","Include entity id and expected value in assertion messages for diagnosis"],"tags":["hibernate-orm","cache","stale-data","integration-test"],"backgroundTag":"stale-cache-entity","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}