B4J Question Is it BUG, that in debug mode no exception but release mode yes?

rosippc64a

Active Member
Licensed User
Longtime User
Hi Everybody,
I have a code piece, what works good in debug mode, but not in release mode. I think it should generate an exception in debug mode also, but it doesn't.
B4X:
            If szf.GetString("IdoszakielszIN")="I" Then
                sb.Append($"
                    <invoiceDeliveryPeriodStart>${szf.GetString("Idoszakkezdete")}</invoiceDeliveryPeriodStart>
                    <invoiceDeliveryPeriodEnd>${szf.GetString("Idoszakvege")}</invoiceDeliveryPeriodEnd>
                    <invoiceAccountingDeliveryDate>${szf.GetString("Idoszakvege")}</invoiceAccountingDeliveryDate>
                "$)
            End If
The value of szf.GetString("IdoszakielszIN") is null. So in debug mode the compare null="I" is valid and the result is false, in release mode generate an exception ((NullPointerException) java.lang.NullPointerException).
I use postgres database and the szf.GetString("IdoszakielszIN") resulted a real null, not a string converted 'null'.
Is it a bug, or normal?
 

rosippc64a

Active Member
Licensed User
Longtime User
Yes, I tried, but fail. The solution was I give default value ("N") to this db field.

Here is the question not that, but whether it is normal that the same code works otherwise in debug mode as in release mode in B4J?
 
Last edited:
Upvote 0

keirS

Well-Known Member
Licensed User
Longtime User
If you want to know whether a string is null it's quite easy:


Is ResultSet Column Null?:
R = JSQL.ExecQuery("select * from test2")
    Dim JO As JavaObject = R
    Do While R.NextRow
         Dim ISNull As Object =  JO.RunMethod("getObject",Array As Object("st2"))
         If ISNull = Null Then
             Log("String is Null")
        Else
            Log(R.GetString("st2"))
        End If
        
        
Loop
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
Thank you @keirS, interesting solution, I think will use, but additionally I would that null="I" comparison (doesn't matter it is a good or wrong) do work at the same manner in debug and release mode!
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
Thank you @Erel you are right. That is interesting, since there was a moment when it failed (post #3), but now it works well.
As I wrote there was another solution giving default value to the database field, I just wondering what would be the reason of that, that b4j program works different in debug and release mode.
 
Upvote 0
Top