Bug 1132224 - java-functions cannot handle spaces in flags/options
Summary: java-functions cannot handle spaces in flags/options
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: javapackages-tools
Version: 21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mikolaj Izdebski
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-20 23:29 UTC by Christopher Tubbs
Modified: 2014-12-15 13:12 UTC (History)
3 users (show)

Fixed In Version: 4.3.0-1
Clone Of:
Environment:
Last Closed: 2014-12-14 21:01:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Christopher Tubbs 2014-08-20 23:29:20 UTC
Description of problem:
set_flags and set_options in /usr/share/java-utils/java-functions cannot handle options with spaces.

Version-Release number of selected component (if applicable):
javapackages-tools-4.1.0-2.fc21.noarch (probably affects other versions as well)

How reproducible:
100%

Steps to Reproduce:
1. Create an application script (using %jpackage_script maybe)
2. Observe the generated script

Actual results:
There's a few issues.

First, the generated output for %jpackage_script assigns the variables BASE_FLAGS and BASE_OPTIONS as strings instead of arrays. (This probably also affects BASE_JARS, but the nature of that limits the likelihood that it will contain individual elements with spaces.)

Second, the $BASE_FLAGS and $BASE_OPTIONS are passed as arguments to set_flags and set_options functions, respectively, without passing as arrays.

Third, the set_flags and set_options functions themselves flatten their arguments to a string for use later when passing to the $JAVA_CMD.

Fourth, internal values of $OPTIONS and $FLAGS are passed to $JAVA_CMD as a string.

This is a big limitation, because some arguments may have spaces, such as "-XX:OnOutOfMemoryError=kill -9 %s", which does not seem to be capable of properly quoting/escaping to pass all the way through to the exec line.


Expected results:
The arguments should be carried as arrays throughout, so they can be properly passed to the $JAVA_CMD.

Example:
BASE_FLAGS=("%5") # (assuming %5 is the rpm argument)
set_flags "${BASE_FLAGS[@]}"
set_flags() {
  FLAGS=("$@")
}
exec $JAVA_CMD "${FLAGS[@]}" ...


Additional info:

When used with %jpackage_script, one cannot put spaces into arguments in the first place... unless one defines a macro. This is a limitation of rpm, but the macro is a reasonable workaround.

I could not find an upstream issue tracker or bug report.

Comment 1 Christopher Tubbs 2014-08-20 23:30:44 UTC
Correction: that -XX:OnOutOfMemoryError should have %p, not %s, but the use case holds.

Comment 2 Mikolaj Izdebski 2014-09-25 08:23:17 UTC
Reproduced:

$ . /usr/share/java-utils/java-functions 
$ set_flags 'foo bar' baz
$ echo $FLAGS
foo bar baz

(In reply to Christopher Tubbs from comment #0)
> I could not find an upstream issue tracker or bug report.

Javapackages-tools is developed by Fedora people and this Bugzilla is the best place for bug reports and RFEs. (Some doc is available in /usr/share/doc/javapackages-tools-doc/index.html, from javapackages-tools-doc).

Comment 3 Mikolaj Izdebski 2014-09-25 10:43:30 UTC
This should be fixed upstream in a3df333.
https://github.com/mizdebsk/javapackages/commit/a3df333

I didn't test this much yet. For testing you can use latest javapackages RPMs, which are available from Jenkins: http://jenkins.cloud.fedoraproject.org/job/javapackages-tools/ws/RPM/latest/

Comment 4 Mikolaj Izdebski 2014-12-14 20:11:39 UTC
Verified using upstream snapshot 4.3.0-0.152.git3a1f75c

$ . /usr/share/java-utils/java-functions 
$ set_flags 'foo bar' baz
$ echo $FLAGS
'foo bar' 'baz'

Comment 5 Mikolaj Izdebski 2014-12-14 20:49:21 UTC
Fixed in javapackages-tools-4.3.0-1

Comment 6 Mikolaj Izdebski 2014-12-14 21:01:20 UTC
I believe that this bug is fixed in javapackages-tools-4.3.0-1,
which is available in Fedora Rawhide, so I am closing this bug now.

The build containing the fix can be found at Koji:
http://koji.fedoraproject.org/koji/buildinfo?buildID=599231

This bug was fixed in the next release of Fedora, and is not planned
to be fixed in the release it was filed against.  If you want this bug
to be fixed in Fedora 21, please say so in a comment.
Otherwise you can update to the newer release of Fedora to get the fix.


Note You need to log in before you can comment on or make changes to this bug.