I figured out a solution. Here it is in case others follow in my footsteps.
This solution uses an interceptor to ensure that any multipart files are cleaned up after the completion of the request.
Enjoy!
Tom
Code:
public class PrimaryInterceptor
extends HandlerInterceptorAdapter implements ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex) throws Exception {
// cleanup the multipart files
if (request instanceof MultipartHttpServletRequest) {
MultipartResolver resolver = (MultipartResolver) applicationContext.getBean("multipartResolver");
resolver.cleanupMultipart((MultipartHttpServletRequest) request);
}
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}