Skip to content

Commit a89bb0e

Browse files
committed
core: allow LongString in the x-rpc-path header
The RabbitMQ management client doesn't allow us to set the headers as bytes, so we should be more lenient as to the received data type. Signed-off-by: Younes Khoudli <younes.khoudli@epita.fr>
1 parent 12d51f2 commit a89bb0e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/src/main/java/fr/sncf/osrd/cli/WorkerCommand.kt

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ package fr.sncf.osrd.cli
22

33
import com.beust.jcommander.Parameter
44
import com.beust.jcommander.Parameters
5-
import com.rabbitmq.client.AMQP
6-
import com.rabbitmq.client.Channel
7-
import com.rabbitmq.client.ConnectionFactory
8-
import com.rabbitmq.client.DeliverCallback
5+
import com.rabbitmq.client.*
96
import fr.sncf.osrd.api.*
107
import fr.sncf.osrd.api.api_v2.conflicts.ConflictDetectionEndpointV2
118
import fr.sncf.osrd.api.api_v2.path_properties.PathPropEndpoint
@@ -154,7 +151,11 @@ class WorkerCommand : CliCommand {
154151
val correlationId = message.properties.correlationId
155152
val body = message.body
156153
val path =
157-
(message.properties.headers["x-rpc-path"] as ByteArray?)?.decodeToString()
154+
if (message.properties.headers["x-rpc-path"] is LongString) {
155+
message.properties.headers["x-rpc-path"].toString()
156+
} else {
157+
(message.properties.headers["x-rpc-path"] as? ByteArray?)?.decodeToString()
158+
}
158159
if (path == null) {
159160
logger.error("missing x-rpc-path header")
160161
channel.basicReject(message.envelope.deliveryTag, false)

0 commit comments

Comments
 (0)