spring-projects/spring-batch

Call List<JobExecution> getJobExecutions(JobInstance jobInstance) causes a INTERNAL_SERVER_ERROR when using MongoDB as Job Repository

Closed this issue · 0 comments

Please do a quick search on Github issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description
Call List getJobExecutions(JobInstance jobInstance) return a very long result and causes a INTERNAL_SERVER_ERROR:

    "httpStatus": "INTERNAL_SERVER_ERROR",
    "message": "Document nesting depth (1001) exceeds the maximum allowed (1000, from `StreamWriteConstraints.getMaxNestingDepth()`) (through reference chain: com.paypal.ppcn.merchantleads.model.JsonResult[\"data\"]->java.util.ImmutableCollections$ListN[0]-mework.batch.core.JobExecution[\"stepExecutions\"]->java.util.ImmutableCollections$List12[0]->org.springframework.batch.core.StepExecution[\"jobExecution\"]->org.springframework.batch.core.JobExecution[\"stepExecutions\"]->java.util.ImmutableCollections$List12[0]-
......
>org.springframework.batch.core.StepExecution[\"jobExecution\"]->org.springframework.batch.core.JobExecution[\"jobParameters\"]->org.springframework.batch.core.JobParameters[\"parameters\"])",
    "data": "[com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402), com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361), com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:323), com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:778), com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:184), com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:732), com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770), com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:184), com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:732), com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770), com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:184), com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119), com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79), com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18), com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:732), com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770),
......

Environment
Spring batch 5.2, java 17, MongoDB 4.4.15-15

Steps to reproduce
Call List getJobExecutions(JobInstance jobInstance)

Expected behavior
Should return result without exception

Minimal Complete Reproducible example
Seemed like this issue is caused by a reference cycle: JobExecution reference StepExecution, StepExecution reference JobExecution.