From c4a0e49f50a959dd3a6ed72f368b589d326e8d7a Mon Sep 17 00:00:00 2001 From: OISHI Masakuni Date: Wed, 23 Mar 2022 11:43:27 +0900 Subject: [PATCH 1/2] Upgrade libthrift to 0.16.0 --- gradle/libs.versions.toml | 2 +- sample_thrift/build.gradle | 1 + thrift/build.gradle | 1 + .../main/java/com/linecorp/lich/thrift/OkioTransport.kt | 9 +++++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5fc5f79..8a0b212 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -24,7 +24,7 @@ autoService = "1.0.1" autoServiceKsp = "1.0.0" okhttp = "4.9.3" kotlinpoet = "1.10.2" -thrift = "0.13.0" +thrift = "0.16.0" dexmaker = "2.28.1" mockito = "4.4.0" mockitoKotlin = "4.0.0" diff --git a/sample_thrift/build.gradle b/sample_thrift/build.gradle index aa13eda..3b7ba1a 100644 --- a/sample_thrift/build.gradle +++ b/sample_thrift/build.gradle @@ -9,6 +9,7 @@ java { dependencies { compileOnly(libs.libthrift) { + exclude group: 'org.apache.commons' exclude group: 'org.apache.httpcomponents' } } diff --git a/thrift/build.gradle b/thrift/build.gradle index f6466d8..ef31987 100644 --- a/thrift/build.gradle +++ b/thrift/build.gradle @@ -14,6 +14,7 @@ dependencies { implementation project(':okhttp') api libs.okhttp api(libs.libthrift) { + exclude group: 'org.apache.commons' exclude group: 'org.apache.httpcomponents' } diff --git a/thrift/src/main/java/com/linecorp/lich/thrift/OkioTransport.kt b/thrift/src/main/java/com/linecorp/lich/thrift/OkioTransport.kt index ffab482..12abcad 100644 --- a/thrift/src/main/java/com/linecorp/lich/thrift/OkioTransport.kt +++ b/thrift/src/main/java/com/linecorp/lich/thrift/OkioTransport.kt @@ -17,6 +17,7 @@ package com.linecorp.lich.thrift import okio.BufferedSink import okio.BufferedSource +import org.apache.thrift.TConfiguration import org.apache.thrift.transport.TTransport import java.io.EOFException @@ -71,4 +72,12 @@ class OkioTransport( override fun open() = Unit override fun close() = Unit + + // To keep binary compatibility with libthrift 0.13.0 or lower, + // we provide empty implementations for the following methods. + override fun getConfiguration(): TConfiguration = TConfiguration.DEFAULT + + override fun checkReadBytesAvailable(numBytes: Long) = Unit + + override fun updateKnownMessageSize(size: Long) = Unit } From b5214ee8d1faa294976063042cad295a60dad953 Mon Sep 17 00:00:00 2001 From: OISHI Masakuni Date: Wed, 23 Mar 2022 11:50:19 +0900 Subject: [PATCH 2/2] Regenerate sample_thrift using Thrift 0.16.0. --- .../lich/sample/thrift/FooException.java | 6 ++---- .../linecorp/lich/sample/thrift/FooParam.java | 10 ++++------ .../lich/sample/thrift/FooResponse.java | 10 ++++------ .../lich/sample/thrift/FooService.java | 20 ++++++------------- .../linecorp/lich/sample/thrift/FooUnion.java | 5 ++--- 5 files changed, 18 insertions(+), 33 deletions(-) diff --git a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooException.java b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooException.java index c768c63..62fb355 100644 --- a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooException.java +++ b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooException.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.13.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -178,8 +178,6 @@ public boolean isSet(_Fields field) { @Override public boolean equals(java.lang.Object that) { - if (that == null) - return false; if (that instanceof FooException) return this.equals((FooException)that); return false; @@ -222,7 +220,7 @@ public int compareTo(FooException other) { int lastComparison = 0; - lastComparison = java.lang.Boolean.valueOf(isSetReason()).compareTo(other.isSetReason()); + lastComparison = java.lang.Boolean.compare(isSetReason(), other.isSetReason()); if (lastComparison != 0) { return lastComparison; } diff --git a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooParam.java b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooParam.java index 893bf99..f52836d 100644 --- a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooParam.java +++ b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooParam.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.13.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -280,8 +280,6 @@ public boolean isSet(_Fields field) { @Override public boolean equals(java.lang.Object that) { - if (that == null) - return false; if (that instanceof FooParam) return this.equals((FooParam)that); return false; @@ -348,7 +346,7 @@ public int compareTo(FooParam other) { int lastComparison = 0; - lastComparison = java.lang.Boolean.valueOf(isSetNumber()).compareTo(other.isSetNumber()); + lastComparison = java.lang.Boolean.compare(isSetNumber(), other.isSetNumber()); if (lastComparison != 0) { return lastComparison; } @@ -358,7 +356,7 @@ public int compareTo(FooParam other) { return lastComparison; } } - lastComparison = java.lang.Boolean.valueOf(isSetComment()).compareTo(other.isSetComment()); + lastComparison = java.lang.Boolean.compare(isSetComment(), other.isSetComment()); if (lastComparison != 0) { return lastComparison; } @@ -368,7 +366,7 @@ public int compareTo(FooParam other) { return lastComparison; } } - lastComparison = java.lang.Boolean.valueOf(isSetFooUnion()).compareTo(other.isSetFooUnion()); + lastComparison = java.lang.Boolean.compare(isSetFooUnion(), other.isSetFooUnion()); if (lastComparison != 0) { return lastComparison; } diff --git a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooResponse.java b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooResponse.java index 4f775ce..83033a3 100644 --- a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooResponse.java +++ b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooResponse.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.13.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -282,8 +282,6 @@ public boolean isSet(_Fields field) { @Override public boolean equals(java.lang.Object that) { - if (that == null) - return false; if (that instanceof FooResponse) return this.equals((FooResponse)that); return false; @@ -350,7 +348,7 @@ public int compareTo(FooResponse other) { int lastComparison = 0; - lastComparison = java.lang.Boolean.valueOf(isSetNumber()).compareTo(other.isSetNumber()); + lastComparison = java.lang.Boolean.compare(isSetNumber(), other.isSetNumber()); if (lastComparison != 0) { return lastComparison; } @@ -360,7 +358,7 @@ public int compareTo(FooResponse other) { return lastComparison; } } - lastComparison = java.lang.Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage()); + lastComparison = java.lang.Boolean.compare(isSetMessage(), other.isSetMessage()); if (lastComparison != 0) { return lastComparison; } @@ -370,7 +368,7 @@ public int compareTo(FooResponse other) { return lastComparison; } } - lastComparison = java.lang.Boolean.valueOf(isSetComment()).compareTo(other.isSetComment()); + lastComparison = java.lang.Boolean.compare(isSetComment(), other.isSetComment()); if (lastComparison != 0) { return lastComparison; } diff --git a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooService.java b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooService.java index 94118a5..92c897f 100644 --- a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooService.java +++ b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooService.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.13.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -508,8 +508,6 @@ public boolean isSet(_Fields field) { @Override public boolean equals(java.lang.Object that) { - if (that == null) - return false; if (that instanceof ping_args) return this.equals((ping_args)that); return false; @@ -762,8 +760,6 @@ public boolean isSet(_Fields field) { @Override public boolean equals(java.lang.Object that) { - if (that == null) - return false; if (that instanceof ping_result) return this.equals((ping_result)that); return false; @@ -1176,8 +1172,6 @@ public boolean isSet(_Fields field) { @Override public boolean equals(java.lang.Object that) { - if (that == null) - return false; if (that instanceof callFoo_args) return this.equals((callFoo_args)that); return false; @@ -1244,7 +1238,7 @@ public int compareTo(callFoo_args other) { int lastComparison = 0; - lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId()); + lastComparison = java.lang.Boolean.compare(isSetId(), other.isSetId()); if (lastComparison != 0) { return lastComparison; } @@ -1254,7 +1248,7 @@ public int compareTo(callFoo_args other) { return lastComparison; } } - lastComparison = java.lang.Boolean.valueOf(isSetName()).compareTo(other.isSetName()); + lastComparison = java.lang.Boolean.compare(isSetName(), other.isSetName()); if (lastComparison != 0) { return lastComparison; } @@ -1264,7 +1258,7 @@ public int compareTo(callFoo_args other) { return lastComparison; } } - lastComparison = java.lang.Boolean.valueOf(isSetParam()).compareTo(other.isSetParam()); + lastComparison = java.lang.Boolean.compare(isSetParam(), other.isSetParam()); if (lastComparison != 0) { return lastComparison; } @@ -1701,8 +1695,6 @@ public boolean isSet(_Fields field) { @Override public boolean equals(java.lang.Object that) { - if (that == null) - return false; if (that instanceof callFoo_result) return this.equals((callFoo_result)that); return false; @@ -1758,7 +1750,7 @@ public int compareTo(callFoo_result other) { int lastComparison = 0; - lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + lastComparison = java.lang.Boolean.compare(isSetSuccess(), other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } @@ -1768,7 +1760,7 @@ public int compareTo(callFoo_result other) { return lastComparison; } } - lastComparison = java.lang.Boolean.valueOf(isSetE()).compareTo(other.isSetE()); + lastComparison = java.lang.Boolean.compare(isSetE(), other.isSetE()); if (lastComparison != 0) { return lastComparison; } diff --git a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooUnion.java b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooUnion.java index 4feb01f..25739bb 100644 --- a/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooUnion.java +++ b/sample_thrift/src/main/java/com/linecorp/lich/sample/thrift/FooUnion.java @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.13.0) + * Autogenerated by Thrift Compiler (0.16.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -267,9 +267,8 @@ public java.lang.String getStringValue() { } public void setStringValue(java.lang.String value) { - if (value == null) throw new java.lang.NullPointerException(); setField_ = _Fields.STRING_VALUE; - value_ = value; + value_ = java.util.Objects.requireNonNull(value,"_Fields.STRING_VALUE"); } public boolean isSetIntValue() {