quarkusio/quarkus · error · RuntimeException
Incorrect cp: " + igeldo.getCp()
Error message
Incorrect cp: " + igeldo.getCp()
What it means
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.
Source
Thrown at integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java:577
Pokemon igeldo = em.find(Pokemon.class, 3);
igeldo.setCp(2707);
Pokemon godzilla = em.find(Pokemon.class, 248);
godzilla.setCp(3834);
Pokemon blissey = em.find(Pokemon.class, 242);
blissey.setCp(2757);
});
assertRegionStats(expected, Pokemon.class.getName());
}
private void verifyFindByIdPokemons(int[] expectedCps, Counts expected) {
clearStatistics();
QuarkusTransaction.requiringNew().run(() -> {
Pokemon igeldo = em.find(Pokemon.class, 3);
if (igeldo.getCp() != expectedCps[0])
throw new RuntimeException("Incorrect cp: " + igeldo.getCp());
Pokemon godzilla = em.find(Pokemon.class, 248);
if (godzilla.getCp() != expectedCps[1])
throw new RuntimeException("Incorrect cp: " + godzilla.getCp());
Pokemon blissey = em.find(Pokemon.class, 242);
if (blissey.getCp() != expectedCps[2])
throw new RuntimeException("Incorrect cp: " + blissey.getCp());
});
assertRegionStats(expected, Pokemon.class.getName());
}
private void storeTestPokemons(Counts expected) {
clearStatistics();
QuarkusTransaction.requiringNew().run(() -> {View on GitHub (pinned to e1c734241f)
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
Example fix
// before
Pokemon igeldo = em.find(Pokemon.class, 3);
if (igeldo.getCp() != expectedCps[0]) throw new RuntimeException("Incorrect cp: " + igeldo.getCp());
// after
Pokemon igeldo = em.find(Pokemon.class, 3);
if (igeldo == null) throw new RuntimeException("Pokemon 3 missing");
if (igeldo.getCp() != expectedCps[0]) throw new RuntimeException("Incorrect cp for igeldo: " + igeldo.getCp() + ", expected: " + expectedCps[0]); Defensive patterns
Strategy: validation
Validate before calling
Pokemon p = em.find(Pokemon.class, 3);
if (p == null) throw new IllegalStateException("Pokemon 3 not found");
if (p.getCp() != expectedCp) throw new IllegalStateException("Stale cp for Pokemon 3: " + p.getCp() + " != " + expectedCp); Type guard
boolean hasExpectedCp(Pokemon p, int expected) { return p != null && p.getCp() == expected; } Try / catch
try {
verifyFindByIdPokemons(expectedCps, expectedCounts);
} catch (RuntimeException e) {
if (e.getMessage().startsWith("Incorrect cp")) {
// evict Pokemon region and re-run write phase
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Incorrect cp: " + godzilla.getCp()
- Incorrect cp: " + blissey.getCp()
- Incorrect number of results
- Persons should have been deleted
- Pokemons should have been deleted
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/614bf8f81a312386.
Report an issue: GitHub.