You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2015/09/29 12:57:04 UTC
[jira] [Comment Edited] (CXF-6544) OutputStream#close not called
for WriterInterceptor
[ https://issues.apache.org/jira/browse/CXF-6544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14934990#comment-14934990 ]
Sergey Beryozkin edited comment on CXF-6544 at 9/29/15 10:56 AM:
-----------------------------------------------------------------
Yes, making sure close() is called can be easily done from AbstractClient, wrapping an abstract doWriteBody call.
I guess HttpUrlConnection simply calls close() on its OutputStream so if we start calling close() earlier - would that cause side-effects, i.e, would that upset somehow HTTP writes ?
But also : the headers have already been written by that time so it won't work after all, how would you pass the digest value ? HTTPUrlConnection can still have the internal buffer, but we won;t be able to update the headers it has cached - unless we go CXF specific way (doing it all at the CXF interceptor level - where we can possibly try to set headers on HTTPUrlConnection after close() and also hoping the internal buffer is still live)
was (Author: sergey_beryozkin):
Yes, making sure close() is called can be easily done from AbstractClient, wrapping an abstract doWriteBody call.
I guess HttpUrlConnection simply calls close() on its OutputStream so if we start calling close() earlier - would that cause side-effects, i.e, would that upset somehow HTTP writes ?
But also : the headers have already been written by that time so it won't work after all, how would you pass the digest value ?
> OutputStream#close not called for WriterInterceptor
> ---------------------------------------------------
>
> Key: CXF-6544
> URL: https://issues.apache.org/jira/browse/CXF-6544
> Project: CXF
> Issue Type: Bug
> Reporter: Romain Manni-Bucau
>
> Hi
> close() is called later in the JAXRS client lifecycle so no way to add code properly at this moment:
> {code}
> ClientBuilder.newBuilder()
> .build()
> .register(new WriterInterceptor() {
> @Override
> public void aroundWriteTo(final WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException {
> writerInterceptorContext.setOutputStream(new FilterOutputStream(writerInterceptorContext.getOutputStream()) {
> @Override
> public void close() throws IOException {
> // need code here
> super.close();
> }
> });
> }
> })
> {code}
> Overall idea can need more work since i'd like to be able to add a final trailer to a HTTP chunk communication.
> Managed to do it with httpclient but I'd like to stick to JAXRS 2 if possible.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)