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

Improve logging when type args do not match params, type parse trim #1993

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
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
@@ -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