Bug 848258 - rhq-script-plugin does not strip whitespace for availability check
Summary: rhq-script-plugin does not strip whitespace for availability check
Keywords:
Status: ASSIGNED
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugins
Version: 4.4,4.5,4.6,4.7,4.8,4.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: John Mazzitelli
QA Contact:
URL:
Whiteboard:
: 848261 (view as bug list)
Depends On:
Blocks: 1005951
TreeView+ depends on / blocked
 
Reported: 2012-08-15 03:05 UTC by Elias Ross
Modified: 2022-03-31 04:27 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)

Description Elias Ross 2012-08-15 03:05:58 UTC
Description of problem:

Typically scripts include a line-ending character at the end of their output.

Therefore, ProcessExecutionResults.getCapturedOutput() used by the plugin will include line end characters.

However, the option 'availabilityOutputRegex' option makes no mention that:
1) The regex must match the entire output of the command, including line end characters
2) And constructs such as .* will not match the end of line characters. 

For example, if my command outputs 'foo\n' when run, the following will not work:

      <plugin-configuration>
        <c:simple-property name="executable" required="true" default="..." />
        <c:simple-property name="availabilityOutputRegex" default="foo" />
      </plugin-configuration>

Nor will:

        <c:simple-property name="availabilityOutputRegex" default="foo.*" />

A work around is to include (?s) at the beginning

        <c:simple-property name="availabilityOutputRegex" default="(?s)foo.*" />

Suggested solutions:

1) Trim the whitespace by default from the output. This could possibly break some
existing plugin users, but highly unlikely.
2) Include Pattern.DOTALL option by default.
3) Make some note that (?s) should be included if the output contains a line break.
4) Instead of using Pattern.matcher().matches() use Pattern.matcher().find() instead.

1 or 4 is probably the most intuitive solution. Whitespace is rarely important to consider.

And just a guess, I doubt this plugin was well tested or this feature used in any case.

Comment 1 Elias Ross 2012-08-20 20:35:01 UTC
*** Bug 848261 has been marked as a duplicate of this bug. ***

Comment 2 Heiko W. Rupp 2013-07-01 12:14:04 UTC
This may be related to Bug 837731

Comment 3 John Mazzitelli 2013-07-01 17:39:33 UTC
trim whitespace/newlines from start/end of output string prior to applying regex filters.

git commit to master 49fe82e

Comment 4 Larry O'Leary 2013-12-13 15:53:29 UTC
Setting back to ASSIGNED as the commit for this issue seems very bad as it changes the output of the script. This can result in failed matches if a valid or proper regular expression is used. 

Instead of trimming, we should use the correct matcher implementation as we are performing searches within output of a script that is most likely multi-line. This is the suggestion also mentioned in option 4) of comment 0.


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