You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/11/01 04:17:58 UTC

[jira] [Commented] (THRIFT-3301) Java generated code uses imports that can lead to class name collisions with IDL defined types

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

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

GitHub user bgould opened a pull request:

    https://github.com/apache/thrift/pull/1120

    THRIFT-3301: Naming collisions possible in generated Java code

    Switched to fully-qualified names for all class name references in generated code.  Added test IDL to verify generated code compiles successfully.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/bgould/thrift THRIFT-3301

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/1120.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1120
    
----
commit c6c5a054955c1b76fa498bb74388b5ddc8f36c14
Author: BCG <bg...@users.noreply.github.com>
Date:   2016-11-01T03:32:18Z

    Switched to fully-qualified names for all class name references in generated code

----


> Java generated code uses imports that can lead to class name collisions with IDL defined types
> ----------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-3301
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3301
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Compiler
>    Affects Versions: 0.8, 0.9, 0.9.1, 0.9.2
>         Environment: Tested on Linux (Ubuntu 14) with Oracle JDK 8
>            Reporter: Alexander Volanis
>         Attachments: thrift-issue-3301.tgz
>
>
> The Java generator will produce Java classes with the following set of imports
> {code}
> import org.apache.thrift.scheme.IScheme;
> import org.apache.thrift.scheme.SchemeFactory;
> import org.apache.thrift.scheme.StandardScheme;
> import org.apache.thrift.scheme.TupleScheme;
> import org.apache.thrift.protocol.TTupleProtocol;
> import java.util.List;
> import java.util.ArrayList;
> import java.util.Map;
> import java.util.HashMap;
> import java.util.EnumMap;
> import java.util.Set;
> import java.util.HashSet;
> import java.util.EnumSet;
> import java.util.Collections;
> import java.util.BitSet;
> import java.nio.ByteBuffer;
> import java.util.Arrays;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> {code}
> Any one of the imported classes may cause a name conflict with generated code that happens to define a same name class and uses such class as argument or result to methods.
> The generated code should always use fully qualified references to the classes when necessary and avoid all use of imports.



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