From 1113e19f88b9d6340a8b6bb9c238d35ea6b86d6a Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 23 Feb 2009 13:13:48 +0000 Subject: [PATCH] sync can cause NPE whith broken symlinks. PR 46747. Submitted by skoppehel at intersoft dot de git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@747004 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 ++++ src/main/org/apache/tools/ant/taskdefs/Sync.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/WHATSNEW b/WHATSNEW index 3cc065876..210efd83f 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -356,6 +356,10 @@ Fixed bugs: when writing zips or jars. Bugzilla Report 45548 + * could into a NullPointerException when faced with broken + symbolic links. + Bugzilla Report 46747. + Other changes: -------------- * A HostInfo task was added performing information on hosts, including info on diff --git a/src/main/org/apache/tools/ant/taskdefs/Sync.java b/src/main/org/apache/tools/ant/taskdefs/Sync.java index 0aa9df11e..7111dd622 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Sync.java +++ b/src/main/org/apache/tools/ant/taskdefs/Sync.java @@ -235,7 +235,8 @@ public class Sync extends Task { // delete them. for (int i = dirs.length - 1; i >= 0; --i) { File f = new File(toDir, dirs[i]); - if (f.list().length < 1) { + String[] children = f.list(); + if (children == null || children.length < 1) { log("Removing orphan directory: " + f, Project.MSG_DEBUG); f.delete(); ++removedCount[0];