Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAILS-11795 preserve order of bean-defined basenames. #11796

Open
wants to merge 2 commits into
base: 5.2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@
import java.io.File;
import java.io.FilenameFilter;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
Expand All @@ -65,6 +62,7 @@ public class PluginAwareResourceBundleMessageSource extends ReloadableResourceBu
private long pluginCacheMillis = Long.MIN_VALUE;
private boolean searchClasspath = false;
private String messageBundleLocationPattern = "classpath*:*.properties";
String[] basenamesDefinition = {};

public PluginAwareResourceBundleMessageSource() {
}
Expand All @@ -86,6 +84,12 @@ public void setResourceResolver(PathMatchingResourcePatternResolver resourceReso
this.resourceResolver = resourceResolver;
}

@Override
public void setBasenames(String... basenames){
basenamesDefinition = basenames;
super.setBasenames(basenames);
}

public void afterPropertiesSet() throws Exception {
if (pluginCacheMillis == Long.MIN_VALUE) {
pluginCacheMillis = cacheMillis;
Expand Down Expand Up @@ -148,8 +152,10 @@ public boolean accept(File dir, String name) {
basenames.add(baseName);
}

setBasenames(basenames.toArray( new String[basenames.size()]));

List<String> mergedBasenames = new ArrayList<>(Arrays.asList(basenamesDefinition));
basenames.removeAll(mergedBasenames);
mergedBasenames.addAll(basenames);
super.setBasenames(mergedBasenames.toArray(new String[0]));
}


Expand Down