Closed
Description
Describe the bug
StackOverflow error on AsyncAPI creation
java.lang.RuntimeException: Error occured during creation of AsyncAPI
Caused by: java.lang.StackOverflowError: null
In io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties
Dependencies and versions used
SpringBoot 3.3.5
Java 17
implementation("io.github.springwolf:springwolf-amqp:1.8.0")
implementation("io.github.springwolf:springwolf-amqp-binding:1.8.0")
implementation("io.github.springwolf:springwolf-ui:1.8.0")
Code example
RabbitMQ Configuration
@Configuration
class RabbitConfig {
@Bean("paymentRequestQueue")
fun requestQueue(): Queue =
Queue(AMQPConstants.QUEUE_PAYMENT_REQUESTS)
@Bean("paymentResponseQueue")
fun responseQueue(): Queue =
Queue(AMQPConstants.QUEUE_PAYMENT_RESPONSES)
@Bean("rabbitListenerContainerFactory")
fun listenerContainerFactory(
conFactory: ConnectionFactory
) =
SimpleRabbitListenerContainerFactory().apply {
setConnectionFactory(conFactory)
setMessageConverter(ProtobufMessageConverterAMQP(
PaymentRequest.getDefaultInstance()
))
setAcknowledgeMode(AcknowledgeMode.MANUAL)
}
@Bean
fun rabbitTemplate(conFactory: ConnectionFactory): RabbitTemplate {
val rabbitTemplate = RabbitTemplate(conFactory)
rabbitTemplate.messageConverter = ProtobufMessageConverterAMQP(
PaymentResponse.getDefaultInstance()
)
return rabbitTemplate
}
}
Consumer
@Component
class PaymentRequestConsumer {
@Autowired
lateinit var responseProducer: PaymentResponseProducer
@RabbitListener(queues = [AMQPConstants.QUEUE_PAYMENT_REQUESTS])
suspend fun process(
@Header(AmqpHeaders.CHANNEL) channel: Channel,
@Header(AmqpHeaders.DELIVERY_TAG) deliveryTag: Long,
@Payload requestMsg: PaymentRequest
) {
println("Processed request! ${requestMsg.id}")
responseProducer.paymentRespond(paymentResponse {
id = 1
status = PaymentResponse.Status.SUCCESSFUL
})
channel.basicAck(deliveryTag, false)
}
}
Producer
@Component
class PaymentResponseProducer {
@Autowired
private lateinit var template: RabbitTemplate
@AsyncPublisher(
operation = AsyncOperation(
channelName = AMQPConstants.QUEUE_PAYMENT_RESPONSES
)
)
@AmqpAsyncOperationBinding
fun paymentRespond(response: PaymentResponse) {
template.convertAndSend(AMQPConstants.QUEUE_PAYMENT_RESPONSES, response)
}
}
Spring `application.properties`
spring.application.name=Delivery Microservice
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
#########
# Springwolf configuration
# Copied from example project
springwolf.enabled=true
springwolf.docket.base-package=com.microdelivery.payment.consumers
springwolf.docket.info.title=${spring.application.name}
springwolf.docket.info.version=1.0.0
springwolf.docket.info.description=Springwolf example project to demonstrate springwolfs abilities
springwolf.docket.info.terms-of-service=http://asyncapi.org/terms
springwolf.docket.info.extension-fields.x-api-audience=company-internal
springwolf.docket.info.extension-fields.x-generator=springwolf
springwolf.docket.info.contact.name=springwolf
springwolf.docket.info.contact.email=[email protected]
springwolf.docket.info.contact.url=https://github.com/springwolf/springwolf-core
springwolf.docket.info.contact.extension-fields.x-phone=+49 123 456789
springwolf.docket.info.license.name=Apache License 2.0
springwolf.docket.info.license.extension-fields.x-desc=some description
springwolf.docket.servers.amqp-server.protocol=amqp
springwolf.docket.servers.amqp-server.host=${spring.rabbitmq.host}:${spring.rabbitmq.port}
springwolf.plugin.amqp.publishing.enabled=true
Stack trace and error logs
Error
java.lang.RuntimeException: Error occured during creation of AsyncAPI
at io.github.springwolf.core.asyncapi.DefaultAsyncApiService.getAsyncAPI(DefaultAsyncApiService.java:48) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.SpringwolfInitApplicationListener.onApplicationEvent(SpringwolfInitApplicationListener.java:31) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.SpringwolfInitApplicationListener.onApplicationEvent(SpringwolfInitApplicationListener.java:17) ~[springwolf-core-1.8.0.jar:na]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185) ~[spring-context-6.1.14.jar:6.1.14]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178) ~[spring-context-6.1.14.jar:6.1.14]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156) ~[spring-context-6.1.14.jar:6.1.14]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:452) ~[spring-context-6.1.14.jar:6.1.14]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:385) ~[spring-context-6.1.14.jar:6.1.14]
at org.springframework.boot.context.event.EventPublishingRunListener.ready(EventPublishingRunListener.java:109) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplicationRunListeners.lambda$ready$6(SpringApplicationRunListeners.java:80) ~[spring-boot-3.3.5.jar:3.3.5]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplicationRunListeners.ready(SpringApplicationRunListeners.java:80) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:349) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352) ~[spring-boot-3.3.5.jar:3.3.5]
at com.microdelivery.payment.PaymentApplicationKt.main(PaymentApplication.kt:13) ~[main/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.3.5.jar:3.3.5]
Caused by: java.lang.StackOverflowError: null
at java.base/java.util.LinkedHashMap.getOrDefault(LinkedHashMap.java:453) ~[na:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:39) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:33) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.lambda$removeAvroProperties$0(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[na:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:33) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.lambda$removeAvroProperties$0(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[na:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:33) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.lambda$removeAvroProperties$0(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[na:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:33) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.lambda$removeAvroProperties$0(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
Caused by: java.lang.StackOverflowError: null
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[na:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:33) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.lambda$removeAvroProperties$0(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[na:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:33) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.lambda$removeAvroProperties$0(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[na:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.removeAvroProperties(AvroSchemaPostProcessor.java:33) ~[springwolf-core-1.8.0.jar:na]
at io.github.springwolf.core.asyncapi.components.postprocessors.AvroSchemaPostProcessor.lambda$removeAvroProperties$0(AvroSchemaPostProcessor.java:49) ~[springwolf-core-1.8.0.jar:na]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[na:na]