Skip to content

Commit 0c1deaf

Browse files
authored
Fix mutex unlock in storage exporters (#2442)
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
1 parent 2f191cc commit 0c1deaf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cmd/opentelemetry/app/exporter/badgerexporter/factory.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func (f Factory) createStorageFactory(params component.ExporterCreateParams, cfg
116116
return nil, fmt.Errorf("could not cast configuration to %s", TypeStr)
117117
}
118118
f.mutex.Lock()
119+
defer f.mutex.Unlock()
119120
if instance != nil {
120121
return instance, nil
121122
}
@@ -126,6 +127,5 @@ func (f Factory) createStorageFactory(params component.ExporterCreateParams, cfg
126127
return nil, err
127128
}
128129
instance = factory
129-
f.mutex.Unlock()
130130
return factory, nil
131131
}

cmd/opentelemetry/app/exporter/memoryexporter/factory.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func (f Factory) createStorageFactory(params component.ExporterCreateParams, cfg
108108
return nil, fmt.Errorf("could not cast configuration to %s", TypeStr)
109109
}
110110
f.mutex.Lock()
111+
defer f.mutex.Unlock()
111112
if instance != nil {
112113
return instance, nil
113114
}
@@ -118,6 +119,5 @@ func (f Factory) createStorageFactory(params component.ExporterCreateParams, cfg
118119
return nil, err
119120
}
120121
instance = factory
121-
f.mutex.Unlock()
122122
return factory, nil
123123
}

0 commit comments

Comments
 (0)