Skip to content

[FLUSS-3628] Fix primary key hashCode contract - #3741

Closed
wolfkill wants to merge 1 commit into
apache:mainfrom
wolfkill:fix/primary-key-hash-code
Closed

[FLUSS-3628] Fix primary key hashCode contract#3741
wolfkill wants to merge 1 commit into
apache:mainfrom
wolfkill:fix/primary-key-hash-code

Conversation

@wolfkill

Copy link
Copy Markdown

What changed

Schema.PrimaryKey.hashCode() now uses the same field set as equals().

Previously, equals() compared only columnNames, but hashCode() also included super.hashCode(), which is object-identity based. Two equal PrimaryKey instances could therefore produce different hash codes and behave incorrectly in hash-based collections.

Validation

  • RED: JAVA_HOME=/Users/cc/Library/Java/JavaVirtualMachines/corretto-18.0.2/Contents/Home mvn -pl fluss-common -am -Dtest=TableSchemaTest#testPrimaryKeyHashCodeMatchesEquals -DfailIfNoTests=false test
    • failed before the fix with different hash codes for two equal Schema.PrimaryKey instances
  • GREEN: same targeted test passed after the fix
  • JAVA_HOME=/Users/cc/Library/Java/JavaVirtualMachines/corretto-18.0.2/Contents/Home mvn -pl fluss-common -am -Dtest=TableSchemaTest -DfailIfNoTests=false test
    • Tests run: 9, Failures: 0, Errors: 0, Skipped: 0
  • JAVA_HOME=/Users/cc/Library/Java/JavaVirtualMachines/corretto-18.0.2/Contents/Home mvn -pl fluss-common -am -DfailIfNoTests=false test
    • Tests run: 1729, Failures: 0, Errors: 0, Skipped: 1
    • reactor result: BUILD SUCCESS
  • git diff --check

@wolfkill

Copy link
Copy Markdown
Author

Closing this as a duplicate.

After creating the PR, I was able to load the issue comments and found that #3629 had already been opened for FLUSS-3628. Sorry for the noise.

@wolfkill wolfkill closed this Jul 22, 2026
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.

1 participant