aragozin/jvm-tools

Cant invoke an operation with comma in arguments

clohfink opened this issue · 5 comments

It will split on the comma and treats each as own argument, so if theres a jmx operation that takes a comma seperated string its impossible to use.

Could you provide more detail about MBean operation you are invoking and arguments you want to pass.

Argument is split on the comma only if target type in MBean operation is array. I've considered passing array of stings which may include comma to MBean operation to be a very rare case.

https://github.com/aragozin/jvm-tools/blob/master/sjk-core/src/main/java/org/gridkit/jvmtool/cmd/MxCmd.java#L136

Because the type is a List it will take the string argument and split it by ',' regardless of type. It cant tell if its a single String type or if its a object[]. In the case of a JMX operation that takes a single String thats comma seperated, it tries to pass it as an object[] of strings which cant be found:

https://github.com/aragozin/jvm-tools/blob/master/sjk-core/src/main/java/org/gridkit/jvmtool/MBeanHelper.java#L104

Could you bring specific example? What is your MBean method signature and what are you to pass via command line?

example:

-mc -b org.apache.cassandra.db:type=CompactionManager -op forceUserDefinedCompaction -a "keyspace-table-kb-22853-Data.db,keyspace-table-kb-21068-Data.db"

calling

https://github.com/apache/cassandra/blob/8b3a60b9a7dbefeecc06bace617279612ec7092d/src/java/org/apache/cassandra/db/compaction/CompactionManagerMBean.java#L44

I was able to reproduce problem. Issue was in default behavior of JCommandr which split vararg parameters on comma.
Fix would be available in next release.