Skip to content

Commit

Permalink
Ensure the classes to be bound in JAXB are cleared in DEV mode
Browse files Browse the repository at this point in the history
The classes in the recorder were not cleared when restaring the app, so the classes to be bound were accumulated in each iteration.

Fix quarkusio#33441

(cherry picked from commit 4a5006e)
  • Loading branch information
Sgitario authored and gsmet committed May 23, 2023
1 parent 92a9a19 commit 7b1d0ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ void bindClassesToJaxbContext(
SynthesisFinishedBuildItem beanContainerState,
JaxbContextConfigRecorder jaxbContextConfig /* Force the build time container to invoke this method */) {

jaxbContextConfig.reset();
final BeanResolver beanResolver = beanContainerState.getBeanResolver();
final Set<BeanInfo> beans = beanResolver
.resolveBeans(Type.create(DotName.createSimple(JAXBContext.class), org.jboss.jandex.Type.Kind.CLASS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public void addClassesToBeBound(Collection<Class<?>> classes) {
this.classesToBeBound.addAll(classes);
}

public void reset() {
classesToBeBound.clear();
}

public static Set<Class<?>> getClassesToBeBound() {
return Collections.unmodifiableSet(classesToBeBound);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.RequestScoped;
Expand Down Expand Up @@ -71,7 +73,7 @@ public JAXBContext createJAXBContext(Instance<JaxbContextCustomizer> customizers
customizer.customizeContextProperties(properties);
}

List<Class> classes = new ArrayList<>();
Set<Class> classes = new HashSet<>();
classes.addAll(Arrays.asList(extraClasses));
classes.addAll(JaxbContextConfigRecorder.getClassesToBeBound());

Expand Down

0 comments on commit 7b1d0ab

Please sign in to comment.