Ensure that generated exceptions mappers don't collide

This could happen if multiple exceptions with the same simple name
but different package names were used
This commit is contained in:
Georgios Andrianakis
2019-11-27 13:50:48 +02:00
committed by Guillaume Smet
parent 4fbbeba236
commit 7382ac641f

View File

@@ -11,6 +11,7 @@ import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.DotName;
import io.quarkus.deployment.util.HashUtil;
import io.quarkus.gizmo.ClassCreator;
import io.quarkus.gizmo.ClassOutput;
import io.quarkus.gizmo.MethodCreator;
@@ -33,9 +34,10 @@ abstract class AbstractExceptionMapperGenerator {
abstract void generateMethodBody(MethodCreator toResponse);
String generate() {
String generatedClassName = "io.quarkus.spring.web.mappers." + exceptionDotName.withoutPackagePrefix() + "Mapper";
String generatedClassName = "io.quarkus.spring.web.mappers." + exceptionDotName.withoutPackagePrefix() + "_Mapper_"
+ HashUtil.sha1(exceptionDotName.toString());
String generatedSubtypeClassName = "io.quarkus.spring.web.mappers.Subtype" + exceptionDotName.withoutPackagePrefix()
+ "Mapper";
+ "Mapper_" + HashUtil.sha1(exceptionDotName.toString());
String exceptionClassName = exceptionDotName.toString();
try (ClassCreator cc = ClassCreator.builder()