Opened 8 years ago

Closed 8 years ago

#3344 closed defect (fixed)

NullPointerException in read-xml on DB connection error

Reported by: lonvia Owned by: lonvia
Priority: minor Milestone:
Component: osmosis Version:
Keywords: Cc:

Description

When using osmosis to read from an xml file into a DB and the DB connection fails for some reason, there is a NullPointerException? in the error handling code of both, the --read-xml and and the --fast-read-xml tasks. This inconveniently hides the true error.

Here the exception trace for the case where the supplied password for the DB was wrong using the latest osmosis version from svn:

me@here:osm$ osmosis --fast-read-xml planet-101117.osm.bz2 --wp database=osm  user=osm
Nov 21, 2010 11:29:22 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Osmosis Version SNAPSHOT-r24324
Nov 21, 2010 11:29:23 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Preparing pipeline.
Nov 21, 2010 11:29:23 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Launching pipeline execution.
Nov 21, 2010 11:29:23 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Pipeline executing, waiting for completion.
Nov 21, 2010 11:29:23 PM org.openstreetmap.osmosis.core.pipeline.common.ActiveTaskManager waitForCompletion
SEVERE: Thread for task 1-fast-read-xml failed
java.lang.NullPointerException
        at org.openstreetmap.osmosis.pgsnapshot.v0_6.PostgreSqlCopyWriter.release(PostgreSqlCopyWriter.java:118)
        at org.openstreetmap.osmosis.xml.v0_6.FastXmlReader.run(FastXmlReader.java:101)
        at java.lang.Thread.run(Thread.java:636)
Nov 21, 2010 11:29:23 PM org.openstreetmap.osmosis.core.Osmosis main
SEVERE: Execution aborted.
org.openstreetmap.osmosis.core.OsmosisRuntimeException: One or more tasks failed.
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.waitForCompletion(Pipeline.java:  146)
        at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:92)
        at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:31)

Change History (2)

comment:1 Changed 8 years ago by brett@…

  • Owner changed from brett@… to lonvia
  • Status changed from new to assigned

The problem was in the release method of the --write-pgsql task. An object was being used that hadn't been initialised yet due to the database connection failure. I've added a null check which fixes the issue.

comment:2 Changed 8 years ago by brett@…

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.