private synchronized Stage persistStage ( Pipeline pipeline , Stage stage ) { long pipelineId = pipeline . getId ( ) ; stage . setOrderId ( resolveStageOrder ( pipelineId , stage . getName ( ) ) ) ; Stage savedStage = stageDao . save ( pipeline , stage ) ; savedStage . setIdentifier ( new StageIdentifier ( pipeline . getName ( ) , pipeline . getCounter ( ) , pipeline . getLabel ( ) , stage . getName ( ) , String . valueOf ( stage . getCounter ( ) ) ) ) ; for ( JobInstance jobInstance : savedStage . getJobInstances ( ) ) { jobInstance . setIdentifier ( new JobIdentifier ( pipeline , savedStage , jobInstance ) ) ; } return savedStage ; }
need to synchronize this method call to make sure no concurrent issues .