-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix Jakarta 3.1 compliance for Character property types #1736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jeanouii
merged 7 commits into
apache:main
from
pradeep85841:fix/jakarta-31-property-compliance
Mar 12, 2026
+161
−3
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c319a09
Fixing Jakarta 3.1 TCK issue: Added strict check for Character type w…
pradeep85841 8850abc
Add missing ASF license header to test file
pradeep85841 e1b2deb
Set nestedMapAndListEnabled to false by default for Jakarta 3.1 compl…
pradeep85841 fa14a9c
Align default configuration and tests with Jakarta 3.1 compliance
pradeep85841 a03670c
Introduce strictCompliance master flag for Jakarta 3.1 alignment
pradeep85841 3770470
Add strictCompliance flag and preserve legacy validation logic
pradeep85841 6fdef5a
Decouple strictCompliance from legacy flags and isolate Character rej…
pradeep85841 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
activemq-unit-tests/src/test/java/org/apache/activemq/ActiveMQMessagePropertyTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.activemq; | ||
|
|
||
| import org.apache.activemq.broker.BrokerService; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| import jakarta.jms.Connection; | ||
| import jakarta.jms.Message; | ||
| import jakarta.jms.MessageFormatException; | ||
| import jakarta.jms.Session; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| import static org.apache.activemq.command.DataStructureTestSupport.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.fail; | ||
|
|
||
| public class ActiveMQMessagePropertyTest { | ||
|
|
||
| private BrokerService broker; | ||
| private String connectionUri; | ||
|
|
||
| @Before | ||
| public void setUp() throws Exception { | ||
| broker = new BrokerService(); | ||
| broker.setPersistent(false); | ||
| broker.setUseJmx(false); | ||
| broker.addConnector("vm://localhost"); | ||
| broker.start(); | ||
| broker.waitUntilStarted(); | ||
| connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString(); | ||
| } | ||
|
|
||
| @After | ||
| public void tearDown() throws Exception { | ||
| if (broker != null) { | ||
| broker.stop(); | ||
| broker.waitUntilStopped(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testStrictComplianceMasterSwitch() throws Exception { | ||
| ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost"); | ||
|
|
||
| // Turn on strict compliance | ||
| factory.setStrictCompliance(true); | ||
| // Explicitly turn on the legacy flag to prove strict mode overrides it | ||
| factory.setNestedMapAndListEnabled(true); | ||
|
|
||
| Connection connection = factory.createConnection(); | ||
| connection.start(); | ||
|
|
||
| Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); | ||
| Message message = session.createMessage(); | ||
|
|
||
| // Verify standard types work | ||
| message.setStringProperty("validString", "test"); // Should pass | ||
|
|
||
| // Verify Character is rejected | ||
| try { | ||
| message.setObjectProperty("invalidChar", 'A'); | ||
| fail("Should have rejected Character under strict compliance"); | ||
| } catch (MessageFormatException e) { | ||
| // Expected | ||
| } | ||
|
|
||
| // Verify Map is rejected (even though nestedMapAndListEnabled is true) | ||
| try { | ||
| Map<String, String> map = new HashMap<>(); | ||
| message.setObjectProperty("invalidMap", map); | ||
| fail("Should have rejected Map under strict compliance"); | ||
| } catch (MessageFormatException e) { | ||
| // Expected | ||
| } | ||
|
|
||
| connection.close(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLegacyModeStillAllowsCharacter() throws Exception { | ||
| ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri); | ||
|
|
||
| // Default is strictCompliance = false | ||
| try (Connection connection = factory.createConnection(); | ||
| Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) { | ||
|
|
||
| Message message = session.createMessage(); | ||
| message.setObjectProperty("charProp", 'A'); // Should pass | ||
| assertEquals('A', message.getObjectProperty("charProp")); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.