[GRADLE-3568] NPE in AbstractCopyTask.rename() Created: 28/Sep/16  Updated: 29/Sep/16  Resolved: 29/Sep/16

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 3.2-rc-1

Type: Bug
Reporter: Jendrik Johannes (Inactive) Assignee: Jendrik Johannes (Inactive)
Resolution: Fixed Votes: 0

Issue Links:
Duplicate
Duplicated by GRADLE-3569 Copy/Tar/Zip-like tasks: rename(Closu... Resolved
Known Issue Of:
3.0, 3.1

 Description   

https://discuss.gradle.org/t/abstractcopytask-rename-closure-does-not-handle-null-returns-as-documented/19758

Spec (says if null, original name is used)
AbstractCopyTask

Example

    task cp(type: Copy) {
        from file('sd1')
        into file('dirInto')
        rename { null }
   }

Stacktrace

    Caused by: java.lang.NullPointerException
        at org.gradle.util.CollectionUtils.join(CollectionUtils.java:547)
        at org.gradle.util.CollectionUtils.join(CollectionUtils.java:517)
        at org.gradle.api.file.RelativePath.getPathString(RelativePath.java:100)
        at org.gradle.api.internal.file.copy.FileCopyAction$FileCopyDetailsInternalAction.processFile(FileCopyAction.java:43)
        at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1$1.processFile(NormalizingCopyActionDecorator.java:66)
        at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1$1.processFile(DuplicateHandlingCopyActionDecorator.java:60)
        at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.processFile(CopyFileVisitorImpl.java:60)
        at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.visitFile(CopyFileVisitorImpl.java:44)
        at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl$1.visitFile(AbstractFileTree.java:150)
        at org.gradle.api.internal.file.collections.SingletonFileTree.visit(SingletonFileTree.java:44)
        at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:109)
        at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl.visit(AbstractFileTree.java:141)
        at org.gradle.api.internal.file.CompositeFileTree.visit(CompositeFileTree.java:58)
        at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:37)
        at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:24)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:570)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:572)
        at org.gradle.api.internal.file.copy.DefaultCopySpec.walk(DefaultCopySpec.java:380)
        at org.gradle.api.internal.file.copy.DelegatingCopySpecInternal.walk(DelegatingCopySpecInternal.java:236)
        at org.gradle.api.internal.file.copy.CopySpecBackedCopyActionProcessingStream.process(CopySpecBackedCopyActionProcessingStream.java:36)
        at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1.process(DuplicateHandlingCopyActionDecorator.java:44)
        at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1.process(NormalizingCopyActionDecorator.java:57)
        at org.gradle.api.internal.file.copy.FileCopyAction.execute(FileCopyAction.java:35)
        at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:53)
        at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator.execute(DuplicateHandlingCopyActionDecorator.java:42)
        at org.gradle.api.internal.file.copy.CopyActionExecuter.execute(CopyActionExecuter.java:38)
        at org.gradle.api.tasks.AbstractCopyTask.copy(AbstractCopyTask.java:94)


 Comments   
Comment by Jendrik Johannes (Inactive) [ 28/Sep/16 ]

In current master (3.2 nightly) it actually uses the string "null" instead of throwing an exception.

Comment by Sterling Greene [ 29/Sep/16 ]

For people using Gradle 3.0 or 3.1, the workaround is to make sure your rename Closure returns the original name instead of null.

Generated at Wed Jun 30 12:52:12 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.