Bug 839080
Summary: | ProcessInfoQuery does not properly handle pidfile with line ending or whitespace | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Other] RHQ Project | Reporter: | Elias Ross <genman> | ||||||
Component: | Agent | Assignee: | Heiko W. Rupp <hrupp> | ||||||
Status: | CLOSED CURRENTRELEASE | QA Contact: | Mike Foley <mfoley> | ||||||
Severity: | unspecified | Docs Contact: | |||||||
Priority: | unspecified | ||||||||
Version: | 4.4 | CC: | hrupp, mazz | ||||||
Target Milestone: | --- | ||||||||
Target Release: | RHQ 4.5.0 | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||||
Doc Text: | Story Points: | --- | |||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2013-09-01 10:19:00 UTC | Type: | Bug | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Attachments: |
|
Description
Elias Ross
2012-07-10 21:18:24 UTC
Elias, you are referring to org.rhq.core.system.pquery.ProcessInfoQuery#getPidfileContents ? Heiko Yes, ProcessInfoQuery.java This is what I suggest: private String getPidfileContents(String pidfileName) { String contents; try { FileInputStream fis = new FileInputStream(pidfileName); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); try { contents = br.readLine(); if (contents == null) { throw new IOException("empty pid"); } } finally { fis.close(); } } catch (FileNotFoundException e) { log.trace("pid not found"); return ""; } catch (IOException e) { log.warn("unable to read pid file " + pidfileName, e); return ""; } return contents.trim(); } Master 4f7c64deab77 Created attachment 612646 [details]
fix and test for this issue
I know this has been mostly addressed already, although I think my fix also contains more logging and more testing. There's some other cleanup as well.
Created attachment 612649 [details]
fix rebased against master
i pushed elias' patch: git commit to master: 6887631b55d273e017257eea610dc5b0df8af1fa Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since. |