From bd51684dac35d8b45dffe35d1b988cc91cf6cfd7 Mon Sep 17 00:00:00 2001 From: "roman.strobl@wultra.com" Date: Tue, 6 Jun 2023 17:02:47 +0200 Subject: [PATCH] Fix #1348: Error while loading lang.json (cherry picked from commit 07748e4eba080ffea981bc856629830933c956f0) --- .../powerauth/app/webflow/i18n/I18NService.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/powerauth-webflow-i18n/src/main/java/io/getlime/security/powerauth/app/webflow/i18n/I18NService.java b/powerauth-webflow-i18n/src/main/java/io/getlime/security/powerauth/app/webflow/i18n/I18NService.java index f570308c7..da6db0211 100644 --- a/powerauth-webflow-i18n/src/main/java/io/getlime/security/powerauth/app/webflow/i18n/I18NService.java +++ b/powerauth-webflow-i18n/src/main/java/io/getlime/security/powerauth/app/webflow/i18n/I18NService.java @@ -19,17 +19,17 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.support.AbstractMessageSource; import org.springframework.stereotype.Service; +import org.springframework.util.FileCopyUtils; import javax.annotation.Resource; import java.io.IOException; -import java.nio.file.Files; +import java.nio.charset.StandardCharsets; import java.util.Locale; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Service which converts resource bundle messages for given locale to JSON and provides access to the MessageSource. * @@ -86,7 +86,8 @@ public AbstractMessageSource getMessageSource() { public String readLanguageSetting() { try { // language setting is possible only via extension and external resources - return new String(Files.readAllBytes(languageSettingSource.getFile().toPath())); + byte[] languageData = FileCopyUtils.copyToByteArray(languageSettingSource.getInputStream()); + return new String(languageData, StandardCharsets.UTF_8); } catch (IOException ex) { // language setting is not configured return null logger.warn("Error occurred while retrieving the language setting ", ex);