Git Product home page Git Product logo

Comments (4)

xsc avatar xsc commented on September 2, 2024

This is a weird one. The field is marked as STRING (and it says in the docs that it "[...] is currently a specialized form of the string type [...]"), reading it produces a byte[] array but setting it needs a ByteBuffer. This is inconsistent to say the least...

I'll look into it.

from thrift-clj.

charlie-harvey avatar charlie-harvey commented on September 2, 2024

Anything ever come of this? I just ran into the same issue. Essentially, I cannot set anything as a binary field.

namespace java com.example
struct SomeMessage {
  1: binary body
}
service SomeService {
  1: sendMsg(1:SomeMessage m)
}
(thrift/import
  (:types [com.example SomeMessage])
  (:clients [com.example SomeService]))

(def msg
  (SomeMessage. (ByteBuffer/wrap (.getBytes "the body" "UTF-8"))))

Produces this:

Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.nio.ByteBuffer
    at com.example.SomeMessage.setFieldValue(SomeMessage.java:135)
    at ns_225746209.SomeMessage.to_thrift_STAR_(producer.clj:32)
    at thrift_clj.gen.core$__GT_thrift.invoke(core.clj:19)
    at ns404766290$sendMsg.invoke(producer.clj:32)

from thrift-clj.

xsc avatar xsc commented on September 2, 2024

@charlie-harvey There is 3fbcf1e (from #10), introducing handling of binary fields, with the caveat that there is no longer an automatic conversion to String for string fields. I just noticed that this has never been released - sorry for that.

Could you try out the latest SNAPSHOT? I'll then package a full release once I hear back from you.

[thrift-clj "0.3.0-SNAPSHOT"]

from thrift-clj.

charlie-harvey avatar charlie-harvey commented on September 2, 2024

Works!!

(with-open [c (thrift/connect! Clt "localhost:7007")]
  (Clt/sendAmqpMessage c
    (AmqpMessage. (ByteBuffer/wrap (.getBytes "hello foo")))))
struct AmqpMessage {
  1: binary body,
}

service AmqpForwardingService {
  bool sendAmqpMessage(1:AmqpMessage m)
}

Thanks so much for pushing that out. Huge help.

from thrift-clj.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.