Java/Groovy - Pipe a Stream > Input to Output to Input, with an Intentional Broken Pipe. Safe? -


most ridiculous use case ever, right? well, here's scenario. basic flow is:

  1. user uploads (large) document in web browser
  2. document sent controller through virus scanning tool , back.
  3. file uploaded controller separate application workflows/processing

the framework (grails) irrelevant here, java/groovy question. want stream file around doesn't wind in memory (at least in full) or on file system...it stays in "pipes". have part working. virus scanning tool takes input stream , output stream (input stream written directly output stream if file clean). use pipedoutputstream/pipedinputstream stream file directly part of httppost (apache commons) end grails app.

so of fine , , works properly. if document clean, it's piped directly end server , saves successfully. if document infected, resulting document output stream "content blocked" html file. great, don't want "content blocked" file stick...i want fail. problem that, since i'm piping streams around, time know have infected file, has been uploaded (with blocked message). ideally, request somehow terminated...and have managed that, i'm unsure of approach. in virus scanning thread, don't close output stream if it's determined file infected. results in broken pipe ioexception, httppost ends terminating.

again, of working fine locally, in unit tests, , in test environment, , appears behaving how want to....but question is, safe? safe assume broken pipe ioexception been thrown , terminate httppost? introducing kind of leak not closing output stream , allowing broken pipe happen? other ideas on how terminate post in better way (keeping in mind post has started...i'm writing results of virus scan directly input stream of httppost)? in advance.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -