Fix MfApi restart invoke by passing empty param arrays instead of null.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -15,7 +15,7 @@ import javax.management.ObjectName;
|
|||||||
public final class SonicMfContainerTool
|
public final class SonicMfContainerTool
|
||||||
{
|
{
|
||||||
public static final String TOOL_VERSION =
|
public static final String TOOL_VERSION =
|
||||||
"2026-07-29-validate-restart";
|
"2026-07-29-restart-empty-params";
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
@@ -251,21 +251,32 @@ public final class SonicMfContainerTool
|
|||||||
info("ObjectName=" + objectName);
|
info("ObjectName=" + objectName);
|
||||||
|
|
||||||
StringBuffer attempts = new StringBuffer();
|
StringBuffer attempts = new StringBuffer();
|
||||||
String[] operations = new String[]
|
|
||||||
|
// 1) restart (bevorzugt)
|
||||||
|
// 2) stop + start (Fallback; manche Agenten haben kein restart)
|
||||||
|
String[][] plans = new String[][]
|
||||||
{
|
{
|
||||||
"stop",
|
{ "restart" },
|
||||||
"restart"
|
{ "stop", "start" }
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int index = 0; index < operations.length; index++)
|
for (int planIndex = 0; planIndex < plans.length; planIndex++)
|
||||||
{
|
{
|
||||||
String operation = operations[index];
|
String[] operations = plans[planIndex];
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
info("Trying MBean.invoke(" + operation + ")");
|
for (int index = 0; index < operations.length; index++)
|
||||||
invokeNoArgs(connector, objectName, operation);
|
{
|
||||||
okRestart("MBean." + operation, shortName, domain);
|
String operation = operations[index];
|
||||||
|
info("Trying MBean.invoke(" + operation + ")");
|
||||||
|
invokeNoArgs(connector, objectName, operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
okRestart(
|
||||||
|
"MBean." + joinOps(operations),
|
||||||
|
shortName,
|
||||||
|
domain);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (Throwable throwable)
|
catch (Throwable throwable)
|
||||||
@@ -273,7 +284,7 @@ public final class SonicMfContainerTool
|
|||||||
Throwable root = rootOf(throwable);
|
Throwable root = rootOf(throwable);
|
||||||
String line =
|
String line =
|
||||||
"MBean."
|
"MBean."
|
||||||
+ operation
|
+ joinOps(operations)
|
||||||
+ " => "
|
+ " => "
|
||||||
+ root.getClass().getName()
|
+ root.getClass().getName()
|
||||||
+ ": "
|
+ ": "
|
||||||
@@ -288,6 +299,23 @@ public final class SonicMfContainerTool
|
|||||||
"Neustart fehlgeschlagen:\n" + attempts.toString());
|
"Neustart fehlgeschlagen:\n" + attempts.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String joinOps(String[] operations)
|
||||||
|
{
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
|
for (int index = 0; index < operations.length; index++)
|
||||||
|
{
|
||||||
|
if (index > 0)
|
||||||
|
{
|
||||||
|
buffer.append('+');
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.append(operations[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private static void invokeNoArgs(
|
private static void invokeNoArgs(
|
||||||
Object connector,
|
Object connector,
|
||||||
ObjectName objectName,
|
ObjectName objectName,
|
||||||
@@ -312,14 +340,18 @@ public final class SonicMfContainerTool
|
|||||||
"invoke(...) wurde nicht gefunden.");
|
"invoke(...) wurde nicht gefunden.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sonic JMSConnectorClient verlangt leere Arrays, nicht null.
|
||||||
|
Object[] params = new Object[0];
|
||||||
|
String[] signature = new String[0];
|
||||||
|
|
||||||
invokeMethod.invoke(
|
invokeMethod.invoke(
|
||||||
connector,
|
connector,
|
||||||
new Object[]
|
new Object[]
|
||||||
{
|
{
|
||||||
objectName,
|
objectName,
|
||||||
operation,
|
operation,
|
||||||
null,
|
params,
|
||||||
null
|
signature
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user