Async - java.lang.InterruptedException marking test case as error even after being catched

as I send methods as parameters to the following function from the actual test case I get the test case marked as Failed because of a catched Exception

the following method runs two functions simultaneously and returns the value of whichever finishes first

package functions

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import org.openqa.selenium.WebDriver

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import org.openqa.selenium.By
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.util.KeywordUtil
import internal.GlobalVariable
import java.util.concurrent.CompletableFuture
import java.util.concurrent.Executors
import java.util.concurrent.ExecutorService


public class Async {
	Closure temp1
	Closure temp2

	@Keyword
	public def getFirstResult(Closure function1, Closure function2) {

		ExecutorService executor1 = new Executors().newSingleThreadExecutor()
		
		ExecutorService executor2 = new Executors().newSingleThreadExecutor()
		
	
		this.temp1 = function1
		this.temp2 = function2
		CompletableFuture <?> Function1 = new CompletableFuture().supplyAsync( this.&temp1, executor1)
		CompletableFuture <?> Function2 = new CompletableFuture().supplyAsync( this.&temp2, executor2)

		def results = CompletableFuture.anyOf(Function1, Function2).get()
		
		if(Function1.isDone()) {
			Function2.cancel(true);
				
				try{
					executor2.shutdownNow()
					
				}
				catch(Throwable ex){
					println "exception:+ "+ex;
				}
		}
		else{
			Function1.cancel(true);
	
				try{
					executor1.shutdownNow()
				
					
				}
				catch(Throwable ex){
					println "exception: "+ex;
				}
		}


		return results
	}
}

then the method in the test case looks like this

boolean noResults()
{
	try{
    //Element_Visibility.byXpath is a Selenium implementation of implicit wait
	CustomKeywords.'functions.Element_Visibility.byXpath'("//*[contains(text(), 'There were no matching results found') or contains(text(), 'Error') or contains(text(), 'Please apply filters to narrow search results')]", 120)
	return false
	}
	catch(Throwable ex){
		println "Ignore ^"+ ex
	}
	
}

**But, I don’t want to fail the test case because of this failed step which failed purposely **

2019-07-15 17:06:34.492 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - :x: java.lang.InterruptedException: sleep interrupted
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘MACOS’, ip: ‘192.168.20.71’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: driver.version: unknown
2019-07-15 17:06:34.492 DEBUG testcase.Contacts - 2: catch (Throwable ex)
2019-07-15 17:06:34.493 DEBUG testcase.Contacts - 1: println(“Ignore ^” + ex)
Ignore ^com.kms.katalon.core.exception.StepErrorException: org.openqa.selenium.WebDriverException: java.lang.InterruptedException: sleep interrupted
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘MACOS’, ip: ‘192.168.20.71’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: driver.version: unknown
Element Found!
2019-07-15 17:06:34.515 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - :x: org.openqa.selenium.WebDriverException: java.lang.InterruptedException: sleep interrupted
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘MACOS’, ip: ‘192.168.20.71’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: driver.version: unknown

I’ve never used the async objects in Java, so take this with a pinch of salt.

Your boolean noResults has two exit paths. Only one returns a deliberate boolean result.

I’d be interested to learn why you took the async/threaded approach, though.

Hi Russ,
for this specific scenario, the two functions are:

boolean results()
{
	try{
		
	WebUI.delay(1)	
	CustomKeywords.'functions.Element_Visibility.byText'(  'Actions',120)
	return true
	}
	catch (Throwable ex)
	{
		println "Ignore ^"+ ex
		
	}
}

boolean noResults()
{
	try{
	CustomKeywords.'functions.Element_Visibility.byXpath'("//*[contains(text(), 'There were no matching results found') or contains(text(), 'Error') or contains(text(), 'Please apply filters to narrow search results')]", 120)
	return false
	}
	catch(Throwable ex){
		println "Ignore ^"+ ex
	}
	
}

the wait time for both is 120 seconds. So, one will always finish before the other one is terminated.
Also, the function CompletableFuture.anyOf() returns only one of the two function’s results

The reason I took this approach is because I did not want to wait for one or the other, but for whichever finishes first within the 120 seconds interval.
The specific test case is testing a search functionality in the case there are no results, I do not want to fail my test case.

Update: after moving the two functions to the Async class, no errors are being displayed in the test case’s Console