Skip to content

FileEditor not applied for String to File property conversion #16931

@garyrussell

Description

@garyrussell

In Spring Integration, we have a number of properties that are of type File and can be specified in XML config as a Resource

directory="file:${some.path}"

This works fine in a stand-alone Spring application but not in a Spring Boot application.

Boot adds a conversion service to the bean factory, by default:

		if (this.addConversionService) {
			context.getBeanFactory().setConversionService(
					ApplicationConversionService.getSharedInstance());
		}

When there is no custom conversion service, the BeanWrapper uses a FileEditor to convert the property; it, in turn, detects the the String is a URL and delegates to a ResourceEditor.

When there is a custom conversion service, it is used by the BeanWrapper instead and it ends up with a java.io.File with the name file:somePath.

The ConversionService uses a simple ObjectToObjectConverter.

So, I believe that Boot's ApplicationConversionService needs a converter than provides similar functionality to the FileEditor PropertyEditor.

Users can .setAddConversionService(false), but that's not a good work-around.

See spring-projects/spring-integration#2930

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions