Modify

Opened 6 years ago

Closed 6 years ago

#15901 closed defect (fixed)

--load-preferences crashes on simple filename

Reported by: Hb--- Owned by: team
Priority: minor Milestone: 18.02
Component: Core Version:
Keywords: template_report Cc:

Description

Launching java -jar josm-latest.jar --load-preferences=url-to-xml.xml fails and gives a crash report dialog. Reason: A simple file name looks like a malformed URL and checking this has no error handler.

JOSM should not crash to a bug report but give an error message.

Loading the file worked with --load-preferences=file://\full\path\on\windows\url-to-xml.xml

URL:http://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2018-02-10 01:40:02 +0100 (Sat, 10 Feb 2018)
Build-Date:2018-02-10 02:33:49
Revision:13400
Relative:URL: ^/trunk

Identification: JOSM/1.5 (13400 en) Windows 7 64-Bit
OS Build number: Windows 7 Professional (7601)
Memory Usage: 256 MB / 3604 MB (238 MB allocated, but free)
Java version: 1.8.0_161-b12, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Screen: \Display0 1280x1024
Maximum Screen Size: 1280x1024
VM arguments: [-Duser.language=en]
Program arguments: [--load-preferences=url-to-xml.xml]

Last errors/warnings:
- E: Handled by bug report queue: java.net.MalformedURLException: no protocol: url-to-xml.xml


=== REPORTED CRASH DATA ===
MainApplication#mainJOSM:
 - file: josmuser.xml

BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: main (1)
java.net.MalformedURLException: no protocol: url-to-xml.xml
	at java.net.URL.<init>(Unknown Source)
	at java.net.URL.<init>(Unknown Source)
	at java.net.URL.<init>(Unknown Source)
	at org.openstreetmap.josm.gui.MainApplication.mainJOSM(MainApplication.java:957)
	at org.openstreetmap.josm.gui.MainApplication$2.processArguments(MainApplication.java:278)
	at org.openstreetmap.josm.gui.MainApplication.main(MainApplication.java:845)

Attachments (0)

Change History (10)

comment:1 by Don-vip, 6 years ago

Milestone: 18.02
Type: enhancementdefect

comment:2 by Don-vip, 6 years ago

Resolution: fixed
Status: newclosed

In 13402/josm:

fix #15901 - --load-preferences crashes on simple filename

comment:3 by Hb---, 6 years ago

Resolution: fixed
Status: closedreopened

The import java -Duser.language=en -jar josm-latest.jar --load-preferences=file://prefs.xmlstill fails and crashes somewhere else now. The content of prefs.xml is at the bottom of this comment.

#Terminal
2018-02-11 01:56:32.604 INFO: Log level is at INFO (INFO, 800)
2018-02-11 01:56:34.248 INFO: Reading preferences from file://prefs.xml
2018-02-11 01:56:36.648 SEVERE: Handled by bug report queue: java.net.UnknownHostException: prefs.xml
-skipped: Stack trace 
-skipped: Built

Identification: JOSM/1.5 (13400 de) Windows 7 64-Bit
OS Build number: Windows 7 Professional (7601)
Memory Usage: 267 MB / 3604 MB (241 MB allocated, but free)
Java version: 1.8.0_161-b12, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Screen: \Display0 1280x1024
Maximum Screen Size: 1280x1024
Program arguments: [--load-preferences=file://prefs.xml]

Last errors/warnings:
- E: Handled by bug report queue: java.net.UnknownHostException: prefs.xml


=== REPORTED CRASH DATA ===
MainApplication#mainJOSM:
 - file: file://prefs.xml

BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: main (1)
java.net.UnknownHostException: prefs.xml
	at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at sun.net.ftp.impl.FtpClient.doConnect(Unknown Source)
	at sun.net.ftp.impl.FtpClient.tryConnect(Unknown Source)
	at sun.net.ftp.impl.FtpClient.connect(Unknown Source)
	at sun.net.ftp.impl.FtpClient.connect(Unknown Source)
	at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Source)
	at java.net.URL.openStream(Unknown Source)
	at org.openstreetmap.josm.tools.Utils.openStream(Utils.java:1785)
	at org.openstreetmap.josm.gui.MainApplication.mainJOSM(MainApplication.java:957)
	at org.openstreetmap.josm.gui.MainApplication$2.processArguments(MainApplication.java:278)
	at org.openstreetmap.josm.gui.MainApplication.main(MainApplication.java:845)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<config>
<preferences operation="append">
<tag key="audio.menuinvisible" value="true" xmlns="http://josm.openstreetmap.de/preferences-1.0"/>
</preferences>
</config>

comment:4 by Don-vip, 6 years ago

Resolution: fixed
Status: reopenedclosed

Don't use file:// protocol, simply specify local path, and JOSM will take care about it.

comment:5 by bastiK, 6 years ago

file://prefs.xml is not a valid URI, file:/prefs.xml or file:///home/un/osm/prefs.xml should work.

in reply to:  3 ; comment:6 by Hb---, 6 years ago

Replying to myself in comment 3:

The import … =file://prefs.xmlstill fails

I failed to notice that checkin was r13402 and nightly r13400 is outdated for this issue. Sorry for bothering you.

For the archives:
In the example below pref.xml is in the same directory as the jarfile. Turns out that the protocol identifier is file: only.

java -jar josm-latest.jar --load-preferences…
…=file:pref.xml::

Both: success

…=file:/pref.xml::

Windows: java.io.FileNotFoundException: \pref.xml
Linux: java.io.FileNotFoundException: /pref.xml

…=file:./pref.xml::

Both: success

…=file:/absolute/path/pref.xml::

Both: success

…=file://absolute/path/pref.xml two slashes::

Both: java.net.UnknownHostException: absolute

…=file:///absolute/path/pref.xml three slashes

Both: success

…=file:////absolute/path/pref.xml four and more slashes::

Windows: java.io.FileNotFoundException: \\absolute\path\pref.xml (Der Netzwerkpfad wurde nicht gefunden = The network path was not found)
Linux: success

comment:7 by Don-vip, 6 years ago

In 13443/josm:

see #15901 - also catch InvalidPathException

in reply to:  6 comment:8 by floscher, 6 years ago

Replying to Hb---:

…=file:/absolute/path/pref.xml::

Both: success

This does not find the correct file (tested on Linux). It will treat the argument as a relative path to the current directory.
So JOSM will try to find the preferences file at file:/absolute/path/file:/absolute/path/pref.xml.

This variant with single slash is the way Java formats a URI via File.getURL().getURI(), so it should probably still be treated as absolute path, even if in theory there could be a relative path starting with file:/ pointing somewhere inside a file: directory.

comment:9 by floscher, 6 years ago

Resolution: fixed
Status: closedreopened

comment:10 by Don-vip, 6 years ago

Resolution: fixed
Status: reopenedclosed

In 13445/josm:

fix #15901 - allow file:/ URLs

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.