zeta243 / osmdroid

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

MapTileDownloader throws NullPointerException on 404 #325

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Point the tile downloader to a server that gives 404's for requests

What is the expected output? What do you see instead?
Null pointer exceptions when the server returns a 404 on tile requests

What version of the product are you using? On what operating system?
HEAD

Please provide any additional information below.

This code fixes it (from line 169 in MapTileDownloader):

                final HttpClient client = new DefaultHttpClient();
                final HttpUriRequest head = new HttpGet(tileURLString);
                final HttpResponse response = client.execute(head);
                final org.apache.http.StatusLine line = response.getStatusLine();
                if( line.getStatusCode() != 200 ) {
                    logger.warn( "Problem downloading MapTile: " + tile + " HTTP response: " + line );
                    return null;
                }
                final HttpEntity entity = response.getEntity();
                if (entity == null) {
                    logger.warn("No content downloading MapTile: " + tile);
                    return null;
                }

Original issue reported on code.google.com by unoi...@gmail.com on 19 Mar 2012 at 10:56

GoogleCodeExporter commented 9 years ago
Thank you for providing this bug report along with a fix! I have tested this 
and am going to commit it now.

Original comment by kurtzm...@gmail.com on 6 Apr 2012 at 9:32

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1088.

Original comment by kurtzm...@gmail.com on 6 Apr 2012 at 9:34