Title: Incorrect working in systems with constant msgpack types headers · Issue #870 · msgpack/msgpack-java · GitHub
Open Graph Title: Incorrect working in systems with constant msgpack types headers · Issue #870 · msgpack/msgpack-java
X Title: Incorrect working in systems with constant msgpack types headers · Issue #870 · msgpack/msgpack-java
Description: Problem description Let's imagine that I have a system that accepts only numbers encoded in UINT16. Using the API with automatic header selection, it is impossible to encode values from 0 to 2^8-1 in UINT16 because MessagePacker will off...
Open Graph Description: Problem description Let's imagine that I have a system that accepts only numbers encoded in UINT16. Using the API with automatic header selection, it is impossible to encode values from 0 to 2^8-1 ...
X Description: Problem description Let's imagine that I have a system that accepts only numbers encoded in UINT16. Using the API with automatic header selection, it is impossible to encode values from 0 to 2^...
Opengraph URL: https://github.com/msgpack/msgpack-java/issues/870
X: @github
Domain: redirect.github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect working in systems with constant msgpack types headers","articleBody":"## Problem description\n\nLet's imagine that I have a system that accepts only numbers encoded in `UINT16`. \n\nUsing the API with automatic header selection, it is impossible to encode values from `0` to `2^8-1` in `UINT16` because `MessagePacker` will offer the types `UINT8`, `INT8`, `NEGFIXINT`, `POSFIXINT`. This will happen until the number exceeds the ranges `UINT8`, `INT8`, `NEGFIXINT`, `POSFIXINT`.\n\n## Suggestions for API improvements for statically typed systems\n\nI suggest introducing an API in which the client can choose the type of encoded header.\nFor example: \n```java\n public MessagePacker packUINT(final short b, final MessageFormat type)\n throws IOException\n {\n switch (type) {\n case UINT8:\n writeByteAndByte(UINT8, (byte) b);\n break;\n case UINT16:\n writeByteAndShort(UINT16, b);\n break;\n case UINT32:\n writeByteAndInt(UINT32, b);\n break;\n case UINT64:\n writeByteAndLong(UINT64, b);\n break;\n default: \n throw new MessagePackException(\"Cannot convert '\" + type + \"' to UINT family types.\");\n }\n return this;\n }\n```\nHere, a method should be understood as a set of overloaded methods with `short`, `int`, `long`, `BigInteger` value arguments . Conversion based on narrowing casting\n\nA similar solution for `FLOAT32/64` types, `INT8,16,32,64` families.\nThe code has already been written, it remains to send a PR\n","author":{"url":"https://github.com/nickkkccc","@type":"Person","name":"nickkkccc"},"datePublished":"2025-01-27T20:11:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/870/msgpack-java/issues/870"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ad888631-e034-4f1f-12b5-d0ec12fd014b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A70A:917F8:16741B1:1DDA4AD:6A534EBF |
| html-safe-nonce | 41598cc3079882dbc18db3a9cc4bb029acff0dc7439cb12b59f55912c51447f1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzBBOjkxN0Y4OjE2NzQxQjE6MUREQTRBRDo2QTUzNEVCRiIsInZpc2l0b3JfaWQiOiIxNjMyMjUwOTU5MTE0NzUxNjc5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6a2ec924b7c4c214e6ba92401526cc7e19715afb4acad82e0d75fad4dbe6d452 |
| hovercard-subject-tag | issue:2813955555 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/msgpack/msgpack-java/870/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96c8468e2d273b8c39877dae9fedfc8b9ee770c8944e7b41907fb37d78f3a7e4/msgpack/msgpack-java/issues/870 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96c8468e2d273b8c39877dae9fedfc8b9ee770c8944e7b41907fb37d78f3a7e4/msgpack/msgpack-java/issues/870 |
| og:image:alt | Problem description Let's imagine that I have a system that accepts only numbers encoded in UINT16. Using the API with automatic header selection, it is impossible to encode values from 0 to 2^8-1 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nickkkccc |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/msgpack/msgpack-java git https://github.com/msgpack/msgpack-java.git |
| octolytics-dimension-user_id | 198264 |
| octolytics-dimension-user_login | msgpack |
| octolytics-dimension-repository_id | 1971346 |
| octolytics-dimension-repository_nwo | msgpack/msgpack-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1971346 |
| octolytics-dimension-repository_network_root_nwo | msgpack/msgpack-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width