I have run into a similar problem with production code, the data that was being returned as actually stored with the wrong content type. That was fun to figure out since it only failed on Ajax calls.
The display from the database displayed ok. However when I updated the data is when the extra character would get appended. What I did was add the following to my servlet and is seems to have solved the problem:
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad: