{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/14079","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/14079/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/14079/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/14079/events","html_url":"https://github.com/spring-projects/spring-boot/issues/14079","id":351133273,"node_id":"MDU6SXNzdWUzNTExMzMyNzM=","number":14079,"title":"Default locale from spring.mvc.locale ignored in CompletableFuture","user":{"login":"sddakoty","id":5269630,"node_id":"MDQ6VXNlcjUyNjk2MzA=","avatar_url":"https://avatars1.githubusercontent.com/u/5269630?v=4","gravatar_id":"","url":"https://api.github.com/users/sddakoty","html_url":"https://github.com/sddakoty","followers_url":"https://api.github.com/users/sddakoty/followers","following_url":"https://api.github.com/users/sddakoty/following{/other_user}","gists_url":"https://api.github.com/users/sddakoty/gists{/gist_id}","starred_url":"https://api.github.com/users/sddakoty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sddakoty/subscriptions","organizations_url":"https://api.github.com/users/sddakoty/orgs","repos_url":"https://api.github.com/users/sddakoty/repos","events_url":"https://api.github.com/users/sddakoty/events{/privacy}","received_events_url":"https://api.github.com/users/sddakoty/received_events","type":"User","site_admin":false},"labels":[{"id":293438798,"node_id":"MDU6TGFiZWwyOTM0Mzg3OTg=","url":"https://api.github.com/repos/spring-projects/spring-boot/labels/status:%20waiting-for-triage","name":"status: waiting-for-triage","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-16T09:49:46Z","updated_at":"2018-08-20T11:04:18Z","closed_at":null,"author_association":"NONE","body":"I'm resolving a message bundle as follows, always relying on the requested locale. With fallback to configured `spring.mvc.locale=de` in my case.\r\n\r\n```\r\n@Autowired\r\nprivate MessageSource bundle;\r\n\r\nbundle.getMessage(key, null, LocalContextHolder.getLocale());\r\n\r\n@Bean\r\npublic MessageSource bundle() {\r\n\tResourceBundleMessageSource bundle = new ResourceBundleMessageSource();\r\n        bundle.setBasenames(filename);\r\n\treturn bundle;\r\n}\r\n```\r\n\r\nIn a normal servlet call, the `LocalContextHolder` always has the correct locale and everything works fine.\r\n\r\nProblem: when accessing the `LocalContextHolder.getLocale()` inside a `CompletableFuture`, the local context is lost. Thus, it falls back to the systemwide locale, which is `en` if you're using an english machine like me. And thus taking 'en' resource bundle as default fallback if the message bundle is resolved within the completable future.\r\n\r\nIs this a bug, or does it work as intended?"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/414279010","html_url":"https://github.com/spring-projects/spring-boot/issues/14079#issuecomment-414279010","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/14079","id":414279010,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDI3OTAxMA==","user":{"login":"nosan","id":5054994,"node_id":"MDQ6VXNlcjUwNTQ5OTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5054994?v=4","gravatar_id":"","url":"https://api.github.com/users/nosan","html_url":"https://github.com/nosan","followers_url":"https://api.github.com/users/nosan/followers","following_url":"https://api.github.com/users/nosan/following{/other_user}","gists_url":"https://api.github.com/users/nosan/gists{/gist_id}","starred_url":"https://api.github.com/users/nosan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nosan/subscriptions","organizations_url":"https://api.github.com/users/nosan/orgs","repos_url":"https://api.github.com/users/nosan/repos","events_url":"https://api.github.com/users/nosan/events{/privacy}","received_events_url":"https://api.github.com/users/nosan/received_events","type":"User","site_admin":false},"created_at":"2018-08-20T11:04:18Z","updated_at":"2018-08-20T11:04:18Z","author_association":"CONTRIBUTOR","body":"Yeah, you actually not :) `DispatcherServlet` does, also like a variant you can try:\r\n```\r\n@SpringBootApplication\r\npublic class DemoApplication {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tConfigurableApplicationContext context = SpringApplication.run(DemoApplication.class);\r\n\t\tDispatcherServlet dispatcherServlet = context.getBean(DispatcherServlet.class);\r\n\t\tdispatcherServlet.setThreadContextInheritable(true);\r\n\t}\r\n\r\n}\r\n```\r\n, but still, I'm not sure that you really need this and you can `getLocale()` before running `CompletableFuture`"}}
{"actor":{"display_login":"nosan"}}