Skip to content

[#2603] [#2604] Jakarta behavior alignment - #2606

Draft
mattrpav wants to merge 5 commits into
apache:mainfrom
mattrpav:amq-gh-2603-jakarta-exception-types
Draft

mattrpav wants to merge 5 commits into
apache:mainfrom
mattrpav:amq-gh-2603-jakarta-exception-types

Conversation

@mattrpav

Copy link
Copy Markdown
Contributor
  1. CreateConnection needs to throw immediately, and not on .start()
  2. ClientID cannot be set on Connection directly
  3. Throw JMSRuntimeException for invalid JMSContext session modes
  4. Map and Bytes message spec alignment
  5. Update the TCK job to use strict spec compliance and validate these fixes address specification scenarios.

…under strict compliance

Jakarta Messaging expects createConnection(user, password) to throw
JMSSecurityException and createContext to throw JMSSecurityRuntimeException
for bad credentials. ActiveMQ defers the ConnectionInfo exchange until first
use, so the failure surfaced only on start(). Under strictCompliance the
factory now validates the credentials at creation (TCK
createConnectionExceptionTests, createJMSContextExceptionTests); the default
keeps the lazy behavior.

The check uses a throwaway ConnectionInfo that is removed again immediately
rather than the connection's own, which would fix the client identifier and
make the spec-mandated createConnection() then setClientID() sequence fail
with "used connection".
…ID under strict compliance

A client identifier set on the connection factory is administratively
configured and the specification forbids the application from changing it
(IllegalStateException / IllegalStateRuntimeException). ActiveMQ always allowed
the override, so enforce only under strictCompliance (TCK
setClientIDOnAdminConfiguredIDTest).
Jakarta Messaging requires createContext to throw JMSRuntimeException for an
invalid session mode. Validate on every createContext entry point (factory
and child contexts) while keeping ActiveMQ's INDIVIDUAL_ACKNOWLEDGE
extension valid (TCK createJMSContextExceptionTests).
… write-only BytesMessage getBody

MapMessage.setObject routed values through the message-property validator,
which rejects Character under strictCompliance; char is a valid MapMessage
body type (setChar), so Character now bypasses that check like byte[] does
(TCK foreignMsg sendReceiveMapMsg tests).

BytesMessage.isBodyAssignableTo treated null content as no body, but bytes
written in write-only mode sit in bytesOut until stored, so getBody accepted
any type. Account for pending written bytes when deciding whether a body
exists (TCK getBodyExceptionTests).
…ing broker

The exception-type fixes are gated on strictCompliance, so the TCK
connection factories enable it.

The TCK expects invalid credentials to be rejected (JMSSecurityException
from createConnection, JMSSecurityRuntimeException from createContext).
The embedded broker authenticates the ts.jte user with
SimpleAuthenticationPlugin and keeps anonymous access for the many tests
that connect without credentials; activemq-jaas supplies the principals
the plugin needs inside the shaded runner.
@mattrpav mattrpav added this to the Jakarta 3.1/JMS 2.0 support milestone Sep 22, 2026
@mattrpav mattrpav self-assigned this Sep 22, 2026
@mattrpav mattrpav changed the title [#2603] Jakarta behavior alignment [#2603] [#2604] Jakarta behavior alignment Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant