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

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

Github user ozymaxx commented on the issue:

    https://github.com/apache/thrift/pull/1496
  
    @jeking3 Forget about what I said on Travis. There is only 1 failure in 
Apache arsenal of Travis (at `cross-test`) as follows:
    ```
    
===============================================================================
    Using JSON protocol
    Using framed transport
    testVoid() = void
    testString("Test") = "Test"
    testBool(true) = True
    testBool(false) = False
    testByte(1) = 1
    testI32(-1) = -1
    testI64(-34359738368) = -34359738368
    testDouble(5.325098235) = 5.325098235
    testDouble(-0.000341012439638598279) = -0.000341012439638598
    
testBinary(000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF)
 = 
000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
    
testBinary(000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F
    .
    .
    .
    *** FAILED ***
    *** FAILED ***
    *** FAILED ***
    *** FAILED ***
    *** FAILED ***
    Test CrazyNesting
    testStruct({"Zero", 1, -3, -5}) = {"Zero", 1, -3, -5}
    testNest({1, {"Zero", 1, -3, -5}, 5}) = {1, {"Zero", 1, -3, -5}, 5}
    testMap({0 => -10, 1 => -9, 2 => -8, 3 => -7, 4 => -6}) = {0 => -10, 1 => 
-9, 2 => -8, 3 => -7, 4 => -6}
    testList({-2, -1, 0, 1, 2}) = {-2, -1, 0, 1, 2}
    testSet({-2, -1, 0, 1, 2}) = {0, 1, 2, -2, -1}
    testEnum(ONE) = ONE
    testEnum(TWO) = TWO
    testEnum(THREE) = THREE
    testEnum(FIVE) = FIVE
    testEnum(EIGHT) = EIGHT
    testTypedef(309858235082523) = 309858235082523
    testMapMap(1) = {4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, -4 => {-4 => -4, 
-3 => -3, -2 => -2, -1 => -1, }, }
    testInsanity() = {1 => {TWO => {{FIVE => 5000, }, {{"Truck", 8, 8, 8}, }}, 
THREE => {{FIVE => 5000, }, {{"Truck", 8, 8, 8}, }}, }, 2 => {SIX => {{}, {}}, 
}, }
    Test 
Multi(1,2,9223372036854775807,System.Collections.Generic.Dictionary`2[System.Int16,System.String],FIVE,5000000)
 = 
Xtruct(byte_thing:1,String_thing:Hello2,i32_thing:2,i64_thing:9223372036854775807)
    testException("Xception")
    testException("TException")
    testException("ok")
    testMultiException("Xception", ...)
    testMultiException("Xception2", ...)
    testMultiException("success", "OK")
    Test Oneway(1)
    Test Calltime() = 59 ms a testVoid() call
    Total time: 00:00:04.3274560
    
    
===============================================================================
    Return code: 1
    Test execution took 4.5 seconds.
    Wed Mar 14 13:10:58 2018
    ```
    
    But the error is the same in the Windows builders (although it seems green 
here). 


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

Reply via email to