commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COLLECTIONS-584) Deserializing an AbstractHashedMap expands the hash table exponentially
Date Mon, 14 Dec 2015 20:20:46 GMT

    [ https://issues.apache.org/jira/browse/COLLECTIONS-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15056651#comment-15056651
] 

Thomas Neidhart commented on COLLECTIONS-584:
---------------------------------------------

the load factor is a *parameter* provided to the AbstractHashedMap. If you see a value like
this, your de-serialization code in the derived class is broken.

> Deserializing an AbstractHashedMap expands the hash table exponentially
> -----------------------------------------------------------------------
>
>                 Key: COLLECTIONS-584
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-584
>             Project: Commons Collections
>          Issue Type: Bug
>    Affects Versions: 4.1
>            Reporter: Diogo Sousa
>
> When deserializing an {{AbstractHashedMap}} the size of the hashtable will be doubled
at each element inserted because {{threshold}} = 0, so this
> {code}
> protected void checkCapacity() {
>         if(this.size >= this.threshold) {
>             int newCapacity = this.data.length * 2;
>             if(newCapacity <= 1073741824) {
>                 this.ensureCapacity(newCapacity);
>             }
>         }
>     }
> {code}
> will always expand the hashtable.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message