Showing
1 changed file
with
6 additions
and
0 deletions
... | ... | @@ -104,6 +104,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
104 | 104 | public void handle(HttpServletRequest request, HttpServletResponse response, |
105 | 105 | AccessDeniedException accessDeniedException) throws IOException, |
106 | 106 | ServletException { |
107 | + response.setCharacterEncoding("utf-8"); | |
107 | 108 | if (!response.isCommitted()) { |
108 | 109 | response.setContentType(MediaType.APPLICATION_JSON_VALUE); |
109 | 110 | response.setStatus(HttpStatus.FORBIDDEN.value()); |
... | ... | @@ -168,11 +169,13 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
168 | 169 | ThingsboardErrorCode errorCode = thingsboardException.getErrorCode(); |
169 | 170 | HttpStatus status = errorCodeToStatus(errorCode); |
170 | 171 | response.setStatus(status.value()); |
172 | + response.setCharacterEncoding("utf-8"); | |
171 | 173 | mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(thingsboardException.getMessage(), errorCode, status)); |
172 | 174 | } |
173 | 175 | |
174 | 176 | private void handleRateLimitException(HttpServletResponse response, TbRateLimitsException exception) throws IOException { |
175 | 177 | response.setStatus(HttpStatus.TOO_MANY_REQUESTS.value()); |
178 | + response.setCharacterEncoding("utf-8"); | |
176 | 179 | String message = "Too many requests for current " + exception.getEntityType().name().toLowerCase() + "!"; |
177 | 180 | mapper.writeValue(response.getWriter(), |
178 | 181 | ThingsboardErrorResponse.of(message, |
... | ... | @@ -181,11 +184,13 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
181 | 184 | |
182 | 185 | private void handleSubscriptionException(ThingsboardException subscriptionException, HttpServletResponse response) throws IOException { |
183 | 186 | response.setStatus(HttpStatus.FORBIDDEN.value()); |
187 | + response.setCharacterEncoding("utf-8"); | |
184 | 188 | mapper.writeValue(response.getWriter(), |
185 | 189 | (new ObjectMapper()).readValue(((HttpClientErrorException) subscriptionException.getCause()).getResponseBodyAsByteArray(), Object.class)); |
186 | 190 | } |
187 | 191 | |
188 | 192 | private void handleAccessDeniedException(HttpServletResponse response) throws IOException { |
193 | + response.setCharacterEncoding("utf-8"); | |
189 | 194 | response.setStatus(HttpStatus.FORBIDDEN.value()); |
190 | 195 | mapper.writeValue(response.getWriter(), |
191 | 196 | ThingsboardErrorResponse.of(ErrorMessage.NOT_HAVE_PERMISSION.getMessage(), |
... | ... | @@ -195,6 +200,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
195 | 200 | |
196 | 201 | private void handleAuthenticationException(AuthenticationException authenticationException, HttpServletResponse response) throws IOException { |
197 | 202 | response.setStatus(HttpStatus.UNAUTHORIZED.value()); |
203 | + response.setCharacterEncoding("utf-8"); | |
198 | 204 | if (authenticationException instanceof BadCredentialsException || authenticationException instanceof UsernameNotFoundException) { |
199 | 205 | mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.USERNAME_PASSWORD_INCORRECT.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
200 | 206 | } else if (authenticationException instanceof DisabledException) { | ... | ... |