Skip to content

Commit

Permalink
Merge pull request #1679 from /issues/1348-error-loading-lang-json
Browse files Browse the repository at this point in the history
Fix #1348: Error while loading lang.json (backport)
  • Loading branch information
banterCZ authored Aug 6, 2024
2 parents 77f8052 + bd51684 commit 5004255
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5004255

Please sign in to comment.