Skip to content

Commit

Permalink
Fix #1348: Error while loading lang.json
Browse files Browse the repository at this point in the history
(cherry picked from commit 07748e4)
  • Loading branch information
romanstrobl authored and banterCZ committed Aug 6, 2024
1 parent 77f8052 commit bd51684
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 bd51684

Please sign in to comment.