Skip to content

Commit

Permalink
Bump com.ncorti.ktfmt.gradle from 0.19.0 to 0.20.1 in /lib/kotlin (#3031
Browse files Browse the repository at this point in the history
)

* Bump com.ncorti.ktfmt.gradle from 0.19.0 to 0.20.1 in /lib/kotlin

Bumps com.ncorti.ktfmt.gradle from 0.19.0 to 0.20.1.

---
updated-dependencies:
- dependency-name: com.ncorti.ktfmt.gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix formatting

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Christopher Tubbs <ctubbsii@apache.org>
  • Loading branch information
dependabot[bot] and ctubbsii committed Sep 4, 2024
1 parent ed5c5a4 commit be216b1
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ enum class ProtocolType(val key: String) {
Json("json"),
MultiJson("multij"),
Compact("compact"),
MultiCompact("multic")
MultiCompact("multic"),
}

enum class TransportType(val key: String) {
Buffered("buffered"),
Framed("framed"),
FastFramed("fastframed"),
Http("http")
Http("http"),
}

class TestClient : CliktCommand() {
Expand Down Expand Up @@ -114,7 +114,8 @@ class TestClient : CliktCommand() {
TransportType.Framed -> TNonblockingSocket(host, port, socketTimeout)
else ->
throw UnsupportedOperationException(
"only frame transport type is supported for now, got $transportType")
"only frame transport type is supported for now, got $transportType"
)
}

private val clientManager = TAsyncClientManager()
Expand Down Expand Up @@ -272,7 +273,8 @@ class TestClient : CliktCommand() {
if (xtructs != null) {
for ((string_thing, byte_thing, i32_thing, i64_thing) in xtructs) {
print(
"{\"$string_thing\", $byte_thing, $i32_thing, $i64_thing}, ")
"{\"$string_thing\", $byte_thing, $i32_thing, $i64_thing}, "
)
}
}
print("}")
Expand All @@ -284,13 +286,15 @@ class TestClient : CliktCommand() {
if (whoa.size == 2 && whoa.containsKey(1L) && whoa.containsKey(2L)) {
val firstMap = whoa[1L]!!
val secondMap = whoa[2L]!!
if (firstMap.size == 2 &&
firstMap.containsKey(Numberz.TWO) &&
firstMap.containsKey(Numberz.THREE) &&
secondMap.size == 1 &&
secondMap.containsKey(Numberz.SIX) &&
insane == firstMap[Numberz.TWO] &&
insane == firstMap[Numberz.THREE]) {
if (
firstMap.size == 2 &&
firstMap.containsKey(Numberz.TWO) &&
firstMap.containsKey(Numberz.THREE) &&
secondMap.size == 1 &&
secondMap.containsKey(Numberz.SIX) &&
insane == firstMap[Numberz.TWO] &&
insane == firstMap[Numberz.THREE]
) {
val six = secondMap[Numberz.SIX]!!
// Cannot use "new Insanity().equals(six)" because as of now,
// struct/container
Expand Down Expand Up @@ -361,9 +365,11 @@ class TestClient : CliktCommand() {

private suspend fun multiplexTest(returnCode: Int): Int {
var code = returnCode
if (protocolType == ProtocolType.Multi ||
protocolType == ProtocolType.MultiJson ||
protocolType == ProtocolType.MultiCompact) {
if (
protocolType == ProtocolType.Multi ||
protocolType == ProtocolType.MultiJson ||
protocolType == ProtocolType.MultiCompact
) {
val secondClient: SecondServiceClient = createSecondServiceClient()
print("secondtestString(\"Test2\")")
val s = secondClient.secondtestString("Test2")
Expand Down Expand Up @@ -432,7 +438,7 @@ class TestClient : CliktCommand() {

private suspend fun exceptionTest(
testClient: ThriftTestClient,
returnCode: Int
returnCode: Int,
): Pair<Int, ThriftTestClient> {
var client = testClient
var code = returnCode
Expand Down Expand Up @@ -467,7 +473,7 @@ class TestClient : CliktCommand() {

private suspend fun multiExceptionTest(
testClient: ThriftTestClient,
returnCode: Int
returnCode: Int,
): Pair<Int, ThriftTestClient> {
var client = testClient
var code = returnCode
Expand Down Expand Up @@ -523,7 +529,8 @@ private suspend fun ThriftTestClient.structTest(returnCode: Int): Pair<Xtruct, I
out.i64_thing = -5
val input: Xtruct = testStruct(out)
print(
""" = {"${input.string_thing}",${input.byte_thing}, ${input.i32_thing}, ${input.i64_thing}}""")
""" = {"${input.string_thing}",${input.byte_thing}, ${input.i32_thing}, ${input.i64_thing}}"""
)
if (input != out) {
code = code or ERR_STRUCTS
println("*** FAILURE ***\n")
Expand Down Expand Up @@ -572,14 +579,16 @@ private suspend fun ThriftTestClient.nestedMapTest(returnCode: Int): Int {
} else {
val m1 = mm[4]!!
val m2 = mm[-4]!!
if (m1[1] != 1 ||
m1[2] != 2 ||
m1[3] != 3 ||
m1[4] != 4 ||
m2[-1] != -1 ||
m2[-2] != -2 ||
m2[-3] != -3 ||
m2[-4] != -4) {
if (
m1[1] != 1 ||
m1[2] != 2 ||
m1[3] != 3 ||
m1[4] != 4 ||
m2[-1] != -1 ||
m2[-2] != -2 ||
m2[-3] != -3 ||
m2[-4] != -4
) {
returnCode1 = returnCode1 or ERR_CONTAINERS
println("*** FAILURE ***\n")
}
Expand Down Expand Up @@ -639,7 +648,8 @@ private suspend fun ThriftTestClient.nestedStructTest(out: Xtruct, returnCode: I
val input = xstruct2.struct_thing!!
print(
""" = {${xstruct2.byte_thing}, {"${input.string_thing}", ${input.byte_thing}, ${input.i32_thing}, ${input.i64_thing}}, ${xstruct2.i32_thing}}
""")
"""
)
if (xstruct2 != out2) {
code = code or ERR_STRUCTS
println("*** FAILURE ***\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,17 @@ class TestHandler : ThriftTest {

override suspend fun testStruct(thing: Xtruct): Xtruct {
logger.info(
"""testStruct({"${thing.string_thing}", ${thing.byte_thing}, ${thing.i32_thing}, ${thing.i64_thing}})""")
"""testStruct({"${thing.string_thing}", ${thing.byte_thing}, ${thing.i32_thing}, ${thing.i64_thing}})"""
)
return thing
}

override suspend fun testNest(thing: Xtruct2): Xtruct2 {
val thing2: Xtruct = thing.struct_thing!!
logger.info(
"""testNest({${thing.byte_thing}, {"${thing2.string_thing}", ${thing2.byte_thing}, ${thing2.i32_thing}, ${thing2.i64_thing}}, ${thing.i32_thing}})"""
.trimIndent())
.trimIndent()
)
return thing
}

Expand Down Expand Up @@ -200,7 +202,7 @@ class TestHandler : ThriftTest {
arg2: Long,
arg3: Map<Short, String>,
arg4: Numberz,
arg5: Long
arg5: Long,
): Xtruct {
logger.info("testMulti()\n")
val hello = Xtruct()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ object TestServer {
}
} catch (e: Exception) {
throw RuntimeException(
"The context is not a wrapper and does not implement the interface")
"The context is not a wrapper and does not implement the interface"
)
}
}

Expand All @@ -98,7 +99,8 @@ object TestServer {

override fun preServe() {
println(
"TServerEventHandler.preServe - called only once before server starts accepting connections")
"TServerEventHandler.preServe - called only once before server starts accepting connections"
)
}

override fun createContext(input: TProtocol, output: TProtocol): ServerContext {
Expand All @@ -108,32 +110,35 @@ object TestServer {
println(
"TServerEventHandler.createContext - connection #" +
ctx.connectionId +
" established")
" established"
)
return ctx
}

override fun deleteContext(
serverContext: ServerContext,
input: TProtocol,
output: TProtocol
output: TProtocol,
) {
val ctx = serverContext.unwrap(TestServerContext::class.java)
println(
"TServerEventHandler.deleteContext - connection #" +
ctx.connectionId +
" terminated")
" terminated"
)
}

override fun processContext(
serverContext: ServerContext,
inputTransport: TTransport,
outputTransport: TTransport
outputTransport: TTransport,
) {
val ctx = serverContext.unwrap(TestServerContext::class.java)
println(
"TServerEventHandler.processContext - connection #" +
ctx.connectionId +
" is ready to process next request")
" is ready to process next request"
)
}
}
}
Expand All @@ -142,7 +147,7 @@ enum class ServerType(val key: String) {
Simple("simple"),
ThreadPool("thread-pool"),
NonBlocking("nonblocking"),
ThreadedSelector("threaded-selector")
ThreadedSelector("threaded-selector"),
}

enum class ProtocolType(val key: String) {
Expand All @@ -151,14 +156,14 @@ enum class ProtocolType(val key: String) {
Json("json"),
MultiJson("multij"),
Compact("compact"),
MultiCompact("multic")
MultiCompact("multic"),
}

enum class TransportType(val key: String) {
Buffered("buffered"),
FastFramed("fastframed"),
Framed("framed"),
Zlib("zlib")
Zlib("zlib"),
}

class TestServerCommand : CliktCommand() {
Expand Down Expand Up @@ -193,12 +198,14 @@ class TestServerCommand : CliktCommand() {
protocolType,
getProtocolFactory(),
getTransportFactory(),
useSSL)
useSSL,
)
// Set server event handler
serverEngine.setServerEventHandler(TestServer.TestServerEventHandler())
// Run it
println(
"Starting the ${if (useSSL) "ssl server" else "server"} [$protocolType/$transportType/$serverType] on port $port")
"Starting the ${if (useSSL) "ssl server" else "server"} [$protocolType/$transportType/$serverType] on port $port"
)
serverEngine.serve()
}

Expand Down Expand Up @@ -241,7 +248,7 @@ private fun getServerEngine(
protocolType: ProtocolType,
tProtocolFactory: TProtocolFactory,
tTransportFactory: TTransportFactory,
ssl: Boolean
ssl: Boolean,
): TServer {
val isMulti =
protocolType == ProtocolType.Multi ||
Expand All @@ -261,7 +268,8 @@ private fun getServerEngine(
ServerType.NonBlocking -> {
val tNonblockingServerArgs = TNonblockingServer.Args(tNonblockingServerSocket)
tNonblockingServerArgs.processor(
if (isMulti) multiplexedProcessor else testProcessor)
if (isMulti) multiplexedProcessor else testProcessor
)
tNonblockingServerArgs.protocolFactory(tProtocolFactory)
tNonblockingServerArgs.transportFactory(tTransportFactory)
return TNonblockingServer(tNonblockingServerArgs)
Expand All @@ -270,7 +278,8 @@ private fun getServerEngine(
val tThreadedSelectorServerArgs =
TThreadedSelectorServer.Args(tNonblockingServerSocket)
tThreadedSelectorServerArgs.processor(
if (isMulti) multiplexedProcessor else testProcessor)
if (isMulti) multiplexedProcessor else testProcessor
)
tThreadedSelectorServerArgs.protocolFactory(tProtocolFactory)
tThreadedSelectorServerArgs.transportFactory(tTransportFactory)
return TThreadedSelectorServer(tThreadedSelectorServerArgs)
Expand All @@ -297,7 +306,8 @@ private fun getServerEngine(
else -> {
val tThreadPoolServerArgs = TThreadPoolServer.Args(tServerSocket)
tThreadPoolServerArgs.processor(
if (isMulti) multiplexedProcessor else testProcessor)
if (isMulti) multiplexedProcessor else testProcessor
)
tThreadPoolServerArgs.protocolFactory(tProtocolFactory)
tThreadPoolServerArgs.transportFactory(tTransportFactory)
return TThreadPoolServer(tThreadPoolServerArgs)
Expand Down
2 changes: 1 addition & 1 deletion lib/kotlin/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
pluginManagement {
plugins {
kotlin("jvm") version "2.0.20"
id("com.ncorti.ktfmt.gradle") version "0.19.0"
id("com.ncorti.ktfmt.gradle") version "0.20.1"
}
}

Expand Down
7 changes: 1 addition & 6 deletions lib/kotlin/src/test/kotlin/org/apache/thrift/MetaDataTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ internal class MetaDataTest {
assertEquals(3, personMetadata.size)
val idField = personMetadata[Person._Fields.ID]!!
assertEquals("id", idField.fieldName)
assertEquals(
mapOf(
"max" to "100000",
"min" to "1",
),
idField.fieldAnnotations)
assertEquals(mapOf("max" to "100000", "min" to "1"), idField.fieldAnnotations)
}
}

0 comments on commit be216b1

Please sign in to comment.