Skip to content

Conversation

@matoro
Copy link

@matoro matoro commented Dec 16, 2025

MD5 digest algorithm is unavailable on a FIPS JVM, so fall back to SHA-1 for generating object hashCodes in this case. Only the first 32 bits are used, so the length difference will not matter.

@pjfanning
Copy link
Member

pjfanning commented Dec 16, 2025

I don't think this is ok - changing the behaviour like this as it will affect all users

You have the option of forking xmlbeans and you can make your fork do whatever you like or finding a way to make this configurable with the existing behaviour the default.

@matoro
Copy link
Author

matoro commented Dec 16, 2025

I don't think this is ok - changing the behaviour like this as it will affect all users

You have the option of forking xmlbeans and you can make your fork do whatever you like or finding a way to make this configurable with the existing behaviour the default.

Sure, is there a preferred method for exposing configurable properties? I didn't think these were part of the public API.

@pjfanning
Copy link
Member

Actually, this only seems to affect hash codes. Is this correct? Maybe, we could just change the code so that it tries to create a MD5 digest instance and if that throws an exception, catch it and try sha-1 instead. Could you centralise the code that creates the MessageDigest instead of having 2 places where it happens. Even if 1 class calls a shared static method that the other class hosts.

@matoro matoro changed the title Use SHA-1 instead of MD5 for base64/binary hashCode Make base64/binary hashCode digest configurable Dec 16, 2025
@matoro
Copy link
Author

matoro commented Dec 16, 2025

Actually, this only seems to affect hash codes. Is this correct? Maybe, we could just change the code so that it tries to create a MD5 digest instance and if that throws an exception, catch it and try sha-1 instead. Could you centralise the code that creates the MessageDigest instead of having 2 places where it happens. Even if 1 class calls a shared static method that the other class hosts.

Yes, this affects hash codes only. From your earlier suggestion, I went ahead and made it configurable with a system property. The logic is merged with another abstract class in the hierarchy so that it's all in one place. MD5 stays as the default.

@pjfanning
Copy link
Member

No system properties please. We don't use them.

@matoro matoro changed the title Make base64/binary hashCode digest configurable Fall back to SHA-1 for base64/binary hashCode Dec 16, 2025
@matoro
Copy link
Author

matoro commented Dec 16, 2025

No system properties please. We don't use them.

Sure thing. I've done the other one then, falling back in the case of NoSuchAlgorithmException.

MD5 digest algorithm is unavailable on a FIPS JVM, so fall back to SHA-1
for generating object hashCodes in this case.  Only the first 32 bits
are used, so the length difference will not matter.
@matoro
Copy link
Author

matoro commented Dec 16, 2025

Not sure where that comment went but yes, this works fine on java 8.

@pjfanning
Copy link
Member

code merged - thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants