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

HashMap capacity doesn't refresh keys after capacity change #2

Open
droptablestar opened this issue Jun 26, 2017 · 0 comments
Open

Comments

@droptablestar
Copy link

droptablestar commented Jun 26, 2017

This bug can be duplicated by adding the following code to testPutAndGet in HashTableTest.java:

for (int i = 0; i < 2048; i++) { classUnderTest.put(i+4096, i); }                                                                                                                                             
for (int i = 0; i < 2048; i++) { assertEquals(classUnderTest.get(i+4096), i); }

The issue here is that the hashed key is dependant on the capacity of the table and the values for the keys aren't update after a capacity change. If the capacity changes those keys could hash to different values. Specifically this happens when keys are added which hash to a number larger than the current capacity.

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

No branches or pull requests

1 participant