Author: bodewig
Date: Fri Apr 16 20:18:51 2010
New Revision: 935069
URL: http://svn.apache.org/viewvc?rev=935069&view=rev
Log:
isSymbolicLink throws a NPE if invoked for the file system root
Added:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java
(with props)
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java?rev=935069&r1=935068&r2=935069&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
Fri Apr 16 20:18:51 2010
@@ -64,7 +64,7 @@ public class SymbolicLinkUtils {
* canonical and absolute paths of the file are identical--this
* may lead to false positives on some platforms.</p>
*
- * @param file the file to test.
+ * @param file the file to test. Must not be null.
*
* @return true if the file is a symbolic link.
* @throws IOException on error.
@@ -104,7 +104,9 @@ public class SymbolicLinkUtils {
*/
public boolean isSymbolicLink(File parent, String name)
throws IOException {
- File toTest = new File(parent.getCanonicalPath(), name);
+ File toTest = parent != null
+ ? new File(parent.getCanonicalPath(), name)
+ : new File(name);
return !toTest.getAbsolutePath().equals(toTest.getCanonicalPath());
}
Added:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java?rev=935069&view=auto
==============================================================================
---
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java
(added)
+++
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java
Fri Apr 16 20:18:51 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant.util;
+
+import java.io.IOException;
+import junit.framework.TestCase;
+
+public class SymlinkUtilsTest extends TestCase {
+
+ private static final SymbolicLinkUtils SYMLINK_UTILS =
+ SymbolicLinkUtils.getSymbolicLinkUtils();
+
+ public void testRootIsNoSymlink() throws IOException {
+ assertFalse(SYMLINK_UTILS.isSymbolicLink("/"));
+ }
+
+}
Propchange:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native