A PR with an “optimization” for creating instances appeared in the preset draft preparation service for the operator panel. After the change, it is sometimes visible that fields from one draft end up in another, and parallel preparation of several drafts periodically ends with a runtime error.
A review of this change is needed.
What matters by requirements:
newDraft call must return an independent draft.buildDrafts must accept a list of identifiers and a template of fields, create drafts in parallel, and return the result in the same order as the input list.What needs to be checked:
Assumptions and runtime environment:
DraftService methods directly from a test or main.buildDrafts contract: receives List<String> presetIds and Map<String, String> templateFields as input, returns List<Draft> of the same length and in the same order as presetIds. For each presetId in the result, there must be a separate Draft with its own set of fields.Java 21, standard library. Compilation and execution in normal JVM mode, for example: javac src/*.java && java -cp src Main. No additional dependencies.
Use line comments to explain the problem, its impact, the fix and how to test it.