xitingTick / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

r1425 MapTileProviderBase NullPointerException #520

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

Regarding r1425 "Avoid repeated casting" in class MapTileProviderBase
at line 349 there can be NullPointerException if isReusable=false
because reusableBitmapDrawable in that case is null.

Best regards, Emux
https://play.google.com/store/apps/details?id=gr.talent.cruiser

Original issue reported on code.google.com by devemu...@gmail.com on 27 Jan 2014 at 10:06

GoogleCodeExporter commented 8 years ago
Maybe I'm not seeing it, but firstly I didn't change the logic (AFAIK), and 
secondly, if the bitmap is not a ReusableBitmapDrawable then !isResuable is 
true so it won't evaluate reusableBitmapDrawable.isBitmapValid()

Original comment by neilboyd on 31 Jan 2014 at 5:52

GoogleCodeExporter commented 8 years ago
Hi Neil,

If the bitmap is not a ReusableBitmapDrawable then !isResuable is true,
so yes it won't evaluate reusableBitmapDrawable.isBitmapValid()

But it will enter the if block and there at line 349 it will process the
final Bitmap oldBitmap = reusableBitmapDrawable.getBitmap();
where it'll throw a NPE as reusableBitmapDrawable is null.

The old code at line 349 works correctly:
final Bitmap oldBitmap = ((BitmapDrawable) oldDrawable).getBitmap();

Best regards, Emux
https://play.google.com/store/apps/details?id=gr.talent.cruiser

Original comment by devemu...@gmail.com on 31 Jan 2014 at 7:26

GoogleCodeExporter commented 8 years ago
Oh, I see, I changed the code - it was a cast to a plain BitmapDrawable.
I'll fix it.

Original comment by neilboyd on 31 Jan 2014 at 8:20

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r1427.

Original comment by neilboyd on 31 Jan 2014 at 8:57