thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4476) Typecasting problem on list items
Date Wed, 14 Mar 2018 12:08:00 GMT

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

ASF GitHub Bot commented on THRIFT-4476:
----------------------------------------

Github user ozymaxx commented on the issue:

    https://github.com/apache/thrift/pull/1496
  
    The build on the `CYGWIN x86` (see https://ci.appveyor.com/project/ozymaxx/thrift/build/job/09xqx9b54efog55o
for more details) machine has broken. Here is the error that I got:
    ```
    3504CMake Error at lib/java/cmake_install.cmake:39 (file):
    3505  file INSTALL cannot find
    3506  "/cygdrive/c/projects/build/CYGWIN/x86/lib/java/build/docs/javadoc".
    3507Call Stack (most recent call first):
    3508  cmake_install.cmake:36 (include)
    ```
    
    Some of the Travis builds have timed out (more details at https://travis-ci.org/ozymaxx/thrift).
A build has also failed with the following error:
    ```
    Failed examples:
    
    rspec ./spec/server_spec.rb:103 # Server Thrift::ThreadPoolServer should
serve inside a thread
    rake aborted!
    /usr/bin/ruby2.3 -S rspec ./spec/base_protocol_spec.rb ./spec/base_transport_spec.rb ./spec/binary_protocol_accelerated_spec.rb
./spec/binary_protocol_spec.rb ./spec/bytes_spec.rb ./spec/client_spec.rb ./spec/compact_protocol_spec.rb
./spec/exception_spec.rb ./spec/flat_spec.rb ./spec/http_client_spec.rb ./spec/json_protocol_spec.rb
./spec/namespaced_spec.rb ./spec/nonblocking_server_spec.rb ./spec/processor_spec.rb ./spec/serializer_spec.rb
./spec/server_socket_spec.rb ./spec/server_spec.rb ./spec/socket_spec.rb ./spec/ssl_socket_spec.rb
./spec/struct_nested_containers_spec.rb ./spec/struct_spec.rb ./spec/thin_http_server_spec.rb
./spec/types_spec.rb ./spec/union_spec.rb ./spec/unix_socket_spec.rb --color --format d failed
    /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:156:in `run_task'
    /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:124:in `block (2
levels) in initialize'
    /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:122:in `block in
initialize'
    Tasks: TOP => default => gem => spec => realspec
    (See full trace by running task with --trace)
    Makefile:655: recipe for target 'check-local' failed
    make[3]: *** [check-local] Error 1
    make[3]: Leaving directory '/thrift/src/lib/rb'
    Makefile:515: recipe for target 'check-am' failed
    make[2]: *** [check-am] Error 2
    make[2]: Leaving directory '/thrift/src/lib/rb'
    Makefile:580: recipe for target 'check-recursive' failed
    make[1]: *** [check-recursive] Error 1
    make[1]: Leaving directory '/thrift/src/lib'
    Makefile:662: recipe for target 'check-recursive' failed
    make: *** [check-recursive] Error 1
    ```
    
    @jeking3 


> Typecasting problem on list items
> ---------------------------------
>
>                 Key: THRIFT-4476
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4476
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Compiler
>    Affects Versions: 0.11.0
>            Reporter: Ozan Can Altiok
>            Priority: Major
>
> I was trying to add the following into a thrift interface file.
> {{const list<double> timeCoefficients = [24, 60, 60, 1000, 1000, 1000]}}
> With the definition given above the {{.thrift}} file compiled properly. However, I noticed
that in Python, the items in {{timeCoefficients}} are considered to be integer although
the list has been defined to include items of {{double}} type. Then I modified the definition
as given below to make sure all the items are of type {{double}}. 
> {{const list<double> timeCoefficients = [24.0, 60.0, 60.0, 1000.0, 1000.0, 1000.0]}}
> After the change, I ran into the following error during compilation.
> {{[ERROR] .../TimeCoefficients.java:[402,48] error: no suitable method found for add(int)}}
>  {{[ERROR] method Collection.add(Double) is not applicable}}
>  {{[ERROR] (argument mismatch; int cannot be converted to Double)}}
>  {{[ERROR] method List.add(Double) is not applicable}}
>  {{[ERROR] (argument mismatch; int cannot be converted to Double)}}
> Next, I changed the line as follows and the compilation became successful.
> {{const list<double> timeCoefficients = [24.1, 60.1, 60.1, 1000.1, 1000.1, 1000.1]}}
> When I reviewed the generated Java source files, I discovered that
> {{const list<double> timeCoefficients = [24, 60, 60, 1000, 1000, 1000]}}
> compiles to
> {{public static final java.util.List<java.lang.Double> timeCoefficients = new java.util.ArrayList<java.lang.Double>();}}
> {{static {}}
> {{  timeCoefficients.add((double)24);}}
>  {{  timeCoefficients.add((double)60);}}
>  {{  timeCoefficients.add((double)60);}}
>  {{  timeCoefficients.add((double)1000);}}
>  {{  timeCoefficients.add((double)1000);}}
>  {{  timeCoefficients.add((double)1000);}}
> {{}}}
> whilst
> {{const list<double> timeCoefficients = [24.0, 60.0, 60.0, 1000.0, 1000.0, 1000.0]}}
> compiles to
> {{public static final java.util.List<java.lang.Double> timeCoefficients = new java.util.ArrayList<java.lang.Double>();}}
> {{static {}}
> {{  timeCoefficients.add(24);}}
> {{  timeCoefficients.add(60);}}
> {{  timeCoefficients.add(60);}}
> {{  timeCoefficients.add(1000);}}
> {{  timeCoefficients.add(1000);}}
> {{  timeCoefficients.add(1000);}}
> {{}}}
> which leads to an error.
> When I modified this line as follows
> {{const list<double> timeCoefficients = [24.1, 60.1, 60.1, 1000.1, 1000.1, 1000.1]}}
> this line compiled to
> {{public static final java.util.List<java.lang.Double> timeCoefficients = new java.util.ArrayList<java.lang.Double>();}}
> {{static {}}
> {{  timeCoefficients.add(24.1);}}
> {{  timeCoefficients.add(60.1);}}
> {{  timeCoefficients.add(60.1);}}
> {{  timeCoefficients.add(1000.1);}}
> {{  timeCoefficients.add(1000.1);}}
> {{  timeCoefficients.add(1000.1);}}
> {{}}}
> My guess is that, even if I put {{.0}} at the end of each numeric constant, on the
Java side, Thrift compiler considers them to be {{double}} and does no typecasts. However,
the {{.0}} s are getting lost somewhere and the items become integers in the generated Java
code. Thus, when it comes to populating the array, Java cannot succeed. {{Double}} s cannot
be unboxed to integer and Java thinks {{int}} and {{Double}} are not related.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message