Clojure

clojure.contrib.string.replace-str throws NPE on nil string

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: Backlog
  • Component/s: None
  • Labels:
    None

Description

Version: Clojure 1.2 / clojure-contrib 1.2

This call:

user=> (clojure.contrib.string/replace-str "a" "b" nil)
#<CompilerException java.lang.NullPointerException (NO_SOURCE_FILE:29)>

throws a NullPointerException when passed a nil string. It seems like more corner cases could be automatically handled by returning nil in this case rather than throwing an NPE. At the very least, it would be nice to update the docstring to state that s cannot be nil.

Activity

Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - Converted from http://www.assembla.com/spaces/clojure/tickets/345
Hide
Assembla Importer added a comment -

stu said: I evaluated this agains the latest version of the fn in clojre (e.g. clojure.string/replace).

The documentation string correctly lists legal parameters for replace as string, char, or fn, so an NPE is expected behavior.

Note also: the contrib versions of most string fns are deprecated.

Show
Assembla Importer added a comment - stu said: I evaluated this agains the latest version of the fn in clojre (e.g. clojure.string/replace). The documentation string correctly lists legal parameters for replace as string, char, or fn, so an NPE is expected behavior. Note also: the contrib versions of most string fns are deprecated.

People

  • Assignee:
    Unassigned
    Reporter:
    Anonymous
Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: