Skip to content

Commit d876777

Browse files
committed
replaced TypeDescriptor synchronization with volatile variables (SPR-8559)
1 parent f67e726 commit d876777

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

org.springframework.core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -80,13 +80,13 @@ public class TypeDescriptor {
8080

8181
private Object value;
8282

83-
private TypeDescriptor elementType;
83+
private volatile TypeDescriptor elementType;
8484

85-
private TypeDescriptor mapKeyType;
85+
private volatile TypeDescriptor mapKeyType;
8686

87-
private TypeDescriptor mapValueType;
87+
private volatile TypeDescriptor mapValueType;
8888

89-
private Annotation[] annotations;
89+
private volatile Annotation[] annotations;
9090

9191

9292
/**
@@ -266,7 +266,7 @@ public Class<?> getElementType() {
266266
/**
267267
* Return the element type as a type descriptor.
268268
*/
269-
public synchronized TypeDescriptor getElementTypeDescriptor() {
269+
public TypeDescriptor getElementTypeDescriptor() {
270270
if (this.elementType == null) {
271271
this.elementType = forElementType(resolveElementType());
272272
}
@@ -309,15 +309,15 @@ public Class<?> getMapKeyType() {
309309
/**
310310
* Returns map key type as a type descriptor.
311311
*/
312-
public synchronized TypeDescriptor getMapKeyTypeDescriptor() {
312+
public TypeDescriptor getMapKeyTypeDescriptor() {
313313
if (this.mapKeyType == null) {
314314
this.mapKeyType = forElementType(resolveMapKeyType());
315315
}
316316
return this.mapKeyType;
317317
}
318318

319319
/**
320-
* Return the map key type as a type descriptor. If the key type is null
320+
* Return the map key type as a type descriptor. If the key type is <code>null</code>
321321
* (cannot be determined), the type descriptor is derived from the key argument.
322322
* @param key the key
323323
* @return the map key type descriptor
@@ -338,7 +338,7 @@ public Class<?> getMapValueType() {
338338
/**
339339
* Returns map value type as a type descriptor.
340340
*/
341-
public synchronized TypeDescriptor getMapValueTypeDescriptor() {
341+
public TypeDescriptor getMapValueTypeDescriptor() {
342342
if (this.mapValueType == null) {
343343
this.mapValueType = forElementType(resolveMapValueType());
344344
}
@@ -359,7 +359,7 @@ public TypeDescriptor getMapValueTypeDescriptor(Object value) {
359359
/**
360360
* Obtain the annotations associated with the wrapped parameter/field, if any.
361361
*/
362-
public synchronized Annotation[] getAnnotations() {
362+
public Annotation[] getAnnotations() {
363363
if (this.annotations == null) {
364364
this.annotations = resolveAnnotations();
365365
}

0 commit comments

Comments
 (0)