Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An annotation-based Java library for creating Thrift serializable types and services.
Java Thrift Other

[codec] Allow negative field numbers in structs/unions

Summary:

Negative field IDs are strongly discouraged, but some old services used
them and are stuck with them to maintain wire compatibility with older
clients. Don't error out on them. Add an `isLegacyId` attribute to the
`@ThriftField` annotation to allow them when necessary. Any
`@ThriftField` which has a negative ID must have `isLegacyId=true`;
`@ThriftField`'s with non-negative IDs must not (but may specify
`isLegacyId=false` if they want.)

Test Plan:

grep in swift-codec for `> 0`, `>= 0`, `< 0`, `<= 0`, (and the other way
around). A bunch of ThriftStructs which didn't used to be able to be
loaded are now. Added unit tests.

Reviewers: alandau, andrewcox, haijunz

CC:
latest commit 7fa662786e
@jesboat jesboat authored
Failed to load latest commit information.
src/license Drop custom BytecodeReadingParanamer and use an official fix
swift-annotations [codec] Allow negative field numbers in structs/unions
swift-codec [codec] Allow negative field numbers in structs/unions
swift-generator-cli [maven-release-plugin] prepare for next development iteration
swift-generator [maven-release-plugin] prepare for next development iteration
swift-idl-parser [maven-release-plugin] prepare for next development iteration
swift-javadoc JavaDocProcessor: Inherit javadocs from base class fields/methods
swift-load-generator [maven-release-plugin] prepare for next development iteration
swift-maven-plugin [maven-release-plugin] prepare for next development iteration
swift-service [codec] Allow negative field numbers in structs/unions
swift2thrift-generator-cli [maven-release-plugin] prepare for next development iteration
.arcconfig Initial revision for review.
.gitignore Remove dependency-reduced-pom.xml
CHANGES.md CHANGES.md
NEWS.md Update the swift code to use the split timeouts for receive and read.
README.md [swift2thrift] Addded README.md
license.txt Change to ASL license headers
notice.md Change to ASL license headers
pom.xml [maven-release-plugin] prepare for next development iteration

README.md

Swift

Swift is an easy-to-use, annotation-based Java library for creating Thrift serializable types and services.

Swift Codec

Swift Codec is a simple library specifying how Java objects are converted to and from Thrift. This library is similar to JaxB (XML) and Jackson (JSON), but for Thrift. Swift codec supports field, method, constructor, and builder injection. For example:

@ThriftStruct
public class LogEntry
{
    private final String category;
    private final String message;

    @ThriftConstructor
    public LogEntry(String category, String message)
    {
        this.category = category;
        this.message = message;
    }

    @ThriftField(1)
    public String getCategory()
    {
        return category;
    }

    @ThriftField(2)
    public String getMessage()
    {
        return message;
    }
}

Swift Service

Swift Service is a simple library annotating services to be exported with Thrift. For example:

@ThriftService("scribe")
public class InMemoryScribe
{
    private final List<LogEntry> messages = new ArrayList<>();

    public List<LogEntry> getMessages()
    {
        return messages;
    }

    @ThriftMethod("Log")
    public ResultCode log(List<LogEntry> messages)
    {
        this.messages.addAll(messages);
        return ResultCode.OK;
    }
}

Swift Generator

Swift Generator is a library that creates Java code usable with the Swift codec from Thrift IDL files and vice versa.

Swift Generator CLI and Swift2Thrift Generator CLI are command-line front-ends to this generator.

Swift Maven plugin

Swift Maven plugin allows using the code generator from a maven build and generate source code on the fly.

Something went wrong with that request. Please try again.