jeanouii commented on code in PR #1736:
URL: https://github.com/apache/activemq/pull/1736#discussion_r2920204579


##########
activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java:
##########
@@ -523,17 +525,26 @@ public void setProperties(Map<String, ?> properties) 
throws JMSException {
     }
 
     protected void checkValidObject(Object value) throws 
MessageFormatException {
-
-        boolean valid = value instanceof Boolean || value instanceof Byte || 
value instanceof Short || value instanceof Integer || value instanceof Long;
-        valid = valid || value instanceof Float || value instanceof Double || 
value instanceof Character || value instanceof String || value == null;
+        // Types allowed by the Jakarta Messaging Specification
+        boolean valid = value instanceof Boolean || value instanceof Byte || 
value instanceof Short ||
+                value instanceof Integer || value instanceof Long || value 
instanceof Float ||
+                value instanceof Double || value instanceof String || value == 
null;
 
         if (!valid) {
 
             ActiveMQConnection conn = getConnection();
+
+            // Jakarta 3.1 Compliance: If strictCompliance is enabled, only 
allow standard types.
+            // This acts as the "Master Switch" and overrides legacy behavior.
+            if (conn != null && conn.isStrictCompliance()) {
+                throw new MessageFormatException("Only objectified primitive 
objects and String types are allowed when strictCompliance is enabled but was: 
" + value + " type: " + value.getClass());
+            }
+
             // conn is null if we are in the broker rather than a JMS client
             if (conn == null || conn.isNestedMapAndListEnabled()) {
-                if (!(value instanceof Map || value instanceof List)) {
-                    throw new MessageFormatException("Only objectified 
primitive objects, String, Map and List types are allowed but was: " + value + 
" type: " + value.getClass());
+                // Standard rules: only primitives and Strings are allowed
+                if (!(value instanceof Map || value instanceof List || value 
instanceof Character)) {

Review Comment:
   I think now that you have the other flag, you can revert the Character part 
here, what do you think?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to