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

ASF GitHub Bot commented on TAJO-2060:
--------------------------------------

Github user jinossy commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/946#discussion_r50218533
  
    --- Diff: 
tajo-core-tests/src/test/java/org/apache/tajo/util/TestGeoIPUtil.java ---
    @@ -0,0 +1,61 @@
    +/**
    + * 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.tajo.util;
    +
    +import static org.junit.Assert.assertNotNull;
    +
    +import org.apache.commons.io.IOUtils;
    +import org.junit.Test;
    +
    +import java.io.File;
    +import java.io.FileOutputStream;
    +import java.io.InputStream;
    +import java.io.OutputStream;
    +import java.lang.reflect.Field;
    +import java.net.URL;
    +import java.util.zip.GZIPInputStream;
    +
    +import com.maxmind.geoip.LookupService;
    +
    +public class TestGeoIPUtil {
    +  @Test
    +  public void testCountryCode() throws Exception {
    +    new GeoIPUtil(); // initialize static field.
    +
    +    LookupService lookup = new LookupService(getGeoIpData().getPath(), 
LookupService.GEOIP_MEMORY_CACHE);
    +    System.out.println(GeoIPUtil.class.getDeclaredField("LOG"));
    +    Field lookupField = GeoIPUtil.class.getDeclaredField("lookup");
    +    lookupField.setAccessible(true);
    +    lookupField.set(null, lookup);
    +    assertNotNull(GeoIPUtil.getCountryCode("154.73.88.82"));
    +    assertNotNull(GeoIPUtil.getCountryCode("154.73.89.143"));
    +    assertNotNull(GeoIPUtil.getCountryCode("154.76.101.156"));
    +  }
    +
    +  private File getGeoIpData() throws Exception {
    +    File tmpFile = File.createTempFile("GeoIP", ".dat");
    +
    +    try (InputStream is = new 
URL("http://www.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz";)
    +        .openConnection().getInputStream();
    +        OutputStream out = new FileOutputStream(tmpFile)) {
    +      IOUtils.copy(new GZIPInputStream(is), out);
    +    }
    +    return tmpFile;
    +  }
    +}
    --- End diff --
    
    In my opinion, we don’t need to tests of third-party module.


> Upgrade geoip-api-java library
> ------------------------------
>
>                 Key: TAJO-2060
>                 URL: https://issues.apache.org/jira/browse/TAJO-2060
>             Project: Tajo
>          Issue Type: Improvement
>          Components: Function/UDF
>    Affects Versions: 0.11.1
>            Reporter: Byunghwa Yun
>            Assignee: Byunghwa Yun
>            Priority: Critical
>             Fix For: 0.12.0, 0.11.1
>
>
> Tajo use the dspace-geoip library, version is 1.2.3.
> Now geoip data doesn't work at 1.2.3 version.
> We need change 1.2.14 from 1.2.3 version.
> Below related exception.
> java.lang.ArrayIndexOutOfBoundsException: 254
>       at com.maxmind.geoip.LookupService.getCountry(LookupService.java:436)
>       at com.maxmind.geoip.LookupService.getCountry(LookupService.java:408)
>       at org.apache.tajo.util.GeoIPUtil.getCountryCode(GeoIPUtil.java:44)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to