Skip to content

ConfigMapping hashcode does not change with the method value changes #1462

Description

@michalvavrik

I have following @ConfigMapping https://github.com/quarkusio/quarkus/blob/main/extensions/devservices/keycloak/src/main/java/io/quarkus/devservices/keycloak/KeycloakDevServicesConfig.java, the mapping has property users. I have mentioned that when I used the KeycloakDevServicesConfig#hashCode in my build step, the hash code was same 1310h386370 even though when I called the KeycloakDevServicesConfig#users, users had a different value (you can try it by setting (quarkus.keycloak.devservices.users.michal=michal). https://smallrye.io/smallrye-config/Main/config/mappings/#validation says that the SR Config generates automatically hashCode. I think it is generally believed that when objects are equal, they should have the same hash code. However, it can't be these config mappings are equal, because the users are different.

Please note that I saw the second value on the dev mode restart, which was triggered by changing of the application.properties file (I added the property mentioned above, previously it was unset).

I guess the reason why this happens is due to the fact how default Map hashcode is implemented, so it can be probably reproduced by using Objects.hash() on maps (XOR trap).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions