Skip to content

Commit

Permalink
fix: issue derjust#233 (checks if dynamoDBMapperConfigRef is set befo…
Browse files Browse the repository at this point in the history
…re registering its factory)
  • Loading branch information
[email protected] authored and [email protected] committed Feb 24, 2019
1 parent 2d7fc1e commit 3cbd580
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public DynamoDBMapperFactory() {
}

@Override
public synchronized DynamoDBMapper getObject() throws Exception {
// fix issue #230
public DynamoDBMapper getObject() throws Exception {
return new DynamoDBMapper(amazonDynamoDB, dynamoDBMapperConfig);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -226,10 +227,14 @@ public void registerBeansForRoot(BeanDefinitionRegistry registry,
// Store for later to be used by #postProcess, too
this.registry = registry;

BeanDefinitionBuilder dynamoDBMapperConfigBuiilder = BeanDefinitionBuilder
.genericBeanDefinition(DynamoDBMapperConfigFactory.class);
registry.registerBeanDefinition(getBeanNameWithModulePrefix("DynamoDBMapperConfig"),
dynamoDBMapperConfigBuiilder.getBeanDefinition());
// Fix issue #233
Optional dynamoDBMapperConfigRef = configurationSource.getAttribute("dynamoDBMapperConfigRef");
if (!dynamoDBMapperConfigRef.isPresent()) {
BeanDefinitionBuilder dynamoDBMapperConfigBuiilder = BeanDefinitionBuilder
.genericBeanDefinition(DynamoDBMapperConfigFactory.class);
registry.registerBeanDefinition(getBeanNameWithModulePrefix("DynamoDBMapperConfig"),
dynamoDBMapperConfigBuiilder.getBeanDefinition());
}

BeanDefinitionBuilder dynamoDBMapperBuilder = BeanDefinitionBuilder
.genericBeanDefinition(DynamoDBMapperFactory.class);
Expand Down

0 comments on commit 3cbd580

Please sign in to comment.