Fix error when deleting configuration objects #1098
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Deleting contest objects like runs or submissions was working, but deleting configuration/registration objects like teams or groups is failing. e.g. if you have some groups and use a set in the event feed to replace with a different set, it fails with the following in the log:
R Error adding property: problems/test_data_count:null
R java.lang.NumberFormatException: null
R at org.icpc.tools.contest.model.internal.ContestObject.parseInt(ContestObject.java:142)
R Could not parse event feed line: {"type":"groups","token":"...","id": null,"data": [{...},{...}]}
R java.lang.NullPointerException: null
R at org.icpc.tools.cds.util.PlaybackContest.applyDefaults(PlaybackContest.java:538)
The fix is in PlaybackContest - we shouldn't try to apply default values to something we're deleting.
While I was debugging I changed a few cases to contest.add(new Deletion()) solely because the syntax looked nicer :) , and moved the line 'IContestObject[] allObjs' higher up because it's more efficient to remove deleted items from the list prior to adding new ones (e.g. if you have 5 groups and set it to 8, you only need to look through the original 5 to see if any were deleted. Likewise, if you have no groups and set it to 7, there aren't any you need to delete)