Skip to content

Commit

Permalink
Fix Windows bug on getComponentMessages (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessiejuachon authored Dec 9, 2020
1 parent 8d7af99 commit 3678872
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class LocalMessagesOpt implements Opt, MessageOpt {

private Logger logger = LoggerFactory.getLogger(LocalMessagesOpt.class.getName());

private static final String OFFLINE_RESOURCE_PATH = "{0}/messages_{1}.json";
private static final String OFFLINE_RESOURCE_PATH = "{0}{1}/messages_{2}.json";
private MessagesDTO dto;

public LocalMessagesOpt(MessagesDTO dto) {
Expand Down Expand Up @@ -67,9 +67,11 @@ public void getComponentMessages(MessageCacheItem cacheItem) {
private InputStream getInputStream() {
String locale = LocaleUtility.fmtToMappedLocale(dto.getLocale()).toLanguageTag();
while (true) {
String filePath = FormatUtils.format(OFFLINE_RESOURCE_PATH, dto.getComponent(), locale);
Path path = Paths.get(VIPCfg.getInstance().getOfflineResourcesBaseUrl(), filePath);
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path.toString());
String offlineResourcePath = VIPCfg.getInstance().getOfflineResourcesBaseUrl();
if(!offlineResourcePath.endsWith("/"))
offlineResourcePath = offlineResourcePath + "/";
String filePath = FormatUtils.format(OFFLINE_RESOURCE_PATH, offlineResourcePath, dto.getComponent(), locale);
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
if (is != null)
return is;
/*
Expand Down

0 comments on commit 3678872

Please sign in to comment.