Resource leak problem

你们好，

I found some possibility of resource leak, this merge request will fix it.
This also contains performance improvement around StringBuffer.

Sorry but I did not compile it because [this issue](https://github.com/taobao/metaq/issues/12) didn't allow me to do. Please compile to check before you merge this. Thanks!