Block finally doesn't run in katalon 5.4

Vinh Nguyen said:

I’m not sure what you mean here. Finally block does execute based on your provided information, so it do its expected behaviors.

This bug continues in the linux version

I tried the latest version for Linux, whose source code was last modified on 04/23/04, while the Windows version was modified on 04/27/04, which makes me think that the Linux version does not has the solution

Hugs

Vinh Nguyen said:

I’m not sure what you mean here. Finally block does execute based on your provided information, so it do its expected behaviors.

Thank you again for investigating. We do appreciate the time and effort you put in to help us.

In my snippets above, you can see that the FINALLY blocks of println(‘Inside FINALLY block’) did not execute – whether the TRY block succeeds or fails. You also do not see the Katalonlog of Start action : Statement - Finally that is shown in your screengrab.

In builds 5.3.1, Katalon followed the programming convention where the FINALLY block always executes – If the TRY block succeeds, the FINALLY block executes. If the TRY block fails, the exceptions are thrown and the FINALLY block still executes. (Even when the FailureHandling is set to STOP_ON_FAILURE.)

My reference for FINALLY – https://docs.oracle.com/javase/tutorial/essential/exceptions/finally.html

In the current 5.4.1 Build 1 of Katalon, on my Mac running Mobile test cases, the FINALLY block never runs.

I use the FINALLY block to tear down and reset the device back to a “zero” or starting-state, which involves more than just uninstalling my app. (I configure the settings and install/uninstall other apps and files, surf in Chrome, and other things.)

To help debug, I replicated your script (without using Mobile keywords), and you can see below that the FINALLY block did not execute. The JVM is still active, since the last println did write.

Screen Shot 2018-05-16 at 10.59.04 AM.png

I also noticed yesterday with the current Windows version that the finally block was not running. I didn’t have the code I was using right now, but in the end I was content to write down my final actions after the catch block, outside of a finally block - which even worked.

By the way: What are the advantages of such a finally block, even if it seems to work (as I would expect) without it? Sorry for my ignorance, but I’ve never used this try-catch structure before.

@Drunda Nibel Good question … I found this on StackFlow: https://stackoverflow.com/questions/15768645/what-is-the-benefit-to-use-finally-after-try-catch-block-in-java

1 Like

Thanks David,
great source that makes things clearer to me!

Drunda Nibel said:

I also noticed yesterday with the current Windows version that the finally block was not running. I didn’t have the code I was using right now, but in the end I was content to write down my final actions after the catch block, outside of a finally block - which even worked.

By the way: What are the advantages of such a finally block, even if it seems to work (as I would expect) without it? Sorry for my ignorance, but I’ve never used this try-catch structure before.

Hi

In the Windows version, the finally block works perfectly, I’ve tested it downloading the latest version.

**But in the Linux version it does not work, neither on Mac like say David in his comments **

regards

Hi Carlos,

In the Windows version, the finally block works perfectly, I’ve tested it downloading the latest version.

Have you even considered that there may be other special circumstances besides the operating system version that could make one thing look different to yours?

I’ve just double checked it again. And believe it or not, for me it is still not working.

Here is my code:

try {
    println '### try ###'
}
catch (Exception e) {
    println '### catch ###'
}
finally {
    println '### finally ###'
}
println '### try-catch-finally finished ###'

If no error occurs, I get this:

05-17-2018 02:20:31 PM - [START] - Start Test Case : Test Cases/test_finally
05-17-2018 02:20:32 PM - [INFO] - Evaluating variables for test case
05-17-2018 02:20:34 PM - [START] - Start action : Statement - Try
05-17-2018 02:20:34 PM - [START] - Start action : Statement - println(“### try ###”)
### try ###
05-17-2018 02:20:34 PM - [END] - End action : Statement - println(“### try ###”)
05-17-2018 02:20:34 PM - [END] - End action : Statement - Try
05-17-2018 02:20:34 PM - [START] - Start action : Statement - println(“### try-catch-finally finished ###”)
### try-catch-finally finished ###
05-17-2018 02:20:34 PM - [END] - End action : Statement - println(“### try-catch-finally finished ###”)
05-17-2018 02:20:34 PM - [PASSED] - Test Cases/test_finally
05-17-2018 02:20:34 PM - [END] - End Test Case : Test Cases/test_finally

Where do you see the finally block?

Almost the same in case of an error, where only the catch block appears additionally as expected.

I am using the 64bit version of Katalon Studio 5.4.1 on Windows 10, which itself pretends to be the very latest.

Best regards

hi @Drunda Nibel
I use Windows server 2012 r2, katalon 5.4.1 downdload May 7

@Vinh Nguyen in Linux still fails

finally2.JPG

@Vinh Nguyen excuse the insistence, do you have any news about this fix for the linux version?

Carlos, why again only for the Linux version?? So that this doesn’t go down: The problem also occurs with the Windows version (under certain circumstances). See my posts above.

And for the record: I would also be interested in a solution. :slight_smile: Thanks.

with the new version 5.4.2 the finally block works perfectly

1 Like

Yaay! Thank you. On 5.4.2 on Mac, the FINALLY block is working.