• Bug
  • Status: Closed
  • Resolution: Fixed
  • drb
  • Reporter: sourceforgetracker
  • September 21, 2009
  • 0
  • Watchers: 0
  • September 22, 2009
  • September 22, 2009

Description

Reading the XML configuration as an inputstream, EHCache does not take into account the character encoding used (UTF-8), but instead converts every byte to a character. This causes the folowing error: Error configuring from input stream. Initial cause was Invalid byte 2 of 3-byte UTF-8 seqquence.

See for details the class ConfigurationFactory, method “private static InputStream translateSystemProperties(InputStream inputStream)”.

Wrong code:

while ((c = inputStream.read()) != -1) { stringBuffer.append((char) c); }

But the inputStream should be wrapped by a reader to the handle the character encoding correct, for example to decode UTF-8. For correct usage the encoding of the XML should be determined.

Reader lReader = new InputStreamReader(inputStream, “UTF-8”); while ((c = lReader.read()) != -1) { stringBuilder.append((char) c); }

Rob Juurlink

Sourceforge Ticket ID: 2584798 - Opened By: kozmoz - 10 Feb 2009 11:44 UTC

Comments

Fiona OShea 2009-09-22

Re-opening so that I can properly close out these issues and have correct Resolution status in Jira