Skip to content

Commit aa000e5

Browse files
committed
Apply the AlternatorEndpointProvider only on custom endpoints
The previous implementation was failing when used on AWS DynamoDB because `conf.get(DynamoDBConstants.ENDPOINT)` was `null`. This was not caught by our tests because our tests always use a custom endpoint (see #113)
1 parent b9be9fb commit aa000e5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

migrator/src/main/scala/com/scylladb/migrator/DynamoUtils.scala

+8-4
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,14 @@ object DynamoUtils {
293293
class AlternatorLoadBalancingEnabler extends DynamoDbClientBuilderTransformer with Configurable {
294294
private var conf: Configuration = null
295295

296-
override def apply(builder: DynamoDbClientBuilder): DynamoDbClientBuilder =
297-
builder.endpointProvider(
298-
new AlternatorEndpointProvider(URI.create(conf.get(DynamoDBConstants.ENDPOINT)))
299-
)
296+
override def apply(builder: DynamoDbClientBuilder): DynamoDbClientBuilder = {
297+
for (customEndpoint <- Option(conf.get(DynamoDBConstants.ENDPOINT))) {
298+
builder.endpointProvider(
299+
new AlternatorEndpointProvider(URI.create(customEndpoint))
300+
)
301+
}
302+
builder
303+
}
300304

301305
override def setConf(configuration: Configuration): Unit =
302306
conf = configuration

0 commit comments

Comments
 (0)