-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
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
Use lists instead of arrays for FlowNode
actions to make deserialization more robust
#263
Use lists instead of arrays for FlowNode
actions to make deserialization more robust
#263
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably various files here could be deleted, and in general I prefer to use zip files to avoid cluttering GitHub search results, but for now at least having the bare files as test resources makes it easy to see what is being tested.
var b = p.getLastBuild(); | ||
var stageBodyStartNode = (StepStartNode) b.getExecution().getNode("4"); | ||
assertThat(stageBodyStartNode, not(nullValue())); | ||
var label = stageBodyStartNode.getPersistentAction(LabelAction.class); | ||
assertThat(label.getDisplayName(), equalTo("test")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the patch, the whole Pipeline itself fails to load because the active head refers to a node with the action from the class that is no longer present.
src/main/java/org/jenkinsci/plugins/workflow/support/storage/BulkFlowNodeStorage.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test is failing on Windows, but otherwise seems like a good idea.
I did not realize this, but if you try to deserialize a Pipeline that has a
FlowNode
with an action from a plugin that is disabled or no longer installed, theFlowNode
itself will fail to be deserialized, leaving the flow graph corrupted. It seems like it would be preferential to haveRobustCollectionConverter
work forFlowNode
actions, so that only the problematic action itself fails to be deserialized, but theFlowNode
itself and all other actions are preserved.The reason for the current behavior is that right now, the fields used to serialize
FlowNode
actions are arrays, and core'sRobustCollectionConverter
has no equivalent for arrays (fair enough I guess).I created some tests to demonstrate the original behavior, but then I realized that the serial format of lists and arrays as far as XStream is concerned actually seems to be interchangeable (maybe not true in general?), so I figured I might as well file a patch instead of just tests. Besides potential concerns with backwards compatibility, I am not sure if there is any specific reason that arrays were used originally. Maybe to reduce memory usage or something like that?
For now I'm just filing as a draft because I'm not sure if this is safe or if there were any particular reasons we were using arrays previously.
Testing done
Only tested briefly against this plugin using the new and existing automated tests.
Submitter checklist