You're comparing strings with identity equals rather than .equals() here.

Have you tested this code?  I can't imagine that these functions would return the same interned string?