Skip to content

fix(amqp): read native timestamp application properties - #763

Open
noxlys wants to merge 2 commits into
cloudevents:mainfrom
noxlys:fix-amqp-native-timestamps
Open

noxlys wants to merge 2 commits into
cloudevents:mainfrom
noxlys:fix-amqp-native-timestamps

Conversation

@noxlys

@noxlys noxlys commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #762.

Native AMQP timestamps are decoded by Proton as java.util.Date. Calling Date.toString() produces a value such as Thu Jan 01 08:00:00 CST 1970, which the CloudEvents time parser rejects. Convert these values to canonical UTC timestamps with Time.writeTime(), retaining millisecond precision and leaving other values unchanged.

The AMQP binding §3.1.3.2 requires readers to handle native timestamp values as well as canonical strings. Six regression cases encode and decode real Proton messages for CloudEvents 0.3 and 1.0, covering the epoch, pre-epoch values, nonzero milliseconds, and a timestamp extension.

Validation on Temurin 21 / Maven wrapper:

  • Original implementation: all six new cases fail with CloudEventRWException; 18 existing factory cases pass.
  • Fixed implementation: ./mvnw -pl amqp -am verify -Dmaven.javadoc.skip=true passes all 140 tests (API 8, core 90, AMQP 42), with no failures or skips.
  • git diff --check passes.
  • The initial verify run was stopped during Javadoc generation; the final successful run explicitly skips Javadoc. Full-repository and live-broker integration tests were not run.

AI assistance was used for investigation, implementation, and validation.

Compatibility

This is a reader-side change. Canonical timestamp strings and other non-timestamp values keep their existing handling. The standard time attribute now accepts a native AMQP timestamp in addition to a string. If an extension is transmitted as a native timestamp, its string value is now RFC3339 UTC rather than Java’s locale-dependent Date.toString() output. Consumers that compared that previous extension string literally may need to update the comparison. The writer’s wire format is unchanged.

After synchronizing with main, all 24 Proton message factory tests passed.

@duglin

duglin commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

@yangjj-iso will this break existing users?

Convert Proton Date attributes to canonical UTC timestamps before reading
CloudEvents. Cover real AMQP encoding and decoding for both spec versions,
including timestamp extensions, the epoch, and millisecond precision.

Fixes cloudevents#762

Signed-off-by: redyyang <3202137046@qq.com>
The Proton message factory tests pass, including native and textual timestamp coverage.

This branch has not been deployed

No deployments
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.

AMQP reader rejects native timestamp application properties

2 participants