Friday, December 29, 2023

Jackson vs. Android package optimization

 For some weird reason (including a 20MB text file to be precise) I wanted to turn on 

shrinkResources true
minifyEnabled true

in my Android app.
I did the compression alright, but the app stopped working.
I got weird Exceptions like 
Cannot construct instance of `g1.k` (no Creators, like default ...)

Well that pointed me to obfuscation, because I definitely don't have classes and members like that.

Jackson relies on reflection to find your class properties and getter/setter functions, so you should not obfuscate them. Duuuh.

They way to turn that off is in the file.

-keepattributes *Annotation*,EnclosingMethod,Signature
-keepnames class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.databind.**
-keep public class** {

The last part keeps the whole package where all my entity classes are.

Sunday, April 16, 2023

NULL values again

Today I learned that you essentially cannot concatenate (concat, ||) nullable columns properly in DB2/SQL.

To be honest, I should have know this of course.

I have a table that records money spent, with a date, text, account and a physical location, e.g. a town, district, ... indicating where the money was spent.

It is nullable because not all transactions need to have a place recorded.

For some statistical analysis I wanted to create one column with text and account and the location simply concatenated into one, like account||' '||text||' '||location.

Turns out, then the location is NULL the whole string will turn NULL

Which reminded me - painfully, after about 30min - that NULL is not a value. You cannot do anything with NULL.

So you have to cast it away to a default value, e.g. with coalesce(location,'dummylocation').