Hi Chris

I don't have time to investigate this issue. You are seeing in your code that InputStream is empty but that is obviously not StreamClosed issue which you are referring to now.

As I said I updated the local test code and was able to echo a 400K stream.

if you do like me to look at it then please open a JIRA issue and attach a Maven test project where I can have a Java client sending a 300+K byte[] to a server asserting that the whole block has been received

Thanks, Sergey

On 28/04/16 16:48, Chris Bud wrote:
Hi Sergey,

I was able to reproduce this issue locally in a standalone project.
I'll tar the project and attach it, maybe you'll see something I'm doing
wrong, hopefully.  I try to post the file I attached earlier with curl
but get IO exceptions (Stream Closed).

curl --form "fileupload=@KML_Samples.kml"
http://localhost:8080/file-service/file/save/somename

*Log*
name: somename
Attachments size: 1
DataHandler: KML_Samples.kml
DataHandler Content type: application/octet-stream
DataHandler Content class: class
org.apache.cxf.attachment.DelegatingInputStream
Mark supported: false
java.io.IOException: Stream Closed
....

Thanks, really appreciate your help!

On Wed, Apr 27, 2016 at 12:54 PM, Sergey Beryozkin <[email protected]
<mailto:[email protected]>> wrote:

    Or even with curl

    Sergey

    On 27/04/16 17:50, Sergey Beryozkin wrote:

        Hi

        I tried to reproduce the issue locally and could not, I updated the
        local test to echo a 400K array and it worked fine. Not sure what is
        going on in your case, can it be that a client is disconnecting
        too early ?

        Can you try to try posting a large payload from a Java client,
        CXF or
        plain Apache HTTP Client and see if it works ?

        Cheers, Sergey


        On 27/04/16 12:11, Chris Bud wrote:

            Hi Sergey,

            OK that did it!! My mistake, I overlooked that.  I notice
            the cxf logger
            still cuts off the file contents but when I spit out the
            input stream
            I see
            the entire file contents.

            Now, is this part of a known issue? Seems like something CXF
            does behind
            the scenes that's not reading the entire stream.. Do I have
            to parse the
            stream myself or is there internal cxf calls I can use like
            AttachmentBuilder?  I have multiple methods for uploading
            different file
            types, with different parameters, ideally I won't have to
            parse each
            method
            individually.

            Thanks for everything!!
            Chris

            On Wed, Apr 27, 2016 at 6:44 AM, Sergey Beryozkin
            <[email protected] <mailto:[email protected]>>
            wrote:

                Hi

                Can you please remove @Multipart which is bound right
                now to InputStream
                (as I did suggest) and retry ?

                Cheers, Sergey

                On 27/04/16 11:35, Chris Bud wrote:

                    Hi Sergey,

                    Regarding the side note, I've tried many approaches,
                    that was the last
                    attempt before turning to the mailing list. I did try
                    attachment.getObject()

                    I get similar results when I changed my method to
                    accept InputStream, I
                    only read the first parameter.  I'll attach files of
                    the inbound
                    message
                    my service receives, and my firebug output.  I
                    changed my method as you
                    suggested.

                    @Consumes(MediaType.MULTIPART_FORM_DATA)
                    @Produces(MediaType.APPLICATION_JSON)
                    public Response saveFile(
                               @PathParam("name") String name,
                               @Multipart InputStream body,
                               @HeaderParam("CUSTOM-uid") String username);
                    ...

                    public Response saveFile(String name, InputStream
                    is, String username){
                    ...
                                       try{
                    logger.info <http://logger.info> <http://logger.info

                        ("***************************************");

                    logger.info <http://logger.info> <http://logger.info

                        ("***************************************");


                    logger.info <http://logger.info>
                    <http://logger.info>("InputStream: " + is.available());

                                               BufferedReader br = null;
                                               StringBuilder sb = new
                    StringBuilder();

                                               String line;
                                               try {

                                                       br = new
                    BufferedReader(new
                    InputStreamReader(is));
                                                       while ((line =
                    br.readLine()) !=
                    null) {

                    sb.append(line);
                                                       }

                                               } catch (IOException e) {
                                                       e.printStackTrace();
                                               } finally {
                                                       if (br != null) {
                                                               try {

                    br.close();
                                                               } catch
                    (IOException e) {

                    e.printStackTrace();
                                                               }
                                                       }
                                               }

                    logger.info <http://logger.info>
                    <http://logger.info>("Info: " + sb.toString());

                    logger.info <http://logger.info> <http://logger.info

                        ("***************************************");

                    logger.info <http://logger.info> <http://logger.info

                        ("***************************************");


                    Produces these logs
                    2016-04-27 05:29:11,308 [INFO] [http-nio-8080-exec-2]
                    [example.com.web.rs.impl.FileServiceImpl] -
                    ***************************************
                    2016-04-27 05:29:11,308 [INFO] [http-nio-8080-exec-2]
                    [example.com.web.rs.impl.FileServiceImpl] -
                    ***************************************
                    2016-04-27 05:29:11,308 [INFO] [http-nio-8080-exec-2]
                    [example.com.web.rs.impl.FileServiceImpl] -
                    InputStream: 4
                    2016-04-27 05:29:11,309 [INFO] [http-nio-8080-exec-2]
                    [example.com.web.rs.impl.FileServiceImpl] - Info: 3304
                    2016-04-27 05:29:11,310 [INFO] [http-nio-8080-exec-2]
                    [example.com.web.rs.impl.FileServiceImpl] -
                    ***************************************
                    2016-04-27 05:29:11,310 [INFO] [http-nio-8080-exec-2]
                    [example.com.web.rs.impl.FileServiceImpl] -
                    ***************************************

                    Thanks for you help!
                    Chris

                    On Tue, Apr 26, 2016 at 4:24 PM, Sergey Beryozkin
                    <[email protected] <mailto:[email protected]>
                    <mailto:[email protected]
                    <mailto:[email protected]>>> wrote:

                          Hi

                          Can you please experiment with accepting it
                    directly as
                    InputStream:

                          @Consumes(MediaType.MULTIPART_FORM_DATA)
                          > @Produces(MediaType.APPLICATION_JSON)
                          > public Response saveFile(
                          >        @PathParam(“name") String name,
                           >        InputStream body,
                          >        @HeaderParam("CUSTOM-uid") String
                    username);

                          If the whole body is indeed available then
                    saving this InputStream
                          will show the complete multipart request (with
                    the part
                    separators,
                    etc)

                          As a side note,
                          > for(Attachment attachment :
                    body.getAllAttachments()) {
                          >      … // how I get the input stream
                          >      is =
                    attachment.getDataHandler().getInputStream();

                          instead you can do

                          is = attachment.getObject(InputStream.class);
                          or directly from the multipart body if a part
                    id is known.

                          Sergey


                          On 26/04/16 19:20, Chris Bud wrote:

                              Hi,

                              I'm using CXF 3.0.3, uploading files to
                    jaxrs service from my
                              webapp.
                              Small files upload fine but when I use
                    files > 300KB they're
                              empty on my
                              server, in my case I'm uploading an XML
                    document containing
                    test
                              info for
                              my system.  When I test for available
                    bytes from the data
                              handler's input
                              stream, it's always empty. Not the case
                    with small files, say
                    500B.
                              Regardless of size, the service returns a
                    success.

                              My LoggingInInterceptor spits out a
                    payload that is
                    incomplete,
                              but the
                              POST in firebug shows the entire file
                    contents. I feel like
                    I'm
                              missing
                              some sort of config, I've read about MTOM
                    but I don't think
                              300KB should be
                              a problem.... What am I missing? Thanks
                    for helping

                              My service interface
                              @POST
                              @Path(“/save/{name}")
                              @Consumes(MediaType.MULTIPART_FORM_DATA)
                              @Produces(MediaType.APPLICATION_JSON)
                              public Response saveFile(
                                      @PathParam(“name") String name,
                                      @Multipart MultipartBody body,
                                      @HeaderParam("CUSTOM-uid") String
                    username);

                              ...
                              for(Attachment attachment :
                    body.getAllAttachments()) {
                                    … // how I get the input stream
                                    is =
                    attachment.getDataHandler().getInputStream();

                              Bean definition
                              <jaxrs:server id=“wserver" address="/">
                                   <jaxrs:serviceBeans>
                                      <bean class=“example.com.web.rs
                    <http://example.com.web.rs>

                      <http://example.com.web.rs>.impl.FileServiceImpl" />
                                      ...
                                   </jaxrs:serviceBeans>
                                   <jaxrs:providers>
                                      <bean

                      class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
                                   </jaxrs:providers>
                                   <jaxrs:features>
                                      <ref bean="logger" />
                                   </jaxrs:features>


                              </jaxrs:server>





                --
                Sergey Beryozkin

                Talend Community Coders
                http://coders.talend.com/






    --
    Sergey Beryozkin

    Talend Community Coders
    http://coders.talend.com/




--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Reply via email to