Skip to content

Commit 1aa4d88

Browse files
committed
[FAB-9133] Data race in TestGenerateDockerBuild2
Data race between setting the _generateDockerBuild function reference in the test and using/reading it from within the go routine spawned by the production code. Resolved by shadowing the function reference on the stack before launching the go routine. Change-Id: Ic1f2de8bc9687d706ed4d65c69455ddbaa09fe21 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent a751f15 commit 1aa4d88

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/chaincode/platforms/platforms.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ func GenerateDockerBuild(cds *pb.ChaincodeDeploymentSpec) (io.Reader, error) {
170170
// ----------------------------------------------------------------------------------------------------
171171
input, output := io.Pipe()
172172

173+
generateDockerBuild := _generateDockerBuild
173174
go func() {
174175
gw := gzip.NewWriter(output)
175176
tw := tar.NewWriter(gw)
176-
err := _generateDockerBuild(platform, cds, inputFiles, tw)
177+
err := generateDockerBuild(platform, cds, inputFiles, tw)
177178
if err != nil {
178179
logger.Error(err)
179180
}

0 commit comments

Comments
 (0)