Skip to content

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

@sang89vh

Description

@sang89vh

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);
		}
		*/
		
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions