Does not store avatar image in disk cache

Issue #123 closed
Markus KARG created an issue

I think there is a bug in the AvatarManager, but I need your judgement before sending a pull request:

// From AvatarManager.java:
                    userHashes.put(contact, hash1);
                    if (!Arrays.equals(avatar, new byte[0])) {
                        storeToCache(hash, avatar);
                    }

In case there is no local avatar existing, variable 'hash' (without suffix '1') is 'null'. So an avatar image is pulled from server. A new hash of that downloaded image is then stored in 'hash1', and we remember it in 'userHashes'. But in the next line (see above) we try to store the OLD hash (whithout suffix '1'), which still is 'null'. Hence, we end up with a silent com.sun exception because we cannot store 'null'.

I assume this is a bug...? I can fix it, but I need your opinion first.

Comments (5)

  1. Christian Schudt repo owner

    Yes, I am pretty sure it's a bug. This code used to be synchronous, only one hash variable was used. When lamddas and asynchronous code was introduced hash needed to be final and a new hash1 was introduced (maybe even automatically by IntelliJ?). The storeToCache has been overlooked here.

  2. Markus KARG reporter

    Files pull request #36 to fix this. Take care when merging, Bitbucket always replaces the selected target branch (weird!)

    One more question. Once I fixed that I noticed that the roster manager tells me that I have a contact with "BOTH" subscription indicated, but I have to pull the avatar of that contact manually, while my own avatar is pushed from the server automatically at login. Is that normal? I thought either I have to pull both avatars on my own, OR get pushed BOTH.

  3. Log in to comment