Skip to content

JAXB Unmarshaller not unlocking after failure #3238

@lafual

Description

@lafual

Hi,
In Windows I am reading a file that "should" contain XML using @InboundChannelAdapter FileReadingMesageSource and passing on to @Transformer UnmarshallingTransformer.

If the un-marshall works, the correct object is forwarded. When the XML is invalid or not the file didn't contain XML a MessageTransformerException is forwarded.

When the un-marshall is successful, the incoming file is un-locked and I can remove it from the incoming directory. However, when I get a MessageTransformerException the file's lock is not released. When I try to move it get java.nio.file.FileSystemException: The process cannot access the file because it is being used by another process

In the FileReadingMessageSource I have tried without setLocker, setLocker with NIOFileLocker and an implementation of FileLocker which creates an additional file with a .locked extension. None of these solutions work.

I am using the following to Transform;

@Bean
public Jaxb2Marshaller unmarshaller() {
   Jaxb2Marshaller x = new Jaxb2Marshaller();
   x.unmarshaller(MyClass.class);
   return x;
}

@Bean
@Transformer
public UnmarshallingTranformer umt() {
   return new UnmarshallingTransformer(unmarshaller());
}

How do I cause the lock to be released?

Shouldn't the transformer somehow share/re-use the lock of the original file reader? It seems as if it is using its own locking and not releasing after failure.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions