Question

The following code:

final String INVALID_ESCAPE="\\";
System.out.println(String.format("'%s' -> '%s'", INVALID_ESCAPE, 
    StringEscapeUtils.unescapeJava(INVALID_ESCAPE)));

... produces:

'\' -> ''

on the console. Since '\' is not a valid escape I would expect an Exception at runtime. Am I missing anything?

UPDATE: filled a bug(?) report in Apache jira

Was it helpful?

Solution

From the source:

// TODO: throw "illegal character: \92" as an Exception if a \ on the end of the Java (as per the compiler)?

Send a patch ;-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top