quarkusio/quarkus · error · RuntimeException

Incorrect cp: " + blissey.getCp()

Error message

Incorrect cp: " + blissey.getCp()

What it means

RuntimeException thrown by verifyFindByIdPokemons when the Pokemon with ID 242 ('blissey') has a cp value that does not match expectedCps[2]. It is the last of the three per-entity cp assertions and, after passing, the test also verifies cache region statistics (assertRegionStats) for the Pokemon region.

Source

Thrown at integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java:585

        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(() -> {
            final Pokemon igeldo = new Pokemon(3, "Venusaur", 2555);
            em.persist(igeldo);
            final Pokemon godzilla = new Pokemon(248, "Tyranitar", 3670);
            em.persist(godzilla);
            final Pokemon khaleesi = new Pokemon(242, "Blissey", 3219);
            em.persist(khaleesi);

        });

View on GitHub (pinned to e1c734241f)

Solutions

  1. Confirm the write phase committed blissey's cp update before verification
  2. Check that Hibernate updated the cached entity on write (invalidation or update-through-cache)
  3. Recompute expectedCps from the actual written values in testReadWrite
  4. Isolate test runs with a fresh database to avoid cross-run contamination

Example fix

// before
if (blissey.getCp() != expectedCps[2]) throw new RuntimeException("Incorrect cp: " + blissey.getCp());
// after
if (blissey.getCp() != expectedCps[2]) throw new RuntimeException("Incorrect cp for blissey: " + blissey.getCp() + ", expected: " + expectedCps[2]);
Defensive patterns

Strategy: validation

Validate before calling

Pokemon b = em.find(Pokemon.class, 242);
if (b == null || b.getCp() != expectedCps[2])
    throw new IllegalStateException("Pokemon 242 cp mismatch or missing: " + (b == null ? "null" : b.getCp()));

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")) {
        // rerun write phase after evicting the Pokemon region
    }
}

Prevention

When it happens

Trigger: em.find(Pokemon.class, 242).getCp() != expectedCps[2] during the verification transaction: blissey's cp was never updated, the update rolled back, or the second-level cache served a stale copy of the entity.

Common situations: Update phase failure leaving blissey at its original cp; stale cache entry not invalidated after update; expectedCps array built from a different baseline (e.g. values from a previous run); concurrent test runs sharing the database.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/1f3f330adcfa897d. Report an issue: GitHub.