Skip to content

create a copy utility and remove the need for clone and copy constructors in transforms/actions - #8031

Merged
hansva merged 2 commits into
apache:mainfrom
hansva:8022
Aug 21, 2026
Merged

create a copy utility and remove the need for clone and copy constructors in transforms/actions#8031
hansva merged 2 commits into
apache:mainfrom
hansva:8022

Conversation

@hansva

@hansva hansva commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Please add a meaningful description for your change here


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Run mvn clean install apache-rat:check to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If you have a group of commits related to the same change, please squash your commits into one and force push your branch using git rebase -i.
  • Mention the appropriate issue in your description (for example: addresses #123), if applicable.

To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

hansva and others added 2 commits August 20, 2026 13:04
…ata. fixes apache#8022

Object.clone() is shallow, so a cloned ITransformMeta or IAction keeps sharing
every list, map and nested value object with the original. The pipeline editor
relies on cloned snapshots in two places and the sharing broke both:

- editTransform() decides whether a dialog changed anything by comparing the XML
  of a snapshot taken before the dialog opened against one taken after OK. The
  snapshot shared the live lists, so dialogs that refill a list in place - Add
  constants, the Data Grid Meta tab, Insert/Update, Update, Table output and
  around twenty more - serialized identically and their edits were silently not
  marked as changed. The reported workaround, moving the transform afterwards,
  worked because setLocation() sets the flag directly.

- The same snapshot is stored as the undo entry, so undo either did nothing or
  rolled back only the properties that survived the shallow copy, leaving the
  transform in a state the user never had.

BaseTransformMeta.clone() and ActionBase.clone() now deep copy the state
described by the @HopMetadataProperty annotations, which is exactly the state
that gets persisted, compared and restored. Live references - other transforms,
metadata providers, caches - stay shared, as the javadoc on clone() intends.

One generic implementation makes the hand written copies redundant: 211 clone()
overrides and 122 copy constructors are removed. The 12 overrides that remain
each do something the generic copy cannot: a covariant return required by
ICsvInputAwareMeta, null defaulting, unannotated runtime state, or a copy
constructor that normalizes a value.

This also fixes AvroOutputMeta, CalculatorMeta and MergeJoinMeta, whose hand
written clone() silently dropped most of their fields, and removes the
assignment in ActionMail.clone() that wrote the copy's list back onto the
original.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Transform and action dialogs are not modal, so the canvas stays live while one
is open. Every dialog captures the changed flag when it is constructed and
restores it in cancel(). A transform's entire dirty state was a single boolean
on the inner ITransformMeta, and TransformMeta.setLocation() wrote to that same
boolean, so dragging a transform while its dialog was open and then pressing
Cancel discarded the move: the transform stayed at its new position while the
pipeline reported no changes, and the move was lost on close.

TransformMeta and ActionMeta now keep their own flag for the state they own -
position, number of copies, row distribution - and hasChanged() reports the two
together. A dialog's Cancel reaches only the transform's own settings, so it can
still roll back an edit in progress without touching what the canvas did.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the Neo4j label Aug 20, 2026
@hansva
hansva merged commit 718a726 into apache:main Aug 21, 2026
3 checks passed
@hansva
hansva deleted the 8022 branch August 21, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant