Bug 754199 - AS7 plugin: fix exception handling and remove all output to stdout or stderr
Summary: AS7 plugin: fix exception handling and remove all output to stdout or stderr
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugins
Version: 4.2
Hardware: All
OS: All
high
medium
Target Milestone: ---
: RHQ 4.3.0
Assignee: Libor Zoubek
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: as7-plugin jon30-sprint8
TreeView+ depends on / blocked
 
Reported: 2011-11-15 17:09 UTC by Ian Springer
Modified: 2015-11-02 00:42 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-08-31 10:15:50 UTC
Embargoed:


Attachments (Terms of Use)

Description Ian Springer 2011-11-15 17:09:04 UTC
The AS7 plugin contains 7 instances of:

        } catch (Exception e) {
            e.printStackTrace(); // TODO: Customise this generated block
        }

Plugins should never output to stdout or stderr, but should instead use a logger. Otherwise, when exceptions occur, users will get stack traces dumped into their agent command prompt (this just happened to me).

Also, any calls to System.out.println() or System.err.println() should be replaced with logging (I see a call to System.out.println() in JmsComponent).

Note, in discovery components, we should make sure to use the following format for exception handling to make sure an exception during discovery of one resource does not prevent discovery of other resources:

        Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
        List<ProcessScanResult> processes = discoveryContext.getAutoDiscoveredProcesses();
        for (ProcessScanResult process : processes) {
            try {
               // do discovery ...
               discoveredResources.add(detail);
            } catch (Exception e) {
               // log and continue on to next process
               log.error("Failed to discover AS instance for process " + process, e);
            }
        }

        return discoveredResources;

Comment 1 Heiko W. Rupp 2011-11-16 12:04:55 UTC
d5c745a in master

Comment 4 Heiko W. Rupp 2013-08-31 10:15:50 UTC
Bulk close of old bugs in VERIFIED state.


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