From: <gv...@hy...> - 2008-09-02 18:08:21
|
Author: gviedma Date: 2008-09-02 11:08:13 -0700 (Tue, 02 Sep 2008) New Revision: 10940 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=10940 Modified: trunk/plugins/hqagent/src/org/hyperic/hq/plugin/hqagent/AgentServerDetector.java Log: HQ-1400: No-wrapper script fails with IndexOutOfBoundsException Modified: trunk/plugins/hqagent/src/org/hyperic/hq/plugin/hqagent/AgentServerDetector.java =================================================================== --- trunk/plugins/hqagent/src/org/hyperic/hq/plugin/hqagent/AgentServerDetector.java 2008-09-02 17:45:24 UTC (rev 10939) +++ trunk/plugins/hqagent/src/org/hyperic/hq/plugin/hqagent/AgentServerDetector.java 2008-09-02 18:08:13 UTC (rev 10940) @@ -26,6 +26,7 @@ package org.hyperic.hq.plugin.hqagent; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -46,7 +47,6 @@ private static final String UNAVAILABLE = "N/A"; private static final String AGENT_BUNDLE_HOME = "agent.bundle.home"; - private static final String BUNDLES_DIR = "bundles/"; public AgentServerDetector(){ super(); @@ -109,10 +109,12 @@ if (home == null) { return UNAVAILABLE; } - int index = home.indexOf(BUNDLES_DIR) + BUNDLES_DIR.length(); - if (index < 0) { + File bundleDir = new File(home); + try { + return bundleDir.getCanonicalFile().getName(); + } + catch (IOException e) { return UNAVAILABLE; } - return home.substring(index); } } |