| Summary: | Remove recursion from IdentityWeakHashMap$WeakEntry.clone() | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | David Minsky <david.minsky> | ||||
| Component: | Eclipselink | Assignee: | David Minsky <david.minsky> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Project Inbox <eclipselink.foundation-inbox> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | ||||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
As an addition, this is related to the work done in: Bug 237812 - RECURSION IN IDENTITYHASHSET.CLONE() CAN CAUSE STACK OVERFLOW WITH LARGE SET Fixed in trunk (2.4) at revision: 10395 The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Created attachment 206989 [details] Fix Current code for WeakEntry.clone() (inner class in IdentityWeakHashMap) is recursive: protected Object clone(ReferenceQueue refQueue) { return new WeakEntry<K,V>(hash, key.get(), value.get(), ((next == null) ? null : (WeakEntry<K,V>)next.clone(refQueue)), refQueue); } Recursive cloning in the product can potentially cause a stack overflow with a large set of data and a normal stack size configuration. Ideally, recursion should not be used when cloning. Propoing to change the code to: protected Object clone(ReferenceQueue refQueue) { WeakEntry current = this; WeakEntry root = new WeakEntry(current.hash, current.key.get(), current.value.get(), null, refQueue); WeakEntry currentClone = root; while (current.next != null) { currentClone.next = new WeakEntry(current.next.hash, current.next.key.get(), current.next.value.get(), null, refQueue); current = current.next; currentClone = currentClone.next; } return root; }