[ 
https://issues.apache.org/jira/browse/GEODE-8372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17170251#comment-17170251
 ] 

ASF subversion and git services commented on GEODE-8372:
--------------------------------------------------------

Commit 1f1bd1adb2b40e69b112900d04350b4cdbcc0d66 in geode's branch 
refs/heads/feature/GEODE-7665 from Jinmei Liao
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=1f1bd1a ]

GEODE-8372: Configure CMS to send UTF-8 regardless of JVM default (#5411)



> Configure CMS to send UTF-8 regardless of JVM default
> -----------------------------------------------------
>
>                 Key: GEODE-8372
>                 URL: https://issues.apache.org/jira/browse/GEODE-8372
>             Project: Geode
>          Issue Type: Bug
>          Components: management
>            Reporter: Dale Emery
>            Priority: Major
>              Labels: GeodeOperationAPI, pull-request-available
>
> In a client, CMS accepts only UTF-8 messages from the locator. But the 
> locator can send non-UTF-8 messages depending on how the JVM and OS are 
> configured.
> It looks as if the locator CMS uses the JVM's default character encoding, and 
> the JVM sets its default character encoding based on the operating system's 
> default locale.
> If a client CMS accepts only UTF-8, the locator CMS should send only UTF-8, 
> regardless of the JVM's default character encoding.
> Example: I have a test client that uses a {{ClientClusterManagementService}} 
> to create a region. The locator, runs on a machine where the default locale 
> is us_EN.US-ASCII, sends US-ASCII responses. The client throws an 
> {{UnknownContentTypeException}}:
> {noformat}
> org.springframework.web.client.UnknownContentTypeException: Could not extract 
> response: no suitable HttpMessageConverter found for response type [class 
> org.apache.geode.management.api.ClusterManagementRealizationResult] and 
> content type [application/json;charset=US-ASCII]
>         at 
> org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:126)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:998)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:981)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:741) 
> ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.client.RestTemplate.execute(RestTemplate.java:674) 
> ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:583) 
> ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.apache.geode.management.api.RestTemplateClusterManagementServiceTransport.create(RestTemplateClusterManagementServiceTransport.java:248)
>  ~[geode-management-1.12.0.jar:na]
>         at 
> org.apache.geode.management.api.RestTemplateClusterManagementServiceTransport.submitMessage(RestTemplateClusterManagementServiceTransport.java:153)
>  ~[geode-management-1.12.0.jar:na]
>         at 
> org.apache.geode.management.internal.ClientClusterManagementService.create(ClientClusterManagementService.java:64)
>  ~[geode-management-1.12.0.jar:na]
>         at 
> org.apache.geode.kubernetes.client.service.AsyncOperationService.createRegion(AsyncOperationService.java:46)
>  ~[main/:na]
>         at 
> org.apache.geode.kubernetes.client.api.Controller.createRegion(Controller.java:27)
>  ~[main/:na]
>         at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
> Method) ~[na:na]
>         at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>  ~[na:na]
>         at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  ~[na:na]
>         at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
>         at 
> org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
>  ~[spring-webmvc-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
>  ~[spring-webmvc-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
>  ~[spring-webmvc-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
>  ~[spring-webmvc-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
>  ~[spring-webmvc-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
>  ~[spring-webmvc-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
>  ~[spring-webmvc-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
>  ~[spring-webmvc-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) 
> ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
>  ~[spring-webmvc-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) 
> ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 
> ~[tomcat-embed-websocket-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
>  ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) 
> ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) 
> ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) 
> ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) 
> ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at 
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>  ~[na:na]
>         at 
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>  ~[na:na]
>         at 
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>  ~[tomcat-embed-core-9.0.36.jar:9.0.36]
>         at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
> {noformat}
> For testing: On my mac, it's possible to set the encoding for a locator by 
> setting the {{LC_ALL}} environment variable in the shell before launching the 
> locator.
> For example, if I execute {{export LC_ALL=en_US.US-ASCII}}, then launch a 
> locator in that shell, the locator sends CMS messages in US-ASCII, as shown 
> in this {{curl -v}} output:
> {noformat}
>  % curl localhost:7070/management/v1/regions -v
> *   Trying ::1...
> * TCP_NODELAY set
> * Connected to localhost (::1) port 7070 (#0)
> > GET /management/v1/regions HTTP/1.1
> > Host: localhost:7070
> > User-Agent: curl/7.64.1
> > Accept: */*
> >
> < HTTP/1.1 200 OK
> < Date: Tue, 21 Jul 2020 16:28:26 GMT
> < Content-Type: application/json; charset=US-ASCII
> < X-Content-Type-Options: nosniff
> < X-XSS-Protection: 1; mode=block
> < Cache-Control: no-cache, no-store, max-age=0, must-revalidate
> < Pragma: no-cache
> < Expires: 0
> < X-Frame-Options: DENY
> < Content-Length: 31
> < Server: Jetty(9.4.21.v20190926)
> <
> * Connection #0 to host localhost left intact
> {"statusCode":"OK","result":[]}* Closing connection 0
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to