Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractDatabase::markUsed doesn't work in some edge cases #15918

Closed
lukaseder opened this issue Dec 7, 2023 · 1 comment
Closed

AbstractDatabase::markUsed doesn't work in some edge cases #15918

lukaseder opened this issue Dec 7, 2023 · 1 comment

Comments

@lukaseder
Copy link
Member

lukaseder commented Dec 7, 2023

While testing #12985, I've discovered a glitch regarding forced types, which hasn't appeared yet with the Maven plugin, but does with the new gradle plugin.

Despite forced types being applied correctly, this is being logged:

Unused forced type       : <priority>0</priority><name>VARCHAR(10)</name><autoConverter>true</autoConverter><includeExpression>J</includeExpression><nullability>ALL</nullability><objectType>ALL</objectType>
Unused forced type       : <priority>0</priority><name>BIGINT</name><autoConverter>true</autoConverter><includeExpression>K</includeExpression><nullability>ALL</nullability><objectType>ALL</objectType>

The reason is because we add the forced types to the AbstractDatabase.unusedForcedTypes hash set, and then modify them on some occasions, e.g. to set autoConverter to true. Obviously, that's forbidden by the HashSet contract, because now, the hashCode (and equals behaviour) changes.

A workaround would be to set autoConverter = true, but similar things happen when using the deprecated expression value, for example, which is copied to includeExpression.

There are a few ways to fix this:

  • Fix equals() and hashCode(), making them more intelligent (hard to check)
  • Use an IdentityHashMap instead (possibly regressing in the future, when we create clones of ForcedType instances, which we currently don't do)
  • Delay initialisation of the HashSet until all the ForcedType values have been patched (probably the best solution here)
  • Remove and re-add any ForcedType that is modified (hard to remember)
3.19 Other improvements automation moved this from To do to Done Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

1 participant