[jira] [Assigned] (THRIFT-4659) golang race detected when closing listener socket
[ https://issues.apache.org/jira/browse/THRIFT-4659?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Can Celasun reassigned THRIFT-4659: --- Assignee: Can Celasun > golang race detected when closing listener socket > - > > Key: THRIFT-4659 > URL: https://issues.apache.org/jira/browse/THRIFT-4659 > Project: Thrift > Issue Type: Bug > Components: Go - Library >Affects Versions: 0.11.0 >Reporter: Jay Gheewala >Assignee: Can Celasun >Priority: Major > > Race condition is deteced for following write/read > > git.apache.org/thrift.git/lib/go/thrift/server_socket.go:119 > git.apache.org/thrift.git/lib/go/thrift.(*TServerSocket).Close() > git.apache.org/thrift.git/lib/go/thrift/server_socket.go:122 > git.apache.org/thrift.git/lib/go/thrift.(*TServerSocket).Interrupt() > > git.apache.org/thrift.git/lib/go/thrift.(*TServerSocket).Accept() > git.apache.org/thrift.git/lib/go/thrift/server_socket.go:78 > git.apache.org/thrift.git/lib/go/thrift.(*TSimpleServer).innerAccept() > git.apache.org/thrift.git/lib/go/thrift/simple_server.go:129 > git.apache.org/thrift.git/lib/go/thrift.(*TSimpleServer).AcceptLoop() -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4660) Include @javax.annotation.Generated and Nullable as needed for enums
[ https://issues.apache.org/jira/browse/THRIFT-4660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16676253#comment-16676253 ] ASF GitHub Bot commented on THRIFT-4660: dcelasun closed pull request #1621: THRIFT-4660: Include @javax.annotation.Generated and Nullable as needed for enums URL: https://github.com/apache/thrift/pull/1621 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc index 4780dc76cd..2c845512cc 100644 --- a/compiler/cpp/src/thrift/generate/t_java_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc @@ -498,6 +498,11 @@ void t_java_generator::generate_enum(t_enum* tenum) { f_enum << autogen_comment() << java_package() << endl; generate_java_doc(f_enum, tenum); + + if (!suppress_generated_annotations_) { +generate_javax_generated_annotation(f_enum); + } + if (is_deprecated) { indent(f_enum) << "@Deprecated" << endl; } @@ -544,6 +549,7 @@ void t_java_generator::generate_enum(t_enum* tenum) { << endl; indent(f_enum) << " * @return null if the value is not found." << endl; indent(f_enum) << " */" << endl; + indent(f_enum) << java_nullable_annotation() << endl; indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << endl; indent_up(); This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Include @javax.annotation.Generated and Nullable as needed for enums > > > Key: THRIFT-4660 > URL: https://issues.apache.org/jira/browse/THRIFT-4660 > Project: Thrift > Issue Type: New Feature > Components: Java - Compiler >Reporter: Lazaro Clapp >Priority: Minor > Fix For: 0.12.0 > > > This is a follow up to THRIFT-4530 and THRIFT-4614. In that patch, we > neglected to add Nullable and Generated annotations to enums, in addition to > classes. Will open PR with small change immediately after creating this task. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4660) Include @javax.annotation.Generated and Nullable as needed for enums
[ https://issues.apache.org/jira/browse/THRIFT-4660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16676072#comment-16676072 ] ASF GitHub Bot commented on THRIFT-4660: lazaroclapp commented on issue #1621: THRIFT-4660: Include @javax.annotation.Generated and Nullable as needed for enums URL: https://github.com/apache/thrift/pull/1621#issuecomment-436115862 cc: msridhar :) This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Include @javax.annotation.Generated and Nullable as needed for enums > > > Key: THRIFT-4660 > URL: https://issues.apache.org/jira/browse/THRIFT-4660 > Project: Thrift > Issue Type: New Feature > Components: Java - Compiler >Reporter: Lazaro Clapp >Priority: Minor > Fix For: 0.12.0 > > > This is a follow up to THRIFT-4530 and THRIFT-4614. In that patch, we > neglected to add Nullable and Generated annotations to enums, in addition to > classes. Will open PR with small change immediately after creating this task. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4660) Include @javax.annotation.Generated and Nullable as needed for enums
[ https://issues.apache.org/jira/browse/THRIFT-4660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16676073#comment-16676073 ] ASF GitHub Bot commented on THRIFT-4660: lazaroclapp edited a comment on issue #1621: THRIFT-4660: Include @javax.annotation.Generated and Nullable as needed for enums URL: https://github.com/apache/thrift/pull/1621#issuecomment-436115862 cc: @msridhar :) This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Include @javax.annotation.Generated and Nullable as needed for enums > > > Key: THRIFT-4660 > URL: https://issues.apache.org/jira/browse/THRIFT-4660 > Project: Thrift > Issue Type: New Feature > Components: Java - Compiler >Reporter: Lazaro Clapp >Priority: Minor > Fix For: 0.12.0 > > > This is a follow up to THRIFT-4530 and THRIFT-4614. In that patch, we > neglected to add Nullable and Generated annotations to enums, in addition to > classes. Will open PR with small change immediately after creating this task. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4660) Include @javax.annotation.Generated and Nullable as needed for enums
[ https://issues.apache.org/jira/browse/THRIFT-4660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16676071#comment-16676071 ] ASF GitHub Bot commented on THRIFT-4660: lazaroclapp opened a new pull request #1621: THRIFT-4660: Include @javax.annotation.Generated and Nullable as needed for enums URL: https://github.com/apache/thrift/pull/1621 Follow up to THRIFT-4530 and THRIFT-4614. In that patch, we neglected to add Nullable and Generated annotations to enums, in addition to classes. This PR fixes that. Client: Java compiler This is a straightforward, compile-time-safe, backward-compatible change. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Include @javax.annotation.Generated and Nullable as needed for enums > > > Key: THRIFT-4660 > URL: https://issues.apache.org/jira/browse/THRIFT-4660 > Project: Thrift > Issue Type: New Feature > Components: Java - Compiler >Reporter: Lazaro Clapp >Priority: Minor > Fix For: 0.12.0 > > > This is a follow up to THRIFT-4530 and THRIFT-4614. In that patch, we > neglected to add Nullable and Generated annotations to enums, in addition to > classes. Will open PR with small change immediately after creating this task. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (THRIFT-4660) Include @javax.annotation.Generated and Nullable as needed for enums
Lazaro Clapp created THRIFT-4660: Summary: Include @javax.annotation.Generated and Nullable as needed for enums Key: THRIFT-4660 URL: https://issues.apache.org/jira/browse/THRIFT-4660 Project: Thrift Issue Type: New Feature Components: Java - Compiler Reporter: Lazaro Clapp Fix For: 0.12.0 This is a follow up to THRIFT-4530 and THRIFT-4614. In that patch, we neglected to add Nullable and Generated annotations to enums, in addition to classes. Will open PR with small change immediately after creating this task. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4214) map key treated as hex value in JavaScript
[ https://issues.apache.org/jira/browse/THRIFT-4214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16676000#comment-16676000 ] ASF GitHub Bot commented on THRIFT-4214: jeking3 commented on issue #1519: THRIFT-4214: map key treated as hex value in JavaScript URL: https://github.com/apache/thrift/pull/1519#issuecomment-436105607 In Jira, the bug is marked as being in JavaScript (lib/js) and not in Node.JS (lib/nodejs), so which is it? :) This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > map key treated as hex value in JavaScript > - > > Key: THRIFT-4214 > URL: https://issues.apache.org/jira/browse/THRIFT-4214 > Project: Thrift > Issue Type: Bug > Components: JavaScript - Compiler, JavaScript - Library >Affects Versions: 0.10.0 >Reporter: Teodor Atroshenko >Priority: Critical > Labels: easyfix > > The service is defined with the following function: > {code:javascript} > map someFunctionName() > {code} > The --gen js:node code: > {code:javascript} > output.writeFieldBegin('success', Thrift.Type.MAP, 0); > output.writeMapBegin(Thrift.Type.I64, Thrift.Type.DOUBLE, > Thrift.objectLength(this.success)); > for (var kiter18 in this.success) > { > if (this.success.hasOwnProperty(kiter18)) > { > var viter19 = this.success[kiter18]; > output.writeI64(kiter18); > output.writeDouble(viter19); > } > } > output.writeMapEnd(); > output.writeFieldEnd(); > {code} > String {{kiter18}} is passed to {{output.writeI64}}. Only *TBinaryProtocol* > is affected by this. The function > [defenition|https://github.com/apache/thrift/blob/19baeefd8c38d62085891d7956349601f79448b3/lib/nodejs/lib/thrift/binary_protocol.js#L137]: > {code:javascript} > TBinaryProtocol.prototype.writeI64 = function(i64) { > if (i64.buffer) { > this.trans.write(i64.buffer); > } else { > this.trans.write(new Int64(i64).buffer); > } > }; > {code} > *Int64* > [constructor|https://github.com/broofa/node-int64/blob/master/Int64.js#L49] > accepts the following arguments: > * new Int64(buffer\[, offset=0]) - Existing Buffer with byte offset > * new Int64(Uint8Array\[, offset=0]) - Existing Uint8Array with a byte offset > * new Int64(string) - Hex string (throws if n is outside int64 > range) > * new Int64(number) - Number (throws if n is outside int64 range) > * new Int64(hi, lo) - Raw bits as two 32-bit values > What happens, is that JavaScript object keys are always Strings, so the > generated function passes the object key as-is (in String representation) and > *Int64* library assumes it's a hex string and converts it to a different > 64-bit integer. > For example {{"4398046511580"}} becomes {{\[Int64 value:1189123005158784 > octets:00 04 39 80 46 51 15 80]}} > This also happens when returning {{list}}, however in lists it can be > bypassed by calling {{Number()}} on all Array elements before passing it to > Thrift's {{result()}} function. > To solve this, the compiler can be adding {{Number()}} around everything that > is a decimal number that is passed to {{writeI64}}; and if {{writeI64}} will > never be called with an actual hex string, then js library can be updated to > include the {{Number()}} call around *Int64* constructor argument. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4214) map key treated as hex value in JavaScript
[ https://issues.apache.org/jira/browse/THRIFT-4214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16675922#comment-16675922 ] ASF GitHub Bot commented on THRIFT-4214: MateuszJeziorski edited a comment on issue #1519: THRIFT-4214: map key treated as hex value in JavaScript URL: https://github.com/apache/thrift/pull/1519#issuecomment-436087140 @thexeos you looked at wrong file, `readI64` is not defined on `binary` - https://github.com/apache/thrift/blob/master/lib/nodejs/lib/thrift/binary.js Also you are testing wrong object - `binary` instead of `binary_protocol` you modified This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > map key treated as hex value in JavaScript > - > > Key: THRIFT-4214 > URL: https://issues.apache.org/jira/browse/THRIFT-4214 > Project: Thrift > Issue Type: Bug > Components: JavaScript - Compiler, JavaScript - Library >Affects Versions: 0.10.0 >Reporter: Teodor Atroshenko >Priority: Critical > Labels: easyfix > > The service is defined with the following function: > {code:javascript} > map someFunctionName() > {code} > The --gen js:node code: > {code:javascript} > output.writeFieldBegin('success', Thrift.Type.MAP, 0); > output.writeMapBegin(Thrift.Type.I64, Thrift.Type.DOUBLE, > Thrift.objectLength(this.success)); > for (var kiter18 in this.success) > { > if (this.success.hasOwnProperty(kiter18)) > { > var viter19 = this.success[kiter18]; > output.writeI64(kiter18); > output.writeDouble(viter19); > } > } > output.writeMapEnd(); > output.writeFieldEnd(); > {code} > String {{kiter18}} is passed to {{output.writeI64}}. Only *TBinaryProtocol* > is affected by this. The function > [defenition|https://github.com/apache/thrift/blob/19baeefd8c38d62085891d7956349601f79448b3/lib/nodejs/lib/thrift/binary_protocol.js#L137]: > {code:javascript} > TBinaryProtocol.prototype.writeI64 = function(i64) { > if (i64.buffer) { > this.trans.write(i64.buffer); > } else { > this.trans.write(new Int64(i64).buffer); > } > }; > {code} > *Int64* > [constructor|https://github.com/broofa/node-int64/blob/master/Int64.js#L49] > accepts the following arguments: > * new Int64(buffer\[, offset=0]) - Existing Buffer with byte offset > * new Int64(Uint8Array\[, offset=0]) - Existing Uint8Array with a byte offset > * new Int64(string) - Hex string (throws if n is outside int64 > range) > * new Int64(number) - Number (throws if n is outside int64 range) > * new Int64(hi, lo) - Raw bits as two 32-bit values > What happens, is that JavaScript object keys are always Strings, so the > generated function passes the object key as-is (in String representation) and > *Int64* library assumes it's a hex string and converts it to a different > 64-bit integer. > For example {{"4398046511580"}} becomes {{\[Int64 value:1189123005158784 > octets:00 04 39 80 46 51 15 80]}} > This also happens when returning {{list}}, however in lists it can be > bypassed by calling {{Number()}} on all Array elements before passing it to > Thrift's {{result()}} function. > To solve this, the compiler can be adding {{Number()}} around everything that > is a decimal number that is passed to {{writeI64}}; and if {{writeI64}} will > never be called with an actual hex string, then js library can be updated to > include the {{Number()}} call around *Int64* constructor argument. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4214) map key treated as hex value in JavaScript
[ https://issues.apache.org/jira/browse/THRIFT-4214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16675921#comment-16675921 ] ASF GitHub Bot commented on THRIFT-4214: MateuszJeziorski commented on issue #1519: THRIFT-4214: map key treated as hex value in JavaScript URL: https://github.com/apache/thrift/pull/1519#issuecomment-436087140 @thexeos you looked at wrong file, `readI64` is not defined on `binary` - https://github.com/apache/thrift/blob/master/lib/nodejs/lib/thrift/binary.js This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > map key treated as hex value in JavaScript > - > > Key: THRIFT-4214 > URL: https://issues.apache.org/jira/browse/THRIFT-4214 > Project: Thrift > Issue Type: Bug > Components: JavaScript - Compiler, JavaScript - Library >Affects Versions: 0.10.0 >Reporter: Teodor Atroshenko >Priority: Critical > Labels: easyfix > > The service is defined with the following function: > {code:javascript} > map someFunctionName() > {code} > The --gen js:node code: > {code:javascript} > output.writeFieldBegin('success', Thrift.Type.MAP, 0); > output.writeMapBegin(Thrift.Type.I64, Thrift.Type.DOUBLE, > Thrift.objectLength(this.success)); > for (var kiter18 in this.success) > { > if (this.success.hasOwnProperty(kiter18)) > { > var viter19 = this.success[kiter18]; > output.writeI64(kiter18); > output.writeDouble(viter19); > } > } > output.writeMapEnd(); > output.writeFieldEnd(); > {code} > String {{kiter18}} is passed to {{output.writeI64}}. Only *TBinaryProtocol* > is affected by this. The function > [defenition|https://github.com/apache/thrift/blob/19baeefd8c38d62085891d7956349601f79448b3/lib/nodejs/lib/thrift/binary_protocol.js#L137]: > {code:javascript} > TBinaryProtocol.prototype.writeI64 = function(i64) { > if (i64.buffer) { > this.trans.write(i64.buffer); > } else { > this.trans.write(new Int64(i64).buffer); > } > }; > {code} > *Int64* > [constructor|https://github.com/broofa/node-int64/blob/master/Int64.js#L49] > accepts the following arguments: > * new Int64(buffer\[, offset=0]) - Existing Buffer with byte offset > * new Int64(Uint8Array\[, offset=0]) - Existing Uint8Array with a byte offset > * new Int64(string) - Hex string (throws if n is outside int64 > range) > * new Int64(number) - Number (throws if n is outside int64 range) > * new Int64(hi, lo) - Raw bits as two 32-bit values > What happens, is that JavaScript object keys are always Strings, so the > generated function passes the object key as-is (in String representation) and > *Int64* library assumes it's a hex string and converts it to a different > 64-bit integer. > For example {{"4398046511580"}} becomes {{\[Int64 value:1189123005158784 > octets:00 04 39 80 46 51 15 80]}} > This also happens when returning {{list}}, however in lists it can be > bypassed by calling {{Number()}} on all Array elements before passing it to > Thrift's {{result()}} function. > To solve this, the compiler can be adding {{Number()}} around everything that > is a decimal number that is passed to {{writeI64}}; and if {{writeI64}} will > never be called with an actual hex string, then js library can be updated to > include the {{Number()}} call around *Int64* constructor argument. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (THRIFT-4659) golang race detected when closing listener socket
Jay Gheewala created THRIFT-4659: Summary: golang race detected when closing listener socket Key: THRIFT-4659 URL: https://issues.apache.org/jira/browse/THRIFT-4659 Project: Thrift Issue Type: Bug Components: Go - Library Affects Versions: 0.11.0 Reporter: Jay Gheewala Race condition is deteced for following write/read git.apache.org/thrift.git/lib/go/thrift/server_socket.go:119 git.apache.org/thrift.git/lib/go/thrift.(*TServerSocket).Close() git.apache.org/thrift.git/lib/go/thrift/server_socket.go:122 git.apache.org/thrift.git/lib/go/thrift.(*TServerSocket).Interrupt() git.apache.org/thrift.git/lib/go/thrift.(*TServerSocket).Accept() git.apache.org/thrift.git/lib/go/thrift/server_socket.go:78 git.apache.org/thrift.git/lib/go/thrift.(*TSimpleServer).innerAccept() git.apache.org/thrift.git/lib/go/thrift/simple_server.go:129 git.apache.org/thrift.git/lib/go/thrift.(*TSimpleServer).AcceptLoop() -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false
[ https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16675108#comment-16675108 ] Allen George commented on THRIFT-4658: -- I changed the "Fix Version/s" to 0.12.0. I'll also create a separate PR for master. > Rust's TBinaryInputProtocol fails when strict is false > -- > > Key: THRIFT-4658 > URL: https://issues.apache.org/jira/browse/THRIFT-4658 > Project: Thrift > Issue Type: Bug > Components: Rust - Library >Affects Versions: 0.11.0 > Environment: > `rustup show` output: > Default host: x86_64-apple-darwin > installed toolchains > > stable-x86_64-apple-darwin > nightly-x86_64-apple-darwin > active toolchain > > stable-x86_64-apple-darwin (default) > rustc 1.30.0 (da5f414c2 2018-10-24) >Reporter: J W >Assignee: Allen George >Priority: Major > Fix For: 0.12.0 > > > When use `TBinaryInputProtocol::new(..., false)`, any trivial example will > fail: > service TestService { > bool Test() > } > > Problem is here: > [https://github.com/apache/thrift/blob/master/lib/rs/src/protocol/binary.rs#L126] > with_capacity() allocates space, but len() of resulting Vec<> is 0. > read_exact() reads 0 bytes and read_byte() below receives first byte of the > string which may or may not convert to TMessageType. > Change it to: > let mut name_buf: Vec = vec![0; name_size]; > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false
[ https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen George updated THRIFT-4658: - Fix Version/s: (was: 1.0) 0.12.0 > Rust's TBinaryInputProtocol fails when strict is false > -- > > Key: THRIFT-4658 > URL: https://issues.apache.org/jira/browse/THRIFT-4658 > Project: Thrift > Issue Type: Bug > Components: Rust - Library >Affects Versions: 0.11.0 > Environment: > `rustup show` output: > Default host: x86_64-apple-darwin > installed toolchains > > stable-x86_64-apple-darwin > nightly-x86_64-apple-darwin > active toolchain > > stable-x86_64-apple-darwin (default) > rustc 1.30.0 (da5f414c2 2018-10-24) >Reporter: J W >Assignee: Allen George >Priority: Major > Fix For: 0.12.0 > > > When use `TBinaryInputProtocol::new(..., false)`, any trivial example will > fail: > service TestService { > bool Test() > } > > Problem is here: > [https://github.com/apache/thrift/blob/master/lib/rs/src/protocol/binary.rs#L126] > with_capacity() allocates space, but len() of resulting Vec<> is 0. > read_exact() reads 0 bytes and read_byte() below receives first byte of the > string which may or may not convert to TMessageType. > Change it to: > let mut name_buf: Vec = vec![0; name_size]; > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Resolved] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false
[ https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] James E. King III resolved THRIFT-4658. --- Resolution: Fixed Fix Version/s: 1.0 If this gets pulled into the 0.12.0 build branch someone will need to change the "Fix Version/s". > Rust's TBinaryInputProtocol fails when strict is false > -- > > Key: THRIFT-4658 > URL: https://issues.apache.org/jira/browse/THRIFT-4658 > Project: Thrift > Issue Type: Bug > Components: Rust - Library >Affects Versions: 0.11.0 > Environment: > `rustup show` output: > Default host: x86_64-apple-darwin > installed toolchains > > stable-x86_64-apple-darwin > nightly-x86_64-apple-darwin > active toolchain > > stable-x86_64-apple-darwin (default) > rustc 1.30.0 (da5f414c2 2018-10-24) >Reporter: J W >Assignee: Allen George >Priority: Major > Fix For: 1.0 > > > When use `TBinaryInputProtocol::new(..., false)`, any trivial example will > fail: > service TestService { > bool Test() > } > > Problem is here: > [https://github.com/apache/thrift/blob/master/lib/rs/src/protocol/binary.rs#L126] > with_capacity() allocates space, but len() of resulting Vec<> is 0. > read_exact() reads 0 bytes and read_byte() below receives first byte of the > string which may or may not convert to TMessageType. > Change it to: > let mut name_buf: Vec = vec![0; name_size]; > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false
[ https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16675104#comment-16675104 ] ASF GitHub Bot commented on THRIFT-4658: jeking3 closed pull request #1620: THRIFT-4658: TBinaryInputProtocol fails when strict is false URL: https://github.com/apache/thrift/pull/1620 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/lib/rs/src/protocol/binary.rs b/lib/rs/src/protocol/binary.rs index 8505b63344..42c6c97511 100644 --- a/lib/rs/src/protocol/binary.rs +++ b/lib/rs/src/protocol/binary.rs @@ -123,7 +123,7 @@ where // is the message name. strings (byte arrays) are length-prefixed, // so we've just read the length in the first 4 bytes let name_size = BigEndian::read_i32(_bytes) as usize; -let mut name_buf: Vec = Vec::with_capacity(name_size); +let mut name_buf: Vec = vec![0; name_size]; self.transport.read_exact( name_buf)?; let name = String::from_utf8(name_buf)?; @@ -544,8 +544,8 @@ mod tests { use super::*; #[test] -fn must_write_message_call_begin() { -let (_, mut o_prot) = test_objects(); +fn must_write_strict_message_call_begin() { +let (_, mut o_prot) = test_objects(true); let ident = TMessageIdentifier::new("test", TMessageType::Call, 1); assert!(o_prot.write_message_begin().is_ok()); @@ -573,8 +573,34 @@ mod tests { } #[test] -fn must_write_message_reply_begin() { -let (_, mut o_prot) = test_objects(); +fn must_write_non_strict_message_call_begin() { +let (_, mut o_prot) = test_objects(false); + +let ident = TMessageIdentifier::new("test", TMessageType::Call, 1); +assert!(o_prot.write_message_begin().is_ok()); + +let expected: [u8; 13] = [ +0x00, +0x00, +0x00, +0x04, +0x74, +0x65, +0x73, +0x74, +0x01, +0x00, +0x00, +0x00, +0x01, +]; + +assert_eq_written_bytes!(o_prot, expected); +} + +#[test] +fn must_write_strict_message_reply_begin() { +let (_, mut o_prot) = test_objects(true); let ident = TMessageIdentifier::new("test", TMessageType::Reply, 10); assert!(o_prot.write_message_begin().is_ok()); @@ -601,9 +627,48 @@ mod tests { assert_eq_written_bytes!(o_prot, expected); } +#[test] +fn must_write_non_strict_message_reply_begin() { +let (_, mut o_prot) = test_objects(false); + +let ident = TMessageIdentifier::new("test", TMessageType::Reply, 10); +assert!(o_prot.write_message_begin().is_ok()); + +let expected: [u8; 13] = [ +0x00, +0x00, +0x00, +0x04, +0x74, +0x65, +0x73, +0x74, +0x02, +0x00, +0x00, +0x00, +0x0A, +]; + +assert_eq_written_bytes!(o_prot, expected); +} + #[test] fn must_round_trip_strict_message_begin() { -let (mut i_prot, mut o_prot) = test_objects(); +let (mut i_prot, mut o_prot) = test_objects(true); + +let sent_ident = TMessageIdentifier::new("test", TMessageType::Call, 1); +assert!(o_prot.write_message_begin(_ident).is_ok()); + +copy_write_buffer_to_read_buffer!(o_prot); + +let received_ident = assert_success!(i_prot.read_message_begin()); +assert_eq!(_ident, _ident); +} + +#[test] +fn must_round_trip_non_strict_message_begin() { +let (mut i_prot, mut o_prot) = test_objects(false); let sent_ident = TMessageIdentifier::new("test", TMessageType::Call, 1); assert!(o_prot.write_message_begin(_ident).is_ok()); @@ -616,22 +681,22 @@ mod tests { #[test] fn must_write_message_end() { -assert_no_write(|o| o.write_message_end()); +assert_no_write(|o| o.write_message_end(), true); } #[test] fn must_write_struct_begin() { -assert_no_write(|o| o.write_struct_begin(::new("foo"))); +assert_no_write(|o| o.write_struct_begin(::new("foo")), true); } #[test] fn must_write_struct_end() { -assert_no_write(|o| o.write_struct_end()); +assert_no_write(|o| o.write_struct_end(), true); } #[test] fn must_write_field_begin() { -let (_, mut o_prot) = test_objects(); +let (_, mut o_prot) = test_objects(true); assert!( o_prot @@ -645,7 +710,7
[jira] [Commented] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false
[ https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16675062#comment-16675062 ] ASF GitHub Bot commented on THRIFT-4658: allengeorge commented on issue #1620: THRIFT-4658: TBinaryInputProtocol fails when strict is false URL: https://github.com/apache/thrift/pull/1620#issuecomment-435856200 @jeking3 The rust changes seem OK. Not sure why one of the sub-builds failed. Would it be possible to kick off the sub-build again or merge the changes please? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Rust's TBinaryInputProtocol fails when strict is false > -- > > Key: THRIFT-4658 > URL: https://issues.apache.org/jira/browse/THRIFT-4658 > Project: Thrift > Issue Type: Bug > Components: Rust - Library >Affects Versions: 0.11.0 > Environment: > `rustup show` output: > Default host: x86_64-apple-darwin > installed toolchains > > stable-x86_64-apple-darwin > nightly-x86_64-apple-darwin > active toolchain > > stable-x86_64-apple-darwin (default) > rustc 1.30.0 (da5f414c2 2018-10-24) >Reporter: J W >Assignee: Allen George >Priority: Major > > When use `TBinaryInputProtocol::new(..., false)`, any trivial example will > fail: > service TestService { > bool Test() > } > > Problem is here: > [https://github.com/apache/thrift/blob/master/lib/rs/src/protocol/binary.rs#L126] > with_capacity() allocates space, but len() of resulting Vec<> is 0. > read_exact() reads 0 bytes and read_byte() below receives first byte of the > string which may or may not convert to TMessageType. > Change it to: > let mut name_buf: Vec = vec![0; name_size]; > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false
[ https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16675036#comment-16675036 ] ASF GitHub Bot commented on THRIFT-4658: allengeorge edited a comment on issue #1620: THRIFT-4658: TBinaryInputProtocol fails when strict is false URL: https://github.com/apache/thrift/pull/1620#issuecomment-435852206 [puzzled] There appears to be a failure in a sub-build, but it doesn't have to do with the PR. Not sure how I can kick off the build again? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Rust's TBinaryInputProtocol fails when strict is false > -- > > Key: THRIFT-4658 > URL: https://issues.apache.org/jira/browse/THRIFT-4658 > Project: Thrift > Issue Type: Bug > Components: Rust - Library >Affects Versions: 0.11.0 > Environment: > `rustup show` output: > Default host: x86_64-apple-darwin > installed toolchains > > stable-x86_64-apple-darwin > nightly-x86_64-apple-darwin > active toolchain > > stable-x86_64-apple-darwin (default) > rustc 1.30.0 (da5f414c2 2018-10-24) >Reporter: J W >Assignee: Allen George >Priority: Major > > When use `TBinaryInputProtocol::new(..., false)`, any trivial example will > fail: > service TestService { > bool Test() > } > > Problem is here: > [https://github.com/apache/thrift/blob/master/lib/rs/src/protocol/binary.rs#L126] > with_capacity() allocates space, but len() of resulting Vec<> is 0. > read_exact() reads 0 bytes and read_byte() below receives first byte of the > string which may or may not convert to TMessageType. > Change it to: > let mut name_buf: Vec = vec![0; name_size]; > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false
[ https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16675035#comment-16675035 ] ASF GitHub Bot commented on THRIFT-4658: allengeorge commented on issue #1620: THRIFT-4658: TBinaryInputProtocol fails when strict is false URL: https://github.com/apache/thrift/pull/1620#issuecomment-435852206 [puzzled] There appears to be a failure in a sub-build, but it doesn't have to do with the PR. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Rust's TBinaryInputProtocol fails when strict is false > -- > > Key: THRIFT-4658 > URL: https://issues.apache.org/jira/browse/THRIFT-4658 > Project: Thrift > Issue Type: Bug > Components: Rust - Library >Affects Versions: 0.11.0 > Environment: > `rustup show` output: > Default host: x86_64-apple-darwin > installed toolchains > > stable-x86_64-apple-darwin > nightly-x86_64-apple-darwin > active toolchain > > stable-x86_64-apple-darwin (default) > rustc 1.30.0 (da5f414c2 2018-10-24) >Reporter: J W >Assignee: Allen George >Priority: Major > > When use `TBinaryInputProtocol::new(..., false)`, any trivial example will > fail: > service TestService { > bool Test() > } > > Problem is here: > [https://github.com/apache/thrift/blob/master/lib/rs/src/protocol/binary.rs#L126] > with_capacity() allocates space, but len() of resulting Vec<> is 0. > read_exact() reads 0 bytes and read_byte() below receives first byte of the > string which may or may not convert to TMessageType. > Change it to: > let mut name_buf: Vec = vec![0; name_size]; > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)