[#1671] Fix bug in ChunkedWriteHandler which produce a NPE on empty chunks