Modify ↓
#22833 closed defect (fixed)
[Patch] Command line environment variables are overwritten by /etc/default/josm
| Reported by: | skyper | Owned by: | team |
|---|---|---|---|
| Priority: | normal | Milestone: | 23.03 |
| Component: | Ubuntu package | Version: | latest |
| Keywords: | template_report | Cc: | sebastic |
Description (last modified by )
What steps will reproduce the problem?
- Enter
JAVA_OPTS="-Xmx256m -Djosm.home=/tmp/josm" josmin the console.
What is the expected result?
JOSM starts with appropriate assigned memory and JOSM dirs plus all environment variables set in /etc/default/josm and /usr/bin/josm
What happens instead?
All environment variables are present but the assigned memory value is taken from /etc/default/josm.
Please provide any additional information below. Attach a screenshot if possible.
Changing the order of the argument and the variable in /etc/default/josm seems to do the trick, e.g. JAVA_OPTS="${JAVA_OPTS} -Xmx768m" to JAVA_OPTS="-Xmx768m ${JAVA_OPTS}".
Relative:URL: ^/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2023-03-21 14:21:54 +0100 (Tue, 21 Mar 2023) Revision:18698 Build-Date:2023-03-22 02:31:00 URL:https://josm.openstreetmap.de/svn/trunk Identification: JOSM/1.5 (18698 en) Linux Debian GNU/Linux 11 (bullseye) Memory Usage: 158 MB / 768 MB (41 MB allocated, but free) Java version: 17.0.6+10-Debian-1deb11u1, Debian, OpenJDK 64-Bit Server VM VM arguments: [--module-path=/usr/share/openjfx/lib, --add-modules=java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web, -Djosm.restart=true, -Djosm.dir.name=JOSM-latest, -Djava.net.useSystemProxies=true, -Djosm.home=<josm.pref>, --add-exports=java.base/sun.security.action=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED]
Attachments (0)
Change History (6)
comment:1 by , 3 years ago
| Cc: | added |
|---|
comment:3 by , 3 years ago
| Summary: | Command line arguments are overwritten by /etc/default/josm → [Patch] Command line environment variables are overwritten by /etc/default/josm |
|---|
comment:4 by , 3 years ago
| Description: | modified (diff) |
|---|
comment:6 by , 3 years ago
| Milestone: | → 23.03 |
|---|
Note:
See TracTickets
for help on using tickets.



JAVA_OPTSis an environment variable, not a commandline argument.Commandline arguments are passed after the
-jaroption using$@:$JAVACMD $JAVA_OPTS -jar "${JOSM_PATH}" "$@"By default none of the options in
/etc/default/josmare enabled:$ cat /etc/default/josm # Options to pass to java when starting JOSM. # Uncomment the JAVA_OPTS lines to enable their use by /usr/bin/josm # Increase usable memory #JAVA_OPTS="${JAVA_OPTS} -Xmx2048m" # Enable OpenGL pipeline (2D graphic accelerators) #JAVA_OPTS="${JAVA_OPTS} -Dsun.java2d.opengl=True"Using the environment variable works in this case:
Annoyingly
--status-reportdoesn't exit like--versionand--help.Setting the same option in
/etc/default/josmand the environment is conflicting:$ grep ^JAVA_OPTS /etc/default/josm JAVA_OPTS="${JAVA_OPTS} -Xmx2048m" $ JAVA_OPTS="-Xmx4096m" bash -x /usr/bin/josm --status-report [...] + '[' -f /etc/default/josm ']' + . /etc/default/josm ++ JAVA_OPTS='-Xmx4096m -Xmx2048m' + JAVA_OPTS='-Djosm.restart=true -Djava.net.useSystemProxies=true -Xmx4096m -Xmx2048m' [...] + /usr/lib/jvm/java-17-openjdk-amd64/bin/java --module-path /usr/share/openjfx/lib --add-modules java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web -Djosm.restart=true -Djava.net.useSystemProxies=true -Xmx4096m -Xmx2048m --add-exports=java.base/sun.security.action=ALL-UNNAMED --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED -jar /usr/share/josm/josm.jar --status-report Revision:18678 Is-Local-Build:false Build-Date:2023-03-03 06:09:07 Debian-Release:0.0.svn18678+dfsg-1~exp1 Build-Name:Debian Identification: JOSM/1.5 (18678 Debian en) Linux Debian GNU/Linux 12 (bookworm) Memory Usage: 248 MB / 2048 MB (228 MB allocated, but free) Java version: 17.0.6+10-Debian-1, Debian, OpenJDK 64-Bit Server VM [...] VM arguments: [--module-path=/usr/share/openjfx/lib, --add-modules=java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web, -Djosm.restart=true, -Djava.net.useSystemProxies=true, --add-exports=java.<user.name>e/sun.security.action=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED] Program arguments: [--status-report] [...]The last one is used as its value overwrites its predecessors.
I don't think this is a bug, either set the option in
/etc/default/josmor set on the commandline.A case can be made for prepending values to
JAVA_OPTSlike/usr/bin/josmto use the value set by the user instead of the one by the administrator.This patch could suffice:
diff --git a/native/linux/latest/etc/default/josm-latest b/native/linux/latest/etc/default/josm-latest index ba09c29fc..dbd556ab6 100644 --- a/native/linux/latest/etc/default/josm-latest +++ b/native/linux/latest/etc/default/josm-latest @@ -2,8 +2,8 @@ # Uncomment the JAVA_OPTS lines to enable their use by /usr/bin/josm-latest # Increase usable memory -#JAVA_OPTS="${JAVA_OPTS} -Xmx2048m" +#JAVA_OPTS="-Xmx2048m ${JAVA_OPTS}" # Enable OpenGL pipeline (2D graphic accelerators) -#JAVA_OPTS="${JAVA_OPTS} -Dsun.java2d.opengl=True" +#JAVA_OPTS="-Dsun.java2d.opengl=True ${JAVA_OPTS}" diff --git a/native/linux/tested/etc/default/josm b/native/linux/tested/etc/default/josm index 8cd8127f3..b646c4f3e 100644 --- a/native/linux/tested/etc/default/josm +++ b/native/linux/tested/etc/default/josm @@ -2,8 +2,8 @@ # Uncomment the JAVA_OPTS lines to enable their use by /usr/bin/josm # Increase usable memory -#JAVA_OPTS="${JAVA_OPTS} -Xmx2048m" +#JAVA_OPTS="-Xmx2048m ${JAVA_OPTS}" # Enable OpenGL pipeline (2D graphic accelerators) -#JAVA_OPTS="${JAVA_OPTS} -Dsun.java2d.opengl=True" +#JAVA_OPTS="-Dsun.java2d.opengl=True ${JAVA_OPTS}"