Modify

Opened 16 years ago

Closed 16 years ago

#2936 closed defect (fixed)

java.lang.NullPointerException on photo import

Reported by: Chris Bainbridge <chris.bainbridge@…> Owned by: team
Priority: major Milestone:
Component: Core Version: latest
Keywords: Cc:

Description

This is with josm-r1779:

Uncaught error fetching image:
java.lang.NullPointerException

at org.openstreetmap.josm.gui.layer.GeoImageLayer$ImageEntry.imageLoaded(GeoImageLayer.java:267)
at org.openstreetmap.josm.gui.layer.GeoImageLayer$ImageLoader.finishImage(GeoImageLayer.java:183)
at org.openstreetmap.josm.gui.layer.GeoImageLayer$ImageLoader.imageUpdate(GeoImageLayer.java:228)
at sun.awt.image.ImageWatched$WeakLink.newInfo(ImageWatched.java:114)
at sun.awt.image.ImageWatched.newInfo(ImageWatched.java:151)
at sun.awt.image.ImageRepresentation.imageComplete(ImageRepresentation.java:639)
at sun.awt.image.ImageDecoder.imageComplete(ImageDecoder.java:135)
at sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:121)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)

Attachments (1)

image-load.patch (560 bytes ) - added by plaicy 16 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by plaicy, 16 years ago

Could you attach the photo? With my photos I do not get this error.

comment:2 by jttt, 16 years ago

It fails on Main.map.mapView.repaint(). That is really incorrect because image are loaded asynchronously and MapView might be removed before all images are loaded.

comment:3 by plaicy, 16 years ago

Okay. The 98% solution would be to check for null (I add a patch). The 99% solution would use java.util.concurrent.atomic.AtomicReference for Main.map and Main.map.mapView. The 100% must check if Main.map.mapView allows concurrent access and maybe block or a queue or something like that.

by plaicy, 16 years ago

Attachment: image-load.patch added

comment:4 by jttt, 16 years ago

There is another solution:

MapFrame frame = Main.map;
if (frame != null) {
  frame.mapView.repaint()
}

comment:5 by plaicy, 16 years ago

I did not know reading and writing to references is in Java atomic: http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.7

So, iIf Main.map.mapView is granted to be non-null this is better.

In C this is not granted...

comment:6 by jttt, 16 years ago

Reading and writing of references is atomic. The link is about 8 byte variables while reference has only 4 bytes (even on 64b machine, reference is not the same thing as pointer).

If reading of references wasn't atomic then it would be possible to have invalid reference (first half comes from one thread, second from another thread). Fortuanatelly this can never happen.

comment:7 by jttt, 16 years ago

Resolution: fixed
Status: newclosed

Fixed in r1863

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.