Skip to content

Commit

Permalink
FindBugs: Check for non-null 'files' before staring to iterate over it.
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-g committed Jun 29, 2015
1 parent 2f21e12 commit 3311b07
Showing 1 changed file with 26 additions and 23 deletions.
Expand Up @@ -132,41 +132,44 @@ private static void zipDir(final File dir, final ZipOutputStream out, final Stri
BufferedInputStream origin;
byte data[] = new byte[BUFFER];

for (String file : files)
if (files != null)
{
if (log.isDebugEnabled())
for (String file : files)
{
log.debug("Adding: '{}'", file);
}
File f = new File(dir, file);
if (f.isDirectory())
{
if (recursive)
if (log.isDebugEnabled())
{
zipDir(f, out, path + f.getName() + "/", recursive);
log.debug("Adding: '{}'", file);
}
}
else
{
out.putNextEntry(new ZipEntry(path + f.getName()));
File f = new File(dir, file);
if (f.isDirectory())
{
if (recursive)
{
zipDir(f, out, path + f.getName() + "/", recursive);
}
} else
{
out.putNextEntry(new ZipEntry(path + f.getName()));

FileInputStream fi = new FileInputStream(f);
origin = new BufferedInputStream(fi, BUFFER);
FileInputStream fi = new FileInputStream(f);
origin = new BufferedInputStream(fi, BUFFER);

try
{
int count;
while ((count = origin.read(data, 0, BUFFER)) != -1)
try
{
int count;
while ((count = origin.read(data, 0, BUFFER)) != -1)
{
out.write(data, 0, count);
}
} finally
{
out.write(data, 0, count);
origin.close();
}
} finally {
origin.close();
}
}
}

if (path.equals(""))
if ("".equals(path))
{
out.close();
}
Expand Down

0 comments on commit 3311b07

Please sign in to comment.