Skip to content
Snippets Groups Projects

Fixing Concurrency Issues with TypeMapper

Closed Sabarish K R E requested to merge sabz/typeMapperConcurrencyFix into master
1 unresolved thread
3 files
+ 137
29
Compare changes
  • Side-by-side
  • Inline
Files
3
  • test case demonstrating a thread-unsafe operation of IndexerMappingServiceImpl.getIndexMappingFromRecordSchema(..) and the fix for that
    
    # Conflicts:
    #	indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerMappingServiceImpl.java
@@ -149,9 +149,9 @@ public class IndexerMappingServiceImpl extends MappingServiceImpl implements IMa
}
for (Map.Entry<String, Object> entry : schema.getMetaSchema().entrySet()) {
if (entry.getKey() == RecordMetaAttribute.AUTHORITY.getValue()) {
if (RecordMetaAttribute.AUTHORITY.getValue().equals(entry.getKey())) {
metaMapping.put(entry.getKey(), TypeMapper.getMetaAttributeIndexerMapping(entry.getKey(), kind.getAuthority()));
} else if (entry.getKey() == RecordMetaAttribute.SOURCE.getValue()) {
} else if (RecordMetaAttribute.SOURCE.getValue().equals(entry.getKey())) {
metaMapping.put(entry.getKey(), TypeMapper.getMetaAttributeIndexerMapping(entry.getKey(), kind.getSource()));
} else {
metaMapping.put(entry.getKey(), TypeMapper.getMetaAttributeIndexerMapping(entry.getKey(), null));
@@ -206,9 +206,10 @@ public class IndexerMappingServiceImpl extends MappingServiceImpl implements IMa
Map<String, Object> properties = new HashMap<>();
Kind kind = new Kind(schema.getKind());
for (String attribute : missing) {
if (attribute == RecordMetaAttribute.AUTHORITY.getValue()) {
if (RecordMetaAttribute.AUTHORITY.getValue().equals(attribute)) {
properties.put(attribute, TypeMapper.getMetaAttributeIndexerMapping(attribute, kind.getAuthority()));
} else if (attribute == RecordMetaAttribute.SOURCE.getValue()) {
log.info(String.format("Syncing Index Mapping for kind %s, Authority %s", schema.getKind(), kind.getAuthority(), index));
} else if (RecordMetaAttribute.SOURCE.getValue().equals(attribute)) {
properties.put(attribute, TypeMapper.getMetaAttributeIndexerMapping(attribute, kind.getSource()));
} else {
properties.put(attribute, TypeMapper.getMetaAttributeIndexerMapping(attribute, null));
Loading