[jira] [Commented] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false

2018-11-05 Thread Allen George (JIRA)


[ 
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] [Commented] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false

2018-11-05 Thread ASF GitHub Bot (JIRA)


[ 
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

2018-11-05 Thread ASF GitHub Bot (JIRA)


[ 
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

2018-11-05 Thread ASF GitHub Bot (JIRA)


[ 
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

2018-11-05 Thread ASF GitHub Bot (JIRA)


[ 
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)


[jira] [Commented] (THRIFT-4658) Rust's TBinaryInputProtocol fails when strict is false

2018-11-04 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16674595#comment-16674595
 ] 

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-435734864
 
 
   Note:
   
   * Added unit tests
   * Ran cross-tests in docker


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

2018-11-04 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16674594#comment-16674594
 ] 

ASF GitHub Bot commented on THRIFT-4658:


allengeorge opened a new pull request #1620: THRIFT-4658: TBinaryInputProtocol 
fails when strict is false
URL: https://github.com/apache/thrift/pull/1620
 
 
   Client: rs


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

2018-11-04 Thread Allen George (JIRA)


[ 
https://issues.apache.org/jira/browse/THRIFT-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16674483#comment-16674483
 ] 

Allen George commented on THRIFT-4658:
--

Ah - dammit. Sorry about that :/ I'll get the fix into 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
>
> 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)