Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

NullPointerException in read-xml on DB connection error #3344

Closed
openstreetmap-trac opened this issue Jul 23, 2021 · 1 comment
Closed

NullPointerException in read-xml on DB connection error #3344

openstreetmap-trac opened this issue Jul 23, 2021 · 1 comment

Comments

@openstreetmap-trac
Copy link

Reporter: lonvia
[Submitted to the original trac issue database at 8.14pm, Saturday, 20th November 2010]

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)
@openstreetmap-trac
Copy link
Author

Author: brett[at]bretth.com
[Added to the original trac issue at 10.30pm, Wednesday, 1st December 2010]

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant