Re: NullPointerException with large file and multipart params

125 views
Skip to first unread message

James Reeves

unread,
May 2, 2013, 5:07:12 AM5/2/13
to ring-c...@googlegroups.com
It looks like this is a bug. The RequestContext interface that Ring uses to talk to the Apache file upload library has the following method:

    int getContentLength()

And the maximum size of an int is 2^32-1, which works out to be about the number of bytes in 2 gigabytes. I suspect that the cause of your issue.

Fortunately, the file upload library specifies another interface, UploadContext, which works exactly the same as RequestContext, but has:

    long getContentLength()

Fixing this bug should be a case of just substituting RequestContent for UploadContext. Please file an issue with GitHub and I'll fix this in the next few days.

- James


On 2 May 2013 04:13, Marshall Brekka <marshal...@gmail.com> wrote:
I can successfully upload files around 80mb, but when I've tried a file that is over 2GB I get this stack trace:

java.lang.NullPointerException
at ring.middleware.multipart_params$request_context$reify__1899.getContentLength(multipart_params.clj:23)
at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:936)
at org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:331)
at ring.middleware.multipart_params$file_item_seq.invoke(multipart_params.clj:38)
at ring.middleware.multipart_params$parse_multipart_params.invoke(multipart_params.clj:54)
at ring.middleware.multipart_params$wrap_multipart_params$fn__1919.invoke(multipart_params.clj:98)
at compojure.core$routing$fn__434.invoke(core.clj:106)
at clojure.core$some.invoke(core.clj:2443)
at compojure.core$routing.doInvoke(core.clj:106)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:619)
at compojure.core$routes$fn__438.invoke(core.clj:111)
at ring.adapter.jetty$proxy_handler$fn__4789.invoke(jetty.clj:18)
at ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle(Unknown Source)

Any thoughts on why this or, or how to debug it? Thanks in advance

My code for the handler basically looks like this:

(mp/wrap-multipart-params
    (p/wrap-params
     (compojure/POST "/testupload" args
                     (println args))))

Also this is not sitting behind an nginx proxy or anything.

--
You received this message because you are subscribed to the Google Groups "Ring" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-clojure...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages