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

Qute message bundles - fix application class predicate #20204

Merged
merged 1 commit into from
Sep 16, 2021
Merged
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 @@ -194,8 +194,8 @@ List<MessageBundleBuildItem> processBundles(BeanArchiveIndexBuildItem beanArchiv

// Generate implementations
// name -> impl class
Map<String, String> generatedImplementations = generateImplementations(bundles,
applicationArchivesBuildItem, generatedClasses, messageTemplateMethods);
Map<String, String> generatedImplementations = generateImplementations(bundles, generatedClasses,
messageTemplateMethods);

// Register synthetic beans
for (MessageBundleBuildItem bundle : bundles) {
Expand Down Expand Up @@ -523,14 +523,12 @@ void generateExamplePropertiesFiles(List<MessageBundleMethodBuildItem> messageBu
}

private Map<String, String> generateImplementations(List<MessageBundleBuildItem> bundles,
ApplicationArchivesBuildItem applicationArchivesBuildItem,
BuildProducer<GeneratedClassBuildItem> generatedClasses,
BuildProducer<MessageBundleMethodBuildItem> messageTemplateMethods) throws IOException {

Map<String, String> generatedTypes = new HashMap<>();

ClassOutput defaultClassOutput = new GeneratedClassGizmoAdaptor(generatedClasses,
new AppClassPredicate(applicationArchivesBuildItem));
ClassOutput defaultClassOutput = new GeneratedClassGizmoAdaptor(generatedClasses, new AppClassPredicate());

for (MessageBundleBuildItem bundle : bundles) {
ClassInfo bundleInterface = bundle.getDefaultBundleInterface();
Expand Down Expand Up @@ -577,17 +575,16 @@ private Map<String, String> generateImplementations(List<MessageBundleBuildItem>

String locale = entry.getKey();
ClassOutput localeAwareGizmoAdaptor = new GeneratedClassGizmoAdaptor(generatedClasses,
new AppClassPredicate(applicationArchivesBuildItem,
new Function<String, String>() {
@Override
public String apply(String className) {
String localeSuffix = "_" + locale;
if (className.endsWith(localeSuffix)) {
return className.replace(localeSuffix, "");
}
return className;
}
}));
new AppClassPredicate(new Function<String, String>() {
@Override
public String apply(String className) {
String localeSuffix = "_" + locale;
if (className.endsWith(localeSuffix)) {
return className.replace(localeSuffix, "");
}
return className;
}
}));
generatedTypes.put(localizedFile.toString(),
generateImplementation(bundle.getDefaultBundleInterface(), bundleImpl, bundleInterface,
localeAwareGizmoAdaptor,
Expand Down Expand Up @@ -1018,16 +1015,13 @@ private Set<Path> findMessageFiles(ApplicationArchivesBuildItem applicationArchi

private static class AppClassPredicate implements Predicate<String> {

private final ApplicationArchivesBuildItem applicationArchives;
private final Function<String, String> additionalClassNameSanitizer;

public AppClassPredicate(ApplicationArchivesBuildItem applicationArchives) {
this(applicationArchives, Function.identity());
public AppClassPredicate() {
this(Function.identity());
}

public AppClassPredicate(ApplicationArchivesBuildItem applicationArchives,
Function<String, String> additionalClassNameSanitizer) {
this.applicationArchives = applicationArchives;
public AppClassPredicate(Function<String, String> additionalClassNameSanitizer) {
this.additionalClassNameSanitizer = additionalClassNameSanitizer;
}

Expand All @@ -1041,8 +1035,7 @@ public boolean test(String name) {
}
// E.g. to match the bundle class generated for a localized file; org.acme.Foo_en -> org.acme.Foo
className = additionalClassNameSanitizer.apply(className);
return applicationArchives.containingArchive(className) != null
|| GeneratedClassGizmoAdaptor.isApplicationClass(name);
return GeneratedClassGizmoAdaptor.isApplicationClass(className);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main part of the fix is GeneratedClassGizmoAdaptor.isApplicationClass(name) -> GeneratedClassGizmoAdaptor.isApplicationClass(className)!

}
}
}