Skip to content

Commit 5cc9873

Browse files
convert #36466 to kotlin
1 parent 0f658ff commit 5cc9873

File tree

1 file changed

+12
-5
lines changed
  • airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/kotlin/io/airbyte/cdk/integrations/destination/jdbc/typing_deduping

1 file changed

+12
-5
lines changed

airbyte-cdk/java/airbyte-cdk/db-destinations/src/main/kotlin/io/airbyte/cdk/integrations/destination/jdbc/typing_deduping/JdbcDestinationHandler.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import java.time.Instant
2222
import java.time.OffsetDateTime
2323
import java.time.temporal.ChronoUnit
2424
import java.util.*
25+
import java.util.HashMap
2526
import java.util.concurrent.CompletableFuture
2627
import java.util.concurrent.CompletionStage
2728
import java.util.function.Predicate
@@ -254,12 +255,18 @@ abstract class JdbcDestinationHandler<DestinationState>(
254255
// This is to handle any destinations that upcase the column names.
255256
// For example - Snowflake with QUOTED_IDENTIFIERS_IGNORE_CASE=TRUE.
256257
val record = recordJson as ObjectNode
257-
record.fieldNames().forEachRemaining { fieldName: String ->
258-
record.set<JsonNode>(
259-
fieldName.lowercase(Locale.getDefault()),
260-
record[fieldName]
261-
)
258+
val newFields: HashMap<String, JsonNode> = HashMap()
259+
260+
val it = record.fieldNames()
261+
while (it.hasNext()) {
262+
val fieldName = it.next()
263+
// We can't directly call record.set here, because that will raise a
264+
// ConcurrentModificationException on the fieldnames iterator.
265+
// Instead, build up a map of new fields and set them all at once.
266+
newFields.put(fieldName.lowercase(Locale.getDefault()), record[fieldName])
262267
}
268+
269+
record.setAll<JsonNode>(newFields)
263270
}
264271
.collect(
265272
toMap(

0 commit comments

Comments
 (0)