quarkusio/quarkus · error · RuntimeException

Incorrect cp: " + godzilla.getCp()

Error message

Incorrect cp: " + godzilla.getCp()

What it means

RuntimeException thrown by verifyFindByIdPokemons when the Pokemon with ID 248 ('godzilla') has a cp value that does not match expectedCps[1]. Like the igeldo check, it detects that the loaded (possibly cached) entity state diverges from what the write phase should have produced.

Source

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

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

View on GitHub (pinned to e1c734241f)

Solutions

  1. Ensure the write phase updated all three Pokemons (3, 248, 242) in a committed transaction
  2. Verify cache invalidation on update for the Pokemon region (check assertRegionStats hit/miss counts)
  3. Align the expectedCps array order with the find order (3 -> [0], 248 -> [1], 242 -> [2])
  4. Clean the DB and clear cache statistics between test runs

Example fix

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

Strategy: validation

Validate before calling

Pokemon g = em.find(Pokemon.class, 248);
if (g == null || g.getCp() != expectedCps[1])
    throw new IllegalStateException("Pokemon 248 cp mismatch or missing: " + (g == null ? "null" : g.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")) {
        // identify which pokemon failed from the message, evict its cache entry
    }
}

Prevention

When it happens

Trigger: em.find(Pokemon.class, 248).getCp() != expectedCps[1]: the write phase did not update this Pokemon, the second-level cache returned the old version, or the expected array is misaligned with the write order.

Common situations: Stale second-level cache entry for Pokemon 248 after an update; test write phase skipped or partially failed; expected counts/cps array passed to verifyFindByIdPokemons does not reflect the actual writes; leftover DB state from a prior run.

Related errors


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