From 225e315e207d7baed58bb82968eaf9201be0d3bb Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Mon, 10 Mar 2014 12:29:39 -0400 Subject: [PATCH] INT-3316 BeanFactoryTypeConverter Concurrency JIRA: https://jira.spring.io/browse/INT-3316 The `SimpleTypeConverter` delegate uses property editors which are not thread safe. We protect against concurrent access when the source is not a String, but when a String, we delegate to the `STC`. Synchronize access to the `STC.convertIfNecessary()` method. --- .../integration/util/BeanFactoryTypeConverter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java index 7bd17635c7..ff83ae73e1 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -139,7 +139,9 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware return convertValue(text, TypeDescriptor.valueOf(String.class), targetType); } } - return delegate.convertIfNecessary(value, targetType.getType()); + synchronized (this.delegate) { + return delegate.convertIfNecessary(value, targetType.getType()); + } } private PropertyEditor getDefaultEditor(Class sourceType) { @@ -157,4 +159,4 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware return defaultEditor; } -} \ No newline at end of file +}