Skip to content

Commit b4368df

Browse files
anssari1github-actions[bot]
authored andcommitted
chore: Publish v5.3.2-SNAPSHOT
1 parent 6624002 commit b4368df

22 files changed

+87
-294
lines changed

code/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<dependency>
66
<groupId>com.expediagroup</groupId>
77
<artifactId>rapid-sdk</artifactId>
8-
<version>5.3.1</version>
8+
<version>5.3.2-SNAPSHOT</version>
99
</dependency>
1010
```
1111

code/pom.xml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.expediagroup</groupId>
66
<artifactId>rapid-sdk</artifactId>
7-
<version>5.3.1</version>
7+
<version>5.3.2-SNAPSHOT</version>
88
<name>EG rapid-sdk for Java</name>
9-
<description>EG rapid-sdk v5.3.1</description>
9+
<description>EG rapid-sdk v5.3.2-SNAPSHOT</description>
1010
<url>https://github.com/ExpediaGroup/test-sdk</url>
1111
<inceptionYear>2022</inceptionYear>
1212
<packaging>jar</packaging>
@@ -74,15 +74,15 @@
7474
<build-helper-maven-plugin.version>3.6.0</build-helper-maven-plugin.version>
7575
<ktlint-plugin.version>3.4.0</ktlint-plugin.version>
7676
<jacoco-plugin.version>0.8.12</jacoco-plugin.version>
77-
<dokka-plugin.version>1.9.20</dokka-plugin.version>
77+
<dokka-plugin.version>2.0.0</dokka-plugin.version>
7878
<dokka-old-versions.location/> <!-- passed as a property when running dokka:dokka-->
7979
<properties.maven.plugin.version>1.2.1</properties.maven.plugin.version>
8080
<maven.licence.plugin.version>4.6</maven.licence.plugin.version>
8181
<flatten.maven.plugin.version>1.6.0</flatten.maven.plugin.version>
82-
<kotlin.version>2.0.21</kotlin.version>
83-
<kotlinx.coroutines.version>1.9.0</kotlinx.coroutines.version>
84-
<ktor.version>2.3.13</ktor.version>
85-
<kotlin-atomic.version>0.26.1</kotlin-atomic.version>
82+
<kotlin.version>2.1.0</kotlin.version>
83+
<kotlinx.coroutines.version>1.10.1</kotlinx.coroutines.version>
84+
<ktor.version>3.0.3</ktor.version>
85+
<kotlin-atomic.version>0.27.0</kotlin-atomic.version>
8686
<slf4j.version>2.0.16</slf4j.version>
8787
<maven.nexus-staging.plugin.version>1.7.0</maven.nexus-staging.plugin.version>
8888
<maven.gpg.plugin.version>3.2.7</maven.gpg.plugin.version>
@@ -138,7 +138,7 @@
138138
<dependency>
139139
<groupId>com.squareup.okio</groupId>
140140
<artifactId>okio-jvm</artifactId>
141-
<version>3.9.1</version>
141+
<version>3.10.2</version>
142142
</dependency>
143143
<dependency>
144144
<groupId>org.jetbrains</groupId>
@@ -449,6 +449,7 @@
449449
<plugin>
450450
<groupId>org.jetbrains.dokka</groupId>
451451
<artifactId>dokka-maven-plugin</artifactId>
452+
<version>${dokka-plugin.version}</version>
452453
<configuration>
453454
<sourceDirectories>
454455
<dir>${project.basedir}/src/main/kotlin/com/expediagroup/sdk/rapid</dir>
@@ -732,13 +733,13 @@
732733
<dependency>
733734
<groupId>org.apache.commons</groupId>
734735
<artifactId>commons-lang3</artifactId>
735-
<version>3.14.0</version>
736+
<version>3.17.0</version>
736737
</dependency>
737738

738739
<dependency>
739740
<groupId>org.apache.commons</groupId>
740741
<artifactId>commons-text</artifactId>
741-
<version>1.12.0</version>
742+
<version>1.13.0</version>
742743
</dependency>
743744

744745
<dependency>

code/src/main/kotlin/com/expediagroup/sdk/core/client/Client.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import okhttp3.Dispatcher
5454
import okhttp3.OkHttpClient
5555

5656
// Create a Dispatcher with limits
57-
val dispatcher =
57+
val configuredDispatcher =
5858
Dispatcher().apply {
5959
maxRequests = 10000 // Maximum number of concurrent requests
6060
maxRequestsPerHost = 1000
@@ -64,7 +64,7 @@ val DEFAULT_HTTP_CLIENT_ENGINE: HttpClientEngine =
6464
OkHttp.create {
6565
config {
6666
eventListenerFactory(OkHttpEventListener.FACTORY)
67-
dispatcher(dispatcher)
67+
dispatcher(configuredDispatcher)
6868
}
6969
}
7070

code/src/main/kotlin/com/expediagroup/sdk/core/client/ExpediaGroupClient.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,20 @@ abstract class ExpediaGroupClient(
6767
return self()
6868
}
6969
}
70+
71+
@Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients.
72+
abstract class BuilderWithHttpClient<SELF : Client.BuilderWithHttpClient<SELF>> : Client.BuilderWithHttpClient<SELF>() {
73+
/** Sets the API auth endpoint to use for requests. */
74+
protected var authEndpoint: String? = null
75+
76+
/** Sets the API auth endpoint to use for requests.
77+
*
78+
* @param authEndpoint The API auth endpoint to use for requests.
79+
* @return The [Builder] instance.
80+
*/
81+
fun authEndpoint(authEndpoint: String): SELF {
82+
this.authEndpoint = authEndpoint
83+
return self()
84+
}
85+
}
7086
}

code/src/main/kotlin/com/expediagroup/sdk/core/configuration/provider/XapConfigurationProvider.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
*/
1616
package com.expediagroup.sdk.core.configuration.provider
1717

18-
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.connectionTimeout
19-
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.endpoint
20-
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.name
21-
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.requestTimeout
22-
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.socketTimeout
2318
import com.expediagroup.sdk.core.constant.Constant
2419

2520
/**

code/src/main/kotlin/com/expediagroup/sdk/core/constant/Constant.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616
package com.expediagroup.sdk.core.constant
1717

18-
import io.ktor.client.plugins.HttpTimeout
18+
import io.ktor.client.plugins.HttpTimeoutConfig
1919

2020
internal object Constant {
2121
const val EMPTY_STRING = ""
2222
const val TEN_SECONDS_IN_MILLIS = 10_000L
2323
const val FIFTEEN_SECONDS_IN_MILLIS = 15_000L
24-
const val INFINITE_TIMEOUT = HttpTimeout.INFINITE_TIMEOUT_MS
24+
const val INFINITE_TIMEOUT = HttpTimeoutConfig.INFINITE_TIMEOUT_MS
2525

2626
private const val SUCCESSFUL_STATUS_CODES_RANGE_START = 200
2727
private const val SUCCESSFUL_STATUS_CODES_RANGE_END = 299

code/src/main/kotlin/com/expediagroup/sdk/core/constant/LogMaskingRegex.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
*/
1616
package com.expediagroup.sdk.core.constant
1717

18+
import com.expediagroup.sdk.core.constant.LoggingMessage.OMITTED
19+
1820
internal object LogMaskingRegex {
1921
val FIELD_REGEX = "^[a-zA-Z0-9-_]+$".toRegex()
2022

21-
val NUMBER_FIELD_REGEX = "(?<=[\"']?number[\"']?:\\s?[\"'])(\\s*\\d{15,16}\\s*)(?=[\"'])".toRegex()
23+
val NUMBER_FIELD_REGEX = "[\"']?(number)([\"']?:\\s?[\"'])(\\s*\\d{12,19}\\s*)(\\\\?\\\"|)".toRegex()
24+
25+
const val REPLACEMENT_TEMPLATE = "\"$1$2${OMITTED}\""
2226
}

code/src/main/kotlin/com/expediagroup/sdk/core/constant/provider/LogMaskingRegexProvider.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616
package com.expediagroup.sdk.core.constant.provider
1717

1818
internal object LogMaskingRegexProvider {
19-
fun getMaskedFieldsRegex(maskedBodyFields: Set<String>) = "(?<=[\"']?(${maskedBodyFields.joinToString("|")})[\"']?:\\s?[\"'])(\\s*[^\"']+\\s*)(?=[\"'])".toRegex()
19+
fun getMaskedFieldsRegex(maskedBodyFields: Set<String>): Regex {
20+
val fields = maskedBodyFields.joinToString("|")
21+
return "\"($fields)(\\\\*\\\"\\s*:\\s*\\\\*\\\")([^\\\"]{1,2})[^\\\"]*(\\\\?\\\"|)".toRegex()
22+
}
2023
}

code/src/main/kotlin/com/expediagroup/sdk/core/model/paging/Paginator.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import io.ktor.client.statement.HttpResponse
2424
sealed class BasePaginator<R, T>(
2525
private val client: Client,
2626
firstResponse: Response<T>,
27-
private val fallbackBody: T,
2827
private val getBody: suspend (HttpResponse) -> T
2928
) : Iterator<R> {
3029
private var state: ResponseState<T> = DefaultResponseState(firstResponse)
@@ -41,7 +40,7 @@ sealed class BasePaginator<R, T>(
4140

4241
protected fun nextResponse(): Response<T> {
4342
val response = state.getNextResponse()
44-
state = ResponseStateFactory.getState(extractLink(response.headers), client, fallbackBody, getBody)
43+
state = ResponseStateFactory.getState(extractLink(response.headers), client, getBody)
4544
return response
4645
}
4746
}
@@ -56,9 +55,8 @@ sealed class BasePaginator<R, T>(
5655
class Paginator<T>(
5756
client: Client,
5857
firstResponse: Response<T>,
59-
fallbackBody: T,
6058
getBody: suspend (HttpResponse) -> T
61-
) : BasePaginator<T, T>(client, firstResponse, fallbackBody, getBody) {
59+
) : BasePaginator<T, T>(client, firstResponse, getBody) {
6260
/**
6361
* Returns the body of the next response.
6462
*
@@ -77,9 +75,8 @@ class Paginator<T>(
7775
class ResponsePaginator<T>(
7876
client: Client,
7977
firstResponse: Response<T>,
80-
fallbackBody: T,
8178
getBody: suspend (HttpResponse) -> T
82-
) : BasePaginator<Response<T>, T>(client, firstResponse, fallbackBody, getBody) {
79+
) : BasePaginator<Response<T>, T>(client, firstResponse, getBody) {
8380
/**
8481
* Returns the next response.
8582
*

code/src/main/kotlin/com/expediagroup/sdk/core/model/paging/ResponseState.kt

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,9 @@
1616
package com.expediagroup.sdk.core.model.paging
1717

1818
import com.expediagroup.sdk.core.client.Client
19-
import com.expediagroup.sdk.core.constant.HeaderValue
2019
import com.expediagroup.sdk.core.model.Response
21-
import com.expediagroup.sdk.core.plugin.logging.GZipEncoder.decode
22-
import com.expediagroup.sdk.core.plugin.logging.contentEncoding
2320
import io.ktor.client.statement.HttpResponse
24-
import io.ktor.util.InternalAPI
25-
import io.ktor.util.moveToByteArray
26-
import io.ktor.utils.io.ByteReadChannel
27-
import io.ktor.utils.io.bits.Memory
2821
import kotlinx.coroutines.runBlocking
29-
import java.nio.ByteBuffer
3022

3123
internal interface ResponseState<T> {
3224
fun getNextResponse(): Response<T>
@@ -51,7 +43,6 @@ internal class LastResponseState<T> : ResponseState<T> {
5143
internal class FetchLinkState<T>(
5244
private val link: String,
5345
private val client: Client,
54-
private val fallbackBody: T,
5546
private val getBody: suspend (HttpResponse) -> T
5647
) : ResponseState<T> {
5748
override fun getNextResponse(): Response<T> =
@@ -63,32 +54,15 @@ internal class FetchLinkState<T>(
6354

6455
override fun hasNext(): Boolean = true
6556

66-
private suspend fun parseBody(response: HttpResponse): T = if (decodeBody(response).isEmpty()) fallbackBody else getBody(response)
67-
68-
private suspend fun decodeBody(response: HttpResponse): String {
69-
val byteReadChannel = prepareByteReadChannel(response)
70-
val decodedByteReadChannel = if (response.contentEncoding().equals(HeaderValue.GZIP)) client.httpClient.decode(byteReadChannel) else byteReadChannel
71-
val bodyString: String = decodedByteReadChannel.readRemaining().readText()
72-
return bodyString
73-
}
74-
75-
@OptIn(InternalAPI::class)
76-
private suspend fun prepareByteReadChannel(response: HttpResponse): ByteReadChannel {
77-
val bufferSize = response.content.availableForRead
78-
val buffer = ByteBuffer.allocate(bufferSize)
79-
val numberOfBytesRead = response.content.peekTo(Memory(buffer), 0, 0, 0, bufferSize.toLong()).toInt()
80-
val byteReadChannel = ByteReadChannel(buffer.moveToByteArray(), 0, numberOfBytesRead)
81-
return byteReadChannel
82-
}
57+
private suspend fun parseBody(response: HttpResponse): T = getBody(response)
8358
}
8459

8560
internal class ResponseStateFactory {
8661
companion object {
8762
fun <T> getState(
8863
link: String?,
8964
client: Client,
90-
fallbackBody: T,
9165
getBody: suspend (HttpResponse) -> T
92-
): ResponseState<T> = link?.let { FetchLinkState(it, client, fallbackBody, getBody) } ?: LastResponseState()
66+
): ResponseState<T> = link?.let { FetchLinkState(it, client, getBody) } ?: LastResponseState()
9367
}
9468
}

0 commit comments

Comments
 (0)