flow
flow copied to clipboard
When CommonsMultipartResolver is registered, streamingFinished is never called.
Description of the bug
Upload success listeners are never called if a CommonsMultipartResolver
is registered as MultipartResolver
Minimal reproducible example
@Configuration
class RestConfiguration {
@Bean
fun multipartResolver(): MultipartResolver = CommonsMultipartResolver()
}
val buffer = MemoryBuffer()
val upload = Upload(buffer)
upload.addSucceededListener { Notification.show(StreamUtils.copyToString(buffer.inputStream, Charset.defaultCharset())) }
div.add(upload)
Expected behavior
Notification shows after file upload
Actual behavior
Listener is never called
Versions:
- Vaadin / Flow version: 19.0.5
- Java version: 15
- OS version: Linux
- Application Server (if applicable): Spring Boot
Workaround
I need CommonsMultipartResolver
in other parts of my application, so I can't just switch to StandardServletMultipartResolver
. Workaround is to conditionally select the one that works:
class SwitchingMultipartResolver : MultipartResolver {
private val commonsResolver = CommonsMultipartResolver()
private val standardResolver = StandardServletMultipartResolver()
override fun isMultipart(request: HttpServletRequest): Boolean = request.resolver().isMultipart(request)
override fun resolveMultipart(request: HttpServletRequest): MultipartHttpServletRequest = request.resolver().resolveMultipart(request)
override fun cleanupMultipart(request: MultipartHttpServletRequest) = request.resolver().cleanupMultipart(request)
private fun HttpServletRequest.resolver() = if (servletPath.startsWith("/VAADIN")) standardResolver else commonsResolver
}
Potentially related
https://github.com/vaadin/flow/issues/5924
https://github.com/vaadin/flow/commit/cbf556f579ddeef1918a31085807be89c8a2f352
It seems like previously only CommonsMultipartResolver
worked, and now only StandardServletMultipartResolver
works for vaadin.
Tested with this project upload-problem.zip
If the @Bean
annotation in RestConfiguration
is commented out, the notification is shown. Otherwise it is not.
When CommonsMultipartResolver
is registered, streamingFinished is never called.
I understand that we are using something from StandardServletMultipartResolver
instead of relying only on the MultipartResolver
interface, so it fails when we change the implementation.
I will label it so it can be addressed