Regex Bug in Oracle/Database plugin (4.3.0-SNAPSHOT)
Elias Ross
genman at noderunner.net
Tue Nov 1 22:12:14 UTC 2011
This is on Java 6, which I suppose treats \\{xxx\\} as special.
2011-11-01 22:01:28,098 WARN [InventoryManager.discovery-1]
(rhq.core.pc.inventory.InventoryManager)- Failure during discovery for
[Oracle User] Resources - failed after 7 ms.
java.lang.Exception: Discovery component invocation failed.
at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:285)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalArgumentException: Illegal group reference
at java.util.regex.Matcher.appendReplacement(Matcher.java:713)
at java.util.regex.Matcher.replaceAll(Matcher.java:813)
at java.lang.String.replaceAll(String.java:2189)
at org.rhq.plugins.database.CustomTableRowDiscoveryComponent.formatMessage(CustomTableRowDiscoveryComponent.java:100)
at org.rhq.plugins.database.CustomTableRowDiscoveryComponent.discoverResources(CustomTableRowDiscoveryComponent.java:70)
at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:281)
... 5 more
The code in question:
<service name="Oracle User"
discovery="org.rhq.plugins.database.CustomTableRowDiscoveryComponent"
class="org.rhq.plugins.oracle.OracleUserComponent">
<plugin-configuration>
<c:simple-property name="table" default="DBA_USERS"/>
<c:simple-property name="metricQuery" default="SELECT *
FROM DBA_USERS"/>
<c:simple-property name="keyColumn" default="username"/>
<c:simple-property name="name" default="{key}"/>
<c:simple-property name="description" default="Oracle User"/>
</plugin-configuration>
<metric property="activeConnections" displayName="Active
Connections" displayType="summary"/>
</service>
/**
* Format a message with {<key>} formatted replacement keys.
*
* @param message the message to format
*
* @return the formatted text with variables replaced
*/
public static String formatMessage(String message, String key) {
message = message.replaceAll("\\{key\\}", key);
return message;
}
I think the code should be:
public static String formatMessage(String message, String key) {
message = message.replaceAll("{key}", key);
return message;
}
More information about the rhq-devel
mailing list