Add a safeguard by not adding more than the 1000 traces during visitation.
@@ -1036,7 +1036,9 @@ public class MessageBusVisitorSession implements VisitorSession {
params.getControlHandler().onProgress(progress.getToken());
statistics.add(reply.getVisitorStatistics());
params.getControlHandler().onVisitorStatistics(statistics);
- if ( ! reply.getTrace().getRoot().isEmpty() ) {
+ // A visitor session might be long lived so we need a safeguard against blowing the memory if tracing
+ // has been enabled.
+ if ( ! reply.getTrace().getRoot().isEmpty() && (trace.getRoot().getNumChildren() < 1000)) {
trace.getRoot().addChild(reply.getTrace().getRoot());
}
