We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The LscBeean.clone() method does not shallow copy the attributes, which leads to data being shared between two objects:
LscBeean.clone()
public LscBean clone() throws CloneNotSupportedException { try { LscBean bean = this.getClass().newInstance(); bean.setMainIdentifier(this.getMainIdentifier()); for (String attributeName : this.getAttributesNames()) { bean.setAttribute(attributeName, this.getDatasetAsSetById(attributeName)); <<<------------------Here } return bean; } catch (InstantiationException ex) { throw new CloneNotSupportedException(ex.getLocalizedMessage()); } catch (IllegalAccessException ex) { throw new CloneNotSupportedException(ex.getLocalizedMessage()); } }
When an object A is cloned, the object B refers to object A attributes.
this SimpleBean (id=114) datasets HashMap<K,V> (id=174) [0] HashMap$Node<K,V> (id=175) key "sn" (id=165) value HashSet<E> (id=176) <--+ [1] HashMap$Node<K,V> (id=195) | key "cn" (id=186) | value HashSet<E> (id=187) <-----+ mainIdentifier "something" (id=157) | | bean SimpleBean (id=156) >.|..... Same reference datasets HashMap<K,V> (id=202) | | [0] HashMap$Node<K,V> (id=206) | >---- Same reference key "sn" (id=165) | | value HashSet<E> (id=176) <--+ | [1] HashMap$Node<K,V> (id=207) | key "cn" (id=186) | value HashSet<E> (id=187) <-----+ mainIdentifier "something" (id=157)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The
LscBeean.clone()
method does not shallow copy the attributes, which leads to data being shared between two objects:When an object A is cloned, the object B refers to object A attributes.
The text was updated successfully, but these errors were encountered: