diff --git a/addOns/spider/CHANGELOG.md b/addOns/spider/CHANGELOG.md index 5daa6554d86..f743b1d866b 100644 --- a/addOns/spider/CHANGELOG.md +++ b/addOns/spider/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Handle persistence errors and forced shutdown in automation job. +- Address memory leak. ## [0.18.0] - 2025-12-15 ### Changed diff --git a/addOns/spider/src/main/java/org/zaproxy/addon/spider/SpiderTask.java b/addOns/spider/src/main/java/org/zaproxy/addon/spider/SpiderTask.java index 8a2a3c67f5a..5503aa5e5e2 100644 --- a/addOns/spider/src/main/java/org/zaproxy/addon/spider/SpiderTask.java +++ b/addOns/spider/src/main/java/org/zaproxy/addon/spider/SpiderTask.java @@ -76,14 +76,13 @@ public class SpiderTask implements Runnable { */ private HistoryReference reference; - /** The spider resource found. */ - private SpiderResourceFound resourceFound; - private ExtensionHistory extHistory; /** The Constant log. */ private static final Logger LOGGER = LogManager.getLogger(SpiderTask.class); + private final int depth; + /** * Instantiates a new spider task using the target URI. The purpose of this task is to crawl the * given uri, using the provided method and supplied request headers, find any other uris in the @@ -99,7 +98,7 @@ public class SpiderTask implements Runnable { public SpiderTask(Spider parent, SpiderResourceFound resourceFound, URI uri) { super(); this.parent = parent; - this.resourceFound = resourceFound; + this.depth = resourceFound.getDepth(); LOGGER.debug("New task submitted for uri: {}", uri); @@ -151,7 +150,7 @@ public void run() { LOGGER.debug( "Spider Task Started. Processing uri at depth {} using already constructed message: {}", - resourceFound.getDepth(), + depth, reference.getURI()); runImpl(); @@ -234,9 +233,9 @@ private void runImpl() { parent.checkPauseAndWait(); int maxDepth = parent.getSpiderParam().getMaxDepth(); - if (maxDepth == SpiderParam.UNLIMITED_DEPTH || resourceFound.getDepth() < maxDepth) { + if (maxDepth == SpiderParam.UNLIMITED_DEPTH || depth < maxDepth) { parent.notifyListenersSpiderTaskResult(new SpiderTaskResult(msg)); - processResource(parent, resourceFound.getDepth(), msg); + processResource(parent, depth, msg); } else { parent.notifyListenersSpiderTaskResult( new SpiderTaskResult(msg, getSkippedMessage("maxdepth")));