Conversation
…to int (uint16) The prefix carried no information once the class name says it: `ContentFormat.CT_APPLICATION_JSON` stutters, `ContentFormat.APPLICATION_JSON` does not. Fix three long-standing defects in their names: CT_APPLICATION_LINK__FORMAT -> APPLICATION_LINK_FORMAT double underscore CT_APPLICATION_OCTET__STREAM -> APPLICATION_OCTET_STREAM double underscore CT_APPLICATION_CODE_* -> APPLICATION_COSE_* "CODE" is a typo for COSE Pure rename, no behaviour or type change. Content-Format is a uint16 in RFC 7252, but it was modelled as a signed short. Parsing did `setContentFormat((short) data.toLong())`, so any content format >= 32768 -- the whole upper half of the IANA registry, including the 65000+ experimental range -- was truncated to a negative number and re-serialized wrong. A round trip of 32768 produced 0. Retype content format to `int`/`Integer` across the constants, header options, builders and factories. The parser assigns the field directly rather than going through the setter, so a malformed peer sending a value outside the uint16 range cannot throw out of the deserializer. Fix the neighbouring types that cannot represent their domains either: the option-number constants (byte -> int, option numbers are uint), `DEFAULT_MAX_AGE` (short -> long, matching the `Long maxAge` field), `CoapConstants.MAX_RETRANSMIT` (Short -> int) and `LinkFormat` content type (Short -> Integer). Collapse the `setAccept(short)` / `setAccept(Integer)` overload trap into a single method. BREAKING CHANGE: `ContentFormat` constants have lost the `CT_` prefix, and the misspelled `CT_APPLICATION_CODE_*`, `CT_APPLICATION_LINK__FORMAT` and `CT_APPLICATION_OCTET__STREAM` names are corrected. Content format is `Integer`/`int` instead of `Short`/`short` across header options, builders and factories;
szysas
added this pull request to stack #159
September 24, 2026 11:52
szysas
marked this pull request as ready for review
September 24, 2026 12:06
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The prefix carried no information once the class name says it:
ContentFormat.CT_APPLICATION_JSONstutters,ContentFormat.APPLICATION_JSONdoes not.Fix three long-standing defects in their names:
CT_APPLICATION_LINK__FORMAT -> APPLICATION_LINK_FORMAT double underscore
CT_APPLICATION_OCTET__STREAM -> APPLICATION_OCTET_STREAM double underscore
CT_APPLICATION_CODE_* -> APPLICATION_COSE_* "CODE" is a typo for COSE
Pure rename, no behaviour or type change.
Content-Format is a uint16 in RFC 7252, but it was modelled as a signed short. Parsing did
setContentFormat((short) data.toLong()), so any content format >= 32768 -- the whole upper half of the IANA registry, including the 65000+ experimental range -- was truncated to a negative number and re-serialized wrong. A round trip of 32768 produced 0.Retype content format to
int/Integeracross the constants, header options, builders and factories. The parser assigns the field directly rather than going through the setter, so a malformed peer sending a value outside the uint16 range cannot throw out of the deserializer.Fix the neighbouring types that cannot represent their domains either: the option-number constants (byte -> int, option numbers are uint),
DEFAULT_MAX_AGE(short -> long, matching theLong maxAgefield),CoapConstants.MAX_RETRANSMIT(Short -> int) andLinkFormatcontent type (Short -> Integer). Collapse thesetAccept(short)/setAccept(Integer)overload trap into a single method.BREAKING CHANGE:
ContentFormatconstants have lost theCT_prefix, and the misspelledCT_APPLICATION_CODE_*,CT_APPLICATION_LINK__FORMATandCT_APPLICATION_OCTET__STREAMnames are corrected. Content format isInteger/intinstead ofShort/shortacross header options, builders and factories;