[FIXED JENKINS-20345] file descriptor leak in zip file download

When downloading a zip file with all of the artifacts, file descriptors
would be opened and never closed. This resulted in many leaked file
descriptors which would only be cleaned up the next time the garbage
collector was run.

For directories with a large number of files, the zip file would be
corrupted because an exception was thrown during the process of creating
the zip file when the process ran out of file descriptors. Jenkins was
then left in a very brittle state as random threads wouldn't be able to
open files or sockets anymore until the garbage collector was run.

(cherry picked from commit f0bbc66921fec56dd9565c2a5146734f20f2fb6c)