implement clone the way it is supposed to
yes, `Cloneable` is broken, I know.
`AsiExtraField` is not final, so in theory subclasses may exist that
override `clone`. By not calling `super.clone()` we would no longer
populate the subclass' fields properly.
@@ -325,13 +325,13 @@ protected int getMode(final int mode) {
@Override
public Object clone() {
- AsiExtraField cloned = new AsiExtraField();
- cloned.mode = mode;
- cloned.uid = uid;
- cloned.gid =gid;
- cloned.link = link;
- cloned.dirFlag = dirFlag;
+ try {
+ final AsiExtraField cloned = (AsiExtraField) super.clone();
cloned.crc = new CRC32();
return cloned;
+ } catch (final CloneNotSupportedException cnfe) {
+ // impossible
+ throw new RuntimeException(cnfe); //NOSONAR
+ }
}
}
