From 4662def90f8a239a6eba74cc600cda45e33ec202 Mon Sep 17 00:00:00 2001 From: Aleksey Dobrynin Date: Thu, 28 May 2026 16:14:57 +0200 Subject: [PATCH] IDEA-388916 TestNG: handle empty properties file path GitOrigin-RevId: 5ededf909cab235b4badddab3ff851794623390e --- .../testng/configuration/SearchingForTestsTask.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java index c9920bf35214..b9853c86164d 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.theoryinpractice.testng.configuration; @@ -283,13 +283,13 @@ public class SearchingForTestsTask extends SearchForTestsTask { Map testParams = new HashMap<>(); // Override with those from the test runner configuration - if (myData.PROPERTIES_FILE != null) { + if (!StringUtil.isEmptyOrSpaces(myData.PROPERTIES_FILE)) { File propertiesFile = new File(myData.PROPERTIES_FILE); - if (propertiesFile.exists()) { + if (propertiesFile.isFile()) { Properties properties = new Properties(); - try { - properties.load(new FileInputStream(propertiesFile)); + try (FileInputStream inputStream = new FileInputStream(propertiesFile)) { + properties.load(inputStream); properties.forEach((key, value) -> testParams.put((String)key, (String)value)); }