Bug 848261 - rhq-script-plugin does not strip whitespace for availability check
rhq-script-plugin does not strip whitespace for availability check
Status: CLOSED DUPLICATE of bug 848258
Product: RHQ Project
Classification: Other
Component: Plugins (Show other bugs)
4.4
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-14 23:10 EDT by Elias Ross
Modified: 2012-08-20 16:35 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-08-20 16:35:01 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Elias Ross 2012-08-14 23:10:10 EDT
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 16:35:01 EDT

*** This bug has been marked as a duplicate of bug 848258 ***

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