File tree 3 files changed +21
-4
lines changed
protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf
3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 4
4
import java .io .IOException ;
5
5
import java .io .InputStream ;
6
6
import java .net .URL ;
7
+ import java .util .concurrent .locks .ReentrantLock ;
7
8
8
9
import com .fasterxml .jackson .core .Version ;
9
10
import com .fasterxml .jackson .core .type .TypeReference ;
@@ -42,7 +43,10 @@ public Builder(ProtobufMapper m) {
42
43
*
43
44
* @since 2.9
44
45
*/
45
- protected DescriptorLoader _descriptorLoader ;
46
+ protected volatile DescriptorLoader _descriptorLoader ;
47
+
48
+ // @since 2.18
49
+ private final ReentrantLock _descriptorLock = new ReentrantLock ();
46
50
47
51
/*
48
52
/**********************************************************
@@ -192,11 +196,19 @@ public FileDescriptorSet loadDescriptorSet(InputStream src) throws IOException {
192
196
*
193
197
* @since 2.9
194
198
*/
195
- public synchronized DescriptorLoader descriptorLoader () throws IOException
199
+ public DescriptorLoader descriptorLoader () throws IOException
196
200
{
197
201
DescriptorLoader l = _descriptorLoader ;
198
202
if (l == null ) {
199
- _descriptorLoader = l = DescriptorLoader .construct (this );
203
+ _descriptorLock .lock ();
204
+ try {
205
+ l = _descriptorLoader ;
206
+ if (l == null ) {
207
+ _descriptorLoader = l = DescriptorLoader .construct (this );
208
+ }
209
+ } finally {
210
+ _descriptorLock .unlock ();
211
+ }
200
212
}
201
213
return l ;
202
214
}
Original file line number Diff line number Diff line change @@ -319,3 +319,7 @@ Thomas de Lange (@thomasdelange5)
319
319
* Contributed fix for #428 : (ion) `IonParser.getIntValue()` fails or does not handle
320
320
value overflow checks
321
321
(2.17 .0 )
322
+
323
+ PJ Fanning (pjfanning @github )
324
+ * Contributed #484 : Rework synchronization in `ProtobufMapper`
325
+ (2.18 .0 )
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ Active maintainers:
16
16
17
17
2.18 .0 (not yet released )
18
18
19
- No changes since 2.17 .
19
+ #484 : (protobuf ) Rework synchronization in `ProtobufMapper `
20
+ (contributed by @pjfanning )
20
21
21
22
2.17 .0 (12 - Mar - 2024 )
22
23
You can’t perform that action at this time.
0 commit comments