Bug? SFtp (jsch library): if method called without initialising, the method doesn't throw an exception

teddybear

Well-Known Member
Licensed User
See title - this caught me off guard; I'd expect an exception to be thrown?

B4X:
Sub Process_Globals
End Sub

Sub AppStart (Args() As String)
    Dim sftp1 As SFtp ' Not initialised
    Log("Before")
    sftp1.List("A/B/C")
    Log("After")
End Sub
In the IDE,the uninitialized sftp will be indicated with wavy line. you can also see warnings in logs.
because you need to get the results of the list method from the list event, a event name must be specied for the sftp.
I don't think it is a bug.
 

walt61

Well-Known Member
Licensed User
Longtime User
I think it is. What you're saying about the IDE is true, but I've just simplified the code here to show the principle. In my real B4A app/B4J program, the object gets initialised 'somewhere', so the IDE considers it ok. At run time, the Wait For the event never finishes as the event isn't raised if the initialisation is missed.
 
Top