Skip to content

Commit

Permalink
Improve logging when type args do not match params, type parse trim (#…
Browse files Browse the repository at this point in the history
…1993)

Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar committed Sep 23, 2024
1 parent 0cfefa0 commit 9497960
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package io.smallrye.openapi.runtime.scanner.dataobject;

import java.util.List;

import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.ParameterizedType;
import org.jboss.jandex.Type;
import org.jboss.jandex.TypeVariable;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.LogMessage;
Expand Down Expand Up @@ -83,9 +80,9 @@ interface DataObjectLogging extends BasicLogger {
void classNotAvailable(Type type);

@LogMessage(level = Logger.Level.ERROR)
@Message(id = 31016, value = "Unanticipated mismatch between type arguments and type variables \n" +
"Args: %s\n Vars:%s")
void classNotAvailable(List<TypeVariable> typeVariables, List<Type> arguments);
@Message(id = 31016, value = "Unanticipated mismatch between type arguments and type variables declared on class\n" +
"Class: %s\nType: %s")
void classNotAvailable(String classDeclaration, String typeSignature);

@LogMessage(level = Logger.Level.WARN)
@Message(id = 31017, value = "Failed to read enumeration values from enum %s method %s with `@JsonValue`: %s")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,9 @@ private static Map<String, Type> buildParamTypeResolutionMap(ClassInfo klazz, Pa
List<Type> arguments = parameterizedType.arguments();

if (arguments.size() != typeVariables.size()) {
DataObjectLogging.logger.classNotAvailable(typeVariables, arguments);
String vars = typeVariables.stream().map(TypeVariable::toString).collect(Collectors.joining(", "));
DataObjectLogging.logger.classNotAvailable(klazz.name() + "<" + vars + ">", parameterizedType.toString());
return Collections.emptyMap();
}

Map<String, Type> resolutionMap = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ private int advanceNot(char c) {
}

private DotName parseName() {
while (Character.isWhitespace(signature.charAt(pos))) {
pos++;
}
int start = pos;
int end = advanceNameEnd();
return DotName.createSimple(signature.substring(start, end));
Expand Down

0 comments on commit 9497960

Please sign in to comment.