Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 Character error when deploy to tomcat 9 on CentOS #79

Open
sang89vh opened this issue Feb 27, 2017 · 0 comments
Open

UTF-8 Character error when deploy to tomcat 9 on CentOS #79

sang89vh opened this issue Feb 27, 2017 · 0 comments

Comments

@sang89vh
Copy link

sang89vh commented Feb 27, 2017

I see on class "ParseResponse" at method "getResponseAsString".
It will be made a bug when convert data respond to UTF-8 String.
My environment is CentOS 6, Tomcat 9, Java 8.
And I changed it such as below then it's resolved
Thanks!

private String getResponseAsString(HttpResponse httpResponse) {
		String jsonText = null;
		try {
			HttpEntity entity = httpResponse.getEntity();
			jsonText = EntityUtils.toString(entity, HTTP.UTF_8);
			
		} catch (org.apache.http.ParseException e) {
			LOGGER.error("Error while reading response entity", e);
			throw new IllegalArgumentException("Failed getting Parse Response", e);
		} catch (IOException e) {
			LOGGER.error("Error while reading response entity", e);
			throw new IllegalArgumentException("Failed getting Parse Response", e);
		}
		return jsonText;
		/*
		try {
			BufferedReader r = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
			StringBuilder total = new StringBuilder();
			String line = null;
			while ((line = r.readLine()) != null) {
			   total.append(line);
			}
			//r.close();
			return total.toString();
		}
		catch(IOException e) {
			LOGGER.error("Error while reading response entity", e);
			throw new IllegalArgumentException("Failed getting Parse Response", e);
		}
		*/
		
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant