Skip to content

Commit

Permalink
MarkingFunctionsFactory.createMarkingFunctions() should not be called…
Browse files Browse the repository at this point in the history
… as a static initializer (#2288)
  • Loading branch information
billoley committed Feb 29, 2024
1 parent d45df0f commit 8679dc2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Expand Up @@ -35,7 +35,6 @@ public class CSVRecordReader extends CSVReaderBase implements EventFixer {
private static final Logger log = Logger.getLogger(CSVRecordReader.class);

private static final IngestConfiguration ingestConfig = IngestConfigurationFactory.getIngestConfiguration();
private static final MarkingFunctions markingFunctions = MarkingFunctionsFactory.createMarkingFunctions();

protected String csvEventId;
private final Multimap<String,Object> metadataForValidation = ArrayListMultimap.create(100, 1);
Expand Down Expand Up @@ -128,7 +127,7 @@ protected void decorateEvent() {
if (null != this.securityMarkings && !this.securityMarkings.isEmpty()) {
event.setSecurityMarkings(securityMarkings);
try {
event.setVisibility(markingFunctions.translateToColumnVisibility(securityMarkings));
event.setVisibility(MarkingFunctionsFactory.createMarkingFunctions().translateToColumnVisibility(securityMarkings));
} catch (MarkingFunctions.Exception e) {
log.error("Could not set default ColumnVisibility for the event", e);
throw new RuntimeException(e);
Expand Down
Expand Up @@ -23,10 +23,8 @@ public abstract class AttributeBag<T extends Comparable<T>> extends Attribute<T>

private static final long ONE_DAY_MS = 1000l * 60 * 60 * 24;

protected static final MarkingFunctions markingFunctions = MarkingFunctionsFactory.createMarkingFunctions();

public MarkingFunctions getMarkingFunctions() {
return markingFunctions;
return MarkingFunctionsFactory.createMarkingFunctions();
}

protected AttributeBag() {
Expand Down Expand Up @@ -83,7 +81,7 @@ protected ColumnVisibility combineAndSetColumnVisibilities(Collection<Attribute<
for (Attribute<?> attr : attributes) {
columnVisibilities.add(attr.getColumnVisibility());
}
return AttributeBag.markingFunctions.combine(columnVisibilities);
return MarkingFunctionsFactory.createMarkingFunctions().combine(columnVisibilities);
}

private long updateTimestamps() {
Expand Down
Expand Up @@ -44,8 +44,6 @@ public class CacheableQueryRowImpl extends CacheableQueryRow implements ObjectSi
private String queryOrigin = null;
private String resultOrigin = null;

private static final MarkingFunctions markingFunctions = MarkingFunctionsFactory.createMarkingFunctions();

public void addColumn(String columnName, String columnValueString, Map<String,String> markings, String columnVisibility, Long timestamp) {
addColumn(columnName, new TypedValue(columnValueString), markings, columnVisibility, timestamp);
}
Expand All @@ -57,6 +55,7 @@ public void addColumn(String columnName, TypedValue columnTypedValue, Map<String
// if new markings are the same as the old markings, skip all of this
// they are the same and the markings value has already been validated
if (this.markings.equals(markings) == false) {
MarkingFunctions markingFunctions = MarkingFunctionsFactory.createMarkingFunctions();
if (this.markings.isEmpty()) {
// validate the markings
try {
Expand Down Expand Up @@ -138,6 +137,7 @@ private void manageColumnInsert(Type<?> datawaveType, String columnName, TypedVa

if (currMarkings.equals(markings) == false) {
try {
MarkingFunctions markingFunctions = MarkingFunctionsFactory.createMarkingFunctions();
Set<ColumnVisibility> columnVisibilities = Sets.newHashSet();
columnVisibilities.add(markingFunctions.translateToColumnVisibility(currMarkings));
columnVisibilities.add(markingFunctions.translateToColumnVisibility(markings));
Expand Down Expand Up @@ -293,6 +293,7 @@ public void setColFam(String colFam) {
public void setMarkings(Map<String,String> markings) {
// validate the markings
try {
MarkingFunctions markingFunctions = MarkingFunctionsFactory.createMarkingFunctions();
markingFunctions.translateToColumnVisibility(markings);
this.markings = markings;
} catch (MarkingFunctions.Exception e) {
Expand Down

0 comments on commit 8679dc2

Please sign in to comment.