You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/10/30 20:30:08 UTC

[GitHub] drcrallen opened a new issue #6553: Smile serde bug in 2.6.5

drcrallen opened a new issue #6553: Smile serde bug in 2.6.5
URL: https://github.com/apache/incubator-druid/issues/6553
 
 
   We hit a weird bug in Jackson 2.6.5 smile code (not present in druid master with 2.6.7) whereby the following unit test will fail:
   
   ```json
   /*
    * Licensed to the Apache Software Foundation (ASF) under one
    * or more contributor license agreements.  See the NOTICE file
    * distributed with this work for additional information
    * regarding copyright ownership.  The ASF licenses this file
    * to you under the Apache License, Version 2.0 (the
    * "License"); you may not use this file except in compliance
    * with the License.  You may obtain a copy of the License at
    *
    *   http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing,
    * software distributed under the License is distributed on an
    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    * KIND, either express or implied.  See the License for the
    * specific language governing permissions and limitations
    * under the License.
    */
   
   package org.apache.druid.jackson;
   
   
   import com.fasterxml.jackson.core.type.TypeReference;
   import com.fasterxml.jackson.databind.ObjectMapper;
   import org.apache.druid.query.Result;
   import org.apache.druid.query.topn.TopNResultValue;
   import org.junit.Assert;
   import org.junit.Test;
   import org.junit.runner.RunWith;
   import org.junit.runners.Parameterized;
   
   import java.io.ByteArrayInputStream;
   import java.io.IOException;
   import java.util.Arrays;
   import java.util.List;
   
   @RunWith(Parameterized.class)
   public class SmileMapperTest
   {
     private static final JacksonModule JACKSON_MODULE = new JacksonModule();
     private static final ObjectMapper JSON_MAPPER = JACKSON_MODULE.jsonMapper();
     private static final ObjectMapper SMILE_MAPPER = JACKSON_MODULE.smileMapper();
   
     private static final TypeReference<List<Result<TopNResultValue>>> TOPN_RESULT_REF = new TypeReference<List<Result<TopNResultValue>>>()
     {
     };
     private static final String BAD_JSON = "[\n"
                                            + "  {\n"
                                            + "    \"timestamp\": \"2018-10-17T08:00:00.000Z\",\n"
                                            + "    \"result\": [\n"
                                            + "      {\n"
                                            + "        \"top_server_impressions-6d6229a9-c552-48fe-99b3-12678001357c\": 0,\n"
                                            + "        \"top_server_impressions-fb7dcf6b-1db2-4cff-9930-75f43460a8\": 0\n"
                                            + "      }\n"
                                            + "    ]\n"
                                            + "  }\n"
                                            + "]\n";
     private static final String GOOD_JSON = "[\n"
                                             + "  {\n"
                                             + "    \"timestamp\": \"2018-10-17T08:00:00.000Z\",\n"
                                             + "    \"result\": [\n"
                                             + "      {\n"
                                             + "        \"top_server_impressions-6d6229a9-c552-48fe-99b3-12678001357c\": 0,\n"
                                             + "        \"top_server_impressions-fb7dcf6b-1db2-4cff-9930-75f43460a\": 0\n"
                                             + "      }\n"
                                             + "    ]\n"
                                             + "  }\n"
                                             + "]\n";
   
     @Parameterized.Parameters(name = "{0}")
     public static Iterable<Object[]> parameterFeeder()
     {
       return Arrays.asList(new Object[]{"Good", GOOD_JSON}, new Object[]{"Bad", BAD_JSON});
     }
   
   
     private final String json;
   
     public SmileMapperTest(String ignoredName, String json)
     {
       this.json = json;
     }
   
     public List<Result<TopNResultValue>> generateResult() throws IOException
     {
       return JSON_MAPPER.readValue(json, TOPN_RESULT_REF);
     }
   
     @Test
     public void testSmile() throws IOException
     {
       final List<Result<TopNResultValue>> origin = generateResult();
       final byte[] b = SMILE_MAPPER.writeValueAsBytes(origin);
       final List<Result<TopNResultValue>> result = SMILE_MAPPER.readValue(new ByteArrayInputStream(b), TOPN_RESULT_REF);
       Assert.assertEquals(origin, result);
     }
   }
   ```
   
   The error message looks like this:
   
   ```
   com.fasterxml.jackson.databind.JsonMappingException: Invalid byte fb in short Unicode text block
    at [Source: java.io.ByteArrayInputStream@13e39c73; line: -1, column: 174] (through reference chain: java.util.ArrayList[0]->io.druid.query.Result["result"]->java.util.ArrayList[0])
   ```
   
   And occurs when the broker deserializes stuff from the historicals.
   
   This is just to spread some knowledge since its already fixed in master.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org