Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyblitz committed Apr 22, 2024
1 parent d695fc7 commit 3af6528
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ protected String buildResourceName(Locale locale) {

protected abstract String getResource(String resourceName);

@Nullable
protected abstract Map<String, String> loadMessages(String resource);

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import static io.microsphere.collection.CollectionUtils.isEmpty;
import static io.microsphere.text.FormatUtils.format;
import static java.util.Collections.emptyMap;
import static java.util.Collections.unmodifiableMap;

/**
Expand All @@ -28,7 +27,7 @@ public PropertiesResourceServiceMessageSource(String source) {

@Override
protected final Map<String, String> loadMessages(String resource) {
Map<String, String> messages = emptyMap();
Map<String, String> messages = null;
try {
Properties properties = loadAllProperties(resource);
if (!MapUtils.isEmpty(properties)) {
Expand All @@ -38,7 +37,7 @@ protected final Map<String, String> loadMessages(String resource) {
} catch (IOException e) {
throw new RuntimeException(format("Source '{}' Messages Properties Resource[name : {}] loading is failed", source, resource), e);
}
return unmodifiableMap(messages);
return messages == null ? null : unmodifiableMap(messages);
}

private Properties loadAllProperties(String resource) throws IOException {
Expand Down

0 comments on commit 3af6528

Please sign in to comment.