TaskContainer replace throws documentation

Documentation for the two replace methods erroneously indicates that an exception is thrown if the task already exists:

https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/TaskContainer.html

Throws:
    InvalidUserDataException - If a task with the given name already exists in this project.

Also, please clarify in the documentation if an exception is thrown when the task does not already exist.

Gradle Version: 3.1
Operating System and JVM version: N/A
Is this a regression? no