quarkusio/quarkus · error · RuntimeException
Incorrect citizen: " + citizen.getLastname() + ", expected:
Error message
Incorrect citizen: " + citizen.getLastname() + ", expected: " + expected
What it means
Assertion inside updateNaturalId: the test loads Citizen with ssn 45989213T by natural id, expects lastname 'Stark', and throws this RuntimeException if the cached/loaded entity has a different lastname. This guards that the natural-id cache resolves the correct entity before the test updates its ssn.
Source
Thrown at integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java:201
final NaturalIdLoadAccess<Country> loader = session.byNaturalId(Country.class);
loader.using("callingCode", callingCode);
Country country = loader.load();
if (!country.getName().equals(expectedName))
throw new RuntimeException("Incorrect citizen: " + country.getName() + ", expected: " + expectedName);
});
}
private void updateNaturalId(Map<String, Counts> counts) {
clearStatistics();
QuarkusTransaction.requiringNew().run(() -> {
final Session session = em.unwrap(Session.class);
final NaturalIdLoadAccess<Citizen> loader = session.byNaturalId(Citizen.class);
loader.using("ssn", "45989213T");
Citizen citizen = loader.load();
String expected = "Stark";
if (!citizen.getLastname().equals(expected))
throw new RuntimeException("Incorrect citizen: " + citizen.getLastname() + ", expected: " + expected);
citizen.setSsn("78902007R");
});
assertRegionStats(counts);
}
private void verifyFindCitizenByNaturalId(String ssn, String expectedLastName,
Map<String, Counts> counts) {
clearStatistics();
QuarkusTransaction.requiringNew().run(() -> {
final Session session = em.unwrap(Session.class);
final NaturalIdLoadAccess<Citizen> loader = session.byNaturalId(Citizen.class);
loader.using("ssn", ssn);
Citizen citizen = loader.load();
if (!citizen.getLastname().equals(expectedLastName))
throw new RuntimeException("Incorrect citizen: " + citizen.getLastname() + ", expected: " + expectedLastName);View on GitHub (pinned to e1c734241f)
Solutions
- Reset the database / re-seed Citizens before each test run
- Evict the Citizen cache region before loading (sessionFactory.getCache().evict(Citizen.class))
- Verify the seeded row: ssn 45989213T must map to lastname 'Stark'
- Ensure tests run in isolation so updateNaturalId does not see mutations from earlier tests
Example fix
// before Citizen citizen = loader.load(); String expected = "Stark"; // after emf.unwrap(SessionFactory.class).getCache().evict(Citizen.class); Citizen citizen = loader.load(); String expected = "Stark";
Defensive patterns
Strategy: validation
Validate before calling
Citizen citizen = loader.load();
if (citizen == null) throw new IllegalStateException("No Citizen with ssn 45989213T; check seeding");
sessionFactory.getCache().evict(Citizen.class); // ensure fresh load Try / catch
try {
updateNaturalId(counts);
} catch (RuntimeException e) {
// evict regions and re-seed before retrying
} Prevention
- Re-seed test data before each endpoint test run
- Evict Citizen region before natural-id lookups
- Run tests in isolation so ssn mutations from earlier runs don't leak
When it happens
Trigger: Running the read-write natural id test when loading ssn=45989213T returns a Citizen whose lastname is not 'Stark' — wrong seed data, stale cache entry under that ssn, or the ssn was changed by a previous run without cache eviction.
Common situations: Previous test run mutated the ssn (test updates it to 78902007R) and the database was not reset; cached natural-id entry now maps to a different row; seed dataset changed.
Related errors
- Incorrect citizen: " + country.getName() + ", expected: " +
- Incorrect citizen: " + citizen.getLastname() + ", expected:
- Incorrect family size: " + pokemons.size() + ", expected: "
- Incorrect description: " + i1.getDescription() + ", expected
- Incorrect description: " + i2.getDescription() + ", expected
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/7dc196bb9fc384f0.
Report an issue: GitHub.