I have been relatively lazy in regards of my blog lately, and I have plenty of articles that are stacking up...But in the meantime, I thought this one is pretty urgent.
In one of my previous article, ALUI Publisher - Part 2: Increase Performance by enabling REAL Caching - No Redirect Bug Fix, I was explaining how to fix the Publisher published_content_noredirect.jsp (see in that serie the benefits of using this instead of published_content_redirect.jsp).
Well, I found out a small little bug on my part, and it is definitely worth fixing if you have not done so already. In my corrective code, I was trimming the content string from its end spaces (just to optimized the HTML output)...and I did not think of the likely negative effects, such as if the buffered content does finish on a meaningful space character (such as a sentence separator etc...)
So the updated code with bug fix is: (specifically the trim that is removed)
//if there is content, forward to the requesting client
int buffersize = 2000;
int charread = 0;
char[] content;
//read until no byte is found in the input stream because request content length is no reliable
// UTF-8 is necessary
BufferedReader bisr = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
do {
content = new char[buffersize];
charread = bisr.read(content);
out.write(new String(content).trim());
} while(charread > -1);
bisr.close();
bisr = null;
content = null;
Better to find it late than never! :)
The code should be updated on the famous (yeah right...) ALUI Toolbox Google project (or should be soon)
So Long.