Skip to content

Commit

Permalink
fix: natural order of parameters
Browse files Browse the repository at this point in the history
 Issues smallrye#2092 and smallrye#1957.

Fixes the natural ordering inconsistency when the @parameters annotation is not used. Method parameters and BeanParam were sorted in alphabetical order if they were not declared with @parameter within the @parameters annotation.
  • Loading branch information
mrobertorr1 committed Dec 16, 2024
1 parent b2424a6 commit c5292a9
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public abstract class AbstractParameterProcessor {
protected Map<String, Map<String, AnnotationInstance>> matrixParams = new LinkedHashMap<>();

private Set<String> processedMatrixSegments = new HashSet<>();
private List<Parameter> preferredOrder;
private List<Parameter> preferredOrder = new ArrayList<>();

/**
* Used for collecting and merging any scanned {@link Parameter} annotations
Expand Down Expand Up @@ -234,6 +234,7 @@ protected void reset() {
params.clear();
formParams.clear();
matrixParams.clear();
preferredOrder.clear();
}

protected ResourceParameters process(ClassInfo resourceClass, MethodInfo resourceMethod) {
Expand Down Expand Up @@ -1373,6 +1374,10 @@ protected void readParameter(ParameterContextKey key,
}

if (preferredOrder != null) {
if (context.oaiParam == null && context.name != null) {
context.oaiParam = new ParameterImpl();
context.oaiParam.setName(context.name);
}
preferredOrder.add(context.oaiParam);
}
}
Expand Down

0 comments on commit c5292a9

Please # to comment.