Modify

Opened 14 years ago

Closed 14 years ago

#6752 closed defect (worksforme)

JMapViewer Encounters java.lang.IllegalArgumentException: input == null!

Reported by: jhuntley Owned by: team
Priority: normal Milestone:
Component: Core Version: latest
Keywords: JMapViewer Cc:

Description

While loading images for tiles, the following exception is encountered:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: input == null!

at javax.imageio.ImageIO.read(Unknown Source)
at org.openstreetmap.gui.jmapviewer.tilesources.BingAerialTileSource.getAttributionImage(BingAerialTileSource.java:171)
at org.openstreetmap.gui.jmapviewer.JMapViewer.setTileSource(JMapViewer.java:703)
at com.houghtonassociates.incident.ui.components.IncidentMapView$1.itemStateChanged(IncidentMapView.java:84)...

I've searched and found the following ticket:

https://josm.openstreetmap.de/ticket/5993

However, the fix for this ticket doesn't seem to be included or applicable to JMapViewer. I've since found the problem in code and am happy to supply a fix for JMapViewer, if not done already.

The following code fixes this problem in JMapViewer:

From BingAerialTileSource.java

    @Override
    public Image getAttributionImage() {
        try {
        	Image img=null;

        	InputStream is=getClass().getResourceAsStream("images/bing_maps.png");
        	
        	if (is!=null)
        		img=ImageIO.read(is);
        	
            	return img;
        	
		//Old Way encounters exception inline
        	//return ImageIO.read(getClass().getResourceAsStream("images/bing_maps.png"));
        } catch (IOException e) {
            return null;
        }
    }

Attachments (0)

Change History (5)

comment:1 by jhuntley, 14 years ago

An alternative is to change IOException to Exception or add IllegalArgumentException to the catch.

comment:3 by bastiK, 14 years ago

Why would getResourceAsStream return null? Is it possible, that you simply don't have the image in class path? In that case, the current exception should be enough.

in reply to:  3 comment:4 by jhuntley, 14 years ago

Replying to bastiK:

Why would getResourceAsStream return null? Is it possible, that you simply don't have the image in class path? In that case, the current exception should be enough.

Right, it returns null if the image isn't in the classpath. This ticket is old and doesn't seem to be a issue at the moment. Might not hurt to have the error checking so a null exception isn't encountered in the event the image is missing, for whatever reason. Regardless, this isn't a serious issue, and I won't be offended if you decide to close it.

comment:5 by bastiK, 14 years ago

Resolution: worksforme
Status: newclosed

Image shouldn't be missing, so the exception is all right.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.