-
Notifications
You must be signed in to change notification settings - Fork 1
Split CBOR encoder to support Jackson 2 and 3 #134
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
base: axon-4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||
| /* | ||||||
| * Copyright (c) 2022-2024. AxonIQ B.V. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Any file that has been touched should have the copyright notice updated. |
||||||
| * | ||||||
| * Licensed 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 io.axoniq.console.framework.client.strategy | ||||||
|
|
||||||
| import io.netty.buffer.ByteBuf | ||||||
| import io.netty.buffer.ByteBufAllocator | ||||||
| import io.netty.buffer.CompositeByteBuf | ||||||
| import io.rsocket.Payload | ||||||
| import io.rsocket.metadata.WellKnownMimeType | ||||||
| import io.rsocket.util.DefaultPayload | ||||||
| import tools.jackson.databind.DeserializationFeature | ||||||
| import tools.jackson.dataformat.cbor.CBORMapper | ||||||
|
|
||||||
| class CborJackson3EncodingStrategy : RSocketPayloadEncodingStrategy { | ||||||
| private val mapper = CBORMapper.builder() | ||||||
| .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | ||||||
| .build() | ||||||
|
|
||||||
| override fun getMimeType(): WellKnownMimeType { | ||||||
| return WellKnownMimeType.APPLICATION_CBOR | ||||||
| } | ||||||
|
|
||||||
| override fun encode(payload: Any, metadata: ByteBuf?): Payload { | ||||||
| val payloadBuffer: CompositeByteBuf = ByteBufAllocator.DEFAULT.compositeBuffer() | ||||||
| payloadBuffer.writeBytes(mapper.writeValueAsBytes(payload)) | ||||||
| return DefaultPayload.create(payloadBuffer, metadata) | ||||||
| } | ||||||
|
|
||||||
| override fun <T> decode(payload: Payload, expectedType: Class<T>): T { | ||||||
| if (expectedType == String::class.java) { | ||||||
| return payload.dataUtf8 as T | ||||||
|
Check warning on line 45 in console-framework-client/src/main/java/io/axoniq/console/framework/client/strategy/CborJackson3EncodingStrategy.kt
|
||||||
| } | ||||||
|
|
||||||
| return mapper.readValue(payload.data.array(), expectedType) | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,8 +54,8 @@ | |
| <sonar.organization>axoniq</sonar.organization> | ||
| <sonar.host.url>https://sonarcloud.io</sonar.host.url> | ||
|
|
||
| <kotlin.version>1.9.25</kotlin.version> | ||
| <dokka.version>1.9.20</dokka.version> | ||
| <kotlin.version>2.2.20</kotlin.version> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't upgrade kotlin. This upgrades the stdlib, and causes any older kotlin version to be incompatible with the client. |
||
| <dokka.version>2.0.0</dokka.version> | ||
|
|
||
| <axon.version>4.6.7</axon.version> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'do nothing' comment is on like 359 instead of here