Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NU-1683] Fixes memory leak in test mechanism introduced in #4956 #6337

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* [#6245](https://github.com/TouK/nussknacker/pull/6245) Parameter validations defined in AdditionalUIConfigProvider now properly impact dynamic components.
* [#6264](https://github.com/TouK/nussknacker/pull/6264) Fix for DatabaseLookupEnricher mixing fields values when it is connected to ignite db
* [#6270](https://github.com/TouK/nussknacker/pull/6270) Resolved an issue with comparing remote versions
* [#6337](https://github.com/TouK/nussknacker/pull/6337) Fixes memory leak in test mechanism introduced in 1.13 version ([#4901](https://github.com/TouK/nussknacker/pull/4901))

1.15.4 (5 July 2025)
-------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ class FlinkTestMain(
val configuration: Configuration
) extends FlinkStubbedRunner {

def runTest: TestResults[Json] =
Using.resource(ResultsCollectingListenerHolder.registerTestEngineListener) { collectingListener =>
def runTest: TestResults[Json] = {
val collectingListener = ResultsCollectingListenerHolder.registerTestEngineListener
try {
val resultCollector = new TestServiceInvocationCollector(collectingListener)
val registrar = prepareRegistrar(collectingListener, scenarioTestData)
val env = createEnv

registrar.register(env, process, processVersion, deploymentData, resultCollector)
execute(env, SavepointRestoreSettings.none())
collectingListener.results
} finally {
collectingListener.clean()
}
}

protected def prepareRegistrar(
collectingListener: ResultsCollectingListener[Json],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ case class ResultsCollectingListener[T](holderClass: String, runId: TestRunId, v

def results: TestResults[T] = ResultsCollectingListenerHolder.resultsForId(runId)

// Warning! close can't clean resources because listener is passed into each scenario subpart and it will be closed few times
// We have to use dedicated clean() method when we are sure that we consumed results instead.
override final def close(): Unit = {}

def clean(): Unit = ResultsCollectingListenerHolder.cleanResult(runId)

override def nodeEntered(nodeId: String, context: Context, processMetaData: MetaData): Unit = {
Expand Down
Loading