Skip to content

Commit ae88581

Browse files
committed
integrate 15.1.1.0 cl 121345 --> 15.1.1.0 CE
[git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v15.1.1.0/": change = 122067]
1 parent 28d9a05 commit ae88581

4 files changed

Lines changed: 105 additions & 23 deletions

File tree

prj/coherence-core/src/main/java/com/tangosol/internal/management/resources/AbstractManagementResource.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import com.tangosol.internal.management.Converter;
2121
import com.tangosol.internal.management.EntityMBeanResponse;
2222
import com.tangosol.internal.management.MBeanResponse;
23+
24+
import com.tangosol.internal.net.management.DiagnosticCommandPolicy;
25+
2326
import com.tangosol.net.management.MapJsonBodyHandler;
2427
import com.tangosol.net.CacheFactory;
2528

@@ -1345,21 +1348,7 @@ protected Response response(EntityMBeanResponse responseEntity)
13451348
*/
13461349
protected static boolean isJfrDiagnosticCommand(String sCmd)
13471350
{
1348-
if (sCmd == null)
1349-
{
1350-
return false;
1351-
}
1352-
1353-
switch (sCmd)
1354-
{
1355-
case "jfrStart":
1356-
case "jfrStop":
1357-
case "jfrDump":
1358-
case "jfrCheck":
1359-
return true;
1360-
default:
1361-
return false;
1362-
}
1351+
return DiagnosticCommandPolicy.isRestOperationAllowed(sCmd);
13631352
}
13641353

13651354
/**
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at
5+
* https://oss.oracle.com/licenses/upl.
6+
*/
7+
package com.tangosol.internal.net.management;
8+
9+
/**
10+
* Policy for DiagnosticCommand operations exposed by Coherence management
11+
* surfaces.
12+
*
13+
* @author Aleks Seovic 2026.07.15
14+
* @since 26.04
15+
*/
16+
public final class DiagnosticCommandPolicy
17+
{
18+
/**
19+
* Return whether an operation is part of the documented management REST
20+
* JFR command set.
21+
*
22+
* @param sOperation the DiagnosticCommand operation name
23+
*
24+
* @return {@code true} if the REST management route may invoke the operation
25+
*/
26+
public static boolean isRestOperationAllowed(String sOperation)
27+
{
28+
if (sOperation == null)
29+
{
30+
return false;
31+
}
32+
33+
switch (sOperation)
34+
{
35+
case "jfrStart":
36+
case "jfrStop":
37+
case "jfrDump":
38+
case "jfrCheck":
39+
return true;
40+
default:
41+
return false;
42+
}
43+
}
44+
45+
/**
46+
* Return whether an operation is allowed through a wrapped JMX
47+
* DiagnosticCommand MBean.
48+
* <p>
49+
* Wrapped JMX retains {@code vmUnlockCommercialFeatures} for supported
50+
* pre-JDK-11 Oracle JFR workflows. The management REST route intentionally
51+
* does not expose that compatibility operation.
52+
*
53+
* @param sOperation the DiagnosticCommand operation name
54+
*
55+
* @return {@code true} if wrapped JMX may invoke the operation
56+
*/
57+
public static boolean isWrappedJmxOperationAllowed(String sOperation)
58+
{
59+
return isRestOperationAllowed(sOperation) || UNLOCK_COMMERCIAL_FEATURES.equals(sOperation);
60+
}
61+
62+
// ----- constants ------------------------------------------------------
63+
64+
private static final String UNLOCK_COMMERCIAL_FEATURES = "vmUnlockCommercialFeatures";
65+
66+
private DiagnosticCommandPolicy()
67+
{
68+
}
69+
}

prj/coherence-core/src/main/java/com/tangosol/net/management/ManagementInvocationPolicy.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import com.oracle.coherence.common.base.Logger;
1010

11+
import com.tangosol.internal.net.management.DiagnosticCommandPolicy;
1112
import com.tangosol.internal.net.management.MBeanCollectorFunction;
1213
import com.tangosol.internal.util.CoherenceMode;
1314

@@ -291,7 +292,7 @@ public static void validateWrapperInvoke(MBeanServer server, ObjectName name, St
291292
validateIdentifier(sOperation, "wrapper-jmx", "operation", "invalid-operation");
292293
validateArguments(aoParam, asSignature, "wrapper-jmx");
293294

294-
if (isDiagnosticCommand(name) && ALLOWED_DIAGNOSTIC_OPERATIONS.contains(sOperation))
295+
if (isDiagnosticCommand(name) && DiagnosticCommandPolicy.isWrappedJmxOperationAllowed(sOperation))
295296
{
296297
validateOperationDescriptor(server, name, sOperation, asSignature, "wrapper-jmx");
297298
return;
@@ -589,6 +590,10 @@ private static ObjectName validateReadObjectName(ObjectName name, String sScope)
589590

590591
private static ObjectName validateQueryObjectName(ObjectName name, String sScope)
591592
{
593+
// Query patterns remain broad for inventory compatibility. Every
594+
// matched name must be passed through validateQueryResult(),
595+
// validateReadQueryResult(), or equivalent concrete-name validation
596+
// before it is used as an MBeanServer target.
592597
if (name == null)
593598
{
594599
return null;
@@ -1158,13 +1163,6 @@ private static String sanitize(String sValue)
11581163
MBeanAccessor.Invoke.class,
11591164
MBeanCollectorFunction.class));
11601165

1161-
private static final Set<String> ALLOWED_DIAGNOSTIC_OPERATIONS = new HashSet<>(Arrays.asList(
1162-
"jfrStart",
1163-
"jfrDump",
1164-
"jfrCheck",
1165-
"jfrStop",
1166-
"vmUnlockCommercialFeatures"));
1167-
11681166
private static final int REMOTE_MODEL_OP_GET = 1;
11691167

11701168
private static final int REMOTE_MODEL_OP_INVOKE = 2;

prj/test/unit/coherence-core-tests/src/test/java/com/tangosol/net/management/ManagementInvocationPolicyTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package com.tangosol.net.management;
88

9+
import com.tangosol.internal.net.management.DiagnosticCommandPolicy;
910
import com.tangosol.internal.net.management.MBeanCollectorFunction;
1011

1112
import com.tangosol.util.Filter;
@@ -36,6 +37,8 @@
3637
import javax.management.StandardMBean;
3738

3839
import static org.junit.Assert.assertEquals;
40+
import static org.junit.Assert.assertFalse;
41+
import static org.junit.Assert.assertTrue;
3942
import static org.junit.Assert.fail;
4043

4144
/**
@@ -224,6 +227,29 @@ public void shouldValidateAttributeAndOperationDescriptors()
224227
null, null, "test"));
225228
}
226229

230+
@Test
231+
public void shouldPreserveIntentionalDiagnosticCommandSurfaceRelationship()
232+
{
233+
String[] asJfrOperation = {"jfrStart", "jfrStop", "jfrDump", "jfrCheck"};
234+
for (String sOperation : asJfrOperation)
235+
{
236+
assertTrue(DiagnosticCommandPolicy.isRestOperationAllowed(sOperation));
237+
assertTrue(DiagnosticCommandPolicy.isWrappedJmxOperationAllowed(sOperation));
238+
}
239+
240+
assertFalse(DiagnosticCommandPolicy.isRestOperationAllowed("vmUnlockCommercialFeatures"));
241+
assertTrue(DiagnosticCommandPolicy.isWrappedJmxOperationAllowed("vmUnlockCommercialFeatures"));
242+
243+
for (String sOperation : new String[] {"vmSystemProperties", "jvmtiAgentLoad", "managementAgentStart"})
244+
{
245+
assertFalse(DiagnosticCommandPolicy.isRestOperationAllowed(sOperation));
246+
assertFalse(DiagnosticCommandPolicy.isWrappedJmxOperationAllowed(sOperation));
247+
}
248+
249+
assertFalse(DiagnosticCommandPolicy.isRestOperationAllowed(null));
250+
assertFalse(DiagnosticCommandPolicy.isWrappedJmxOperationAllowed(null));
251+
}
252+
227253
@Test
228254
public void shouldShadowNonWritableAttributeInCompatibilityMode()
229255
throws Exception

0 commit comments

Comments
 (0)