- priority: 5 --> 9
Hi, I'm not completly sure if this is a problem or not but I'm using Dozer extensively in a large enterprise application namely I'm using a lot of custom converters with parameters. Also I've integrated with spring via the customConvertersWithId and I currently have my converters registered as singleton beans in spring. I was reviewing Dozer code namely the code bellow and I've found (from what I can understand) that the same instance is reused for all the custom conversion needs (line 945). Since the parameter is not protected by any synchronized code and I was not able to find any synchronization code I think that with this configuration it's possible to have threading issues when multiple threads set the parameter..
Can someone from the Dozer team confirm that this is really an issue ?
private Object mapUsingCustomConverter(Class<?> customConverterClass, Class<?> srcFieldClass, Object srcFieldValue,
931 Class<?> destFieldClass, Object existingDestFieldValue, FieldMap fieldMap, boolean topLevel) {
932 CustomConverter converterInstance = null;
933 // search our injected customconverters for a match
934 if (customConverterObjects != null) {
935 for (CustomConverter customConverterObject : customConverterObjects) {
936 if (customConverterObject.getClass().isAssignableFrom(customConverterClass)) {
937 // we have a match
938 converterInstance = customConverterObject;
939 }
940 }
941 }
942 // if converter object instances were not injected, then create new instance
943 // of the converter for each conversion
944 // TODO : Should we really create it each time?
945 if (converterInstance == null) {
946 converterInstance = (CustomConverter) ReflectionUtils.newInstance(customConverterClass);
947 }