Skip to content

Properly write out data given by entity field mapping #434

@ckittl

Description

@ckittl

/**
* Actually persisting the provided entity field data
*
* @param entityFieldData a mapping of an entity instance fields to their values
* @throws IOException If writing has failed
* @throws SinkException If the data does not meet the pre-defined head line
*/
public synchronized void write(Map<String, String> entityFieldData)
throws IOException, SinkException {
/* Check against eligible head line elements */
if (entityFieldData.size() != headLineElements.length
|| !entityFieldData.keySet().containsAll(Arrays.asList(headLineElements)))
throw new SinkException(
"The provided data does not meet the pre-defined head line elements '"
+ String.join(",", headLineElements)
+ "'.");
String[] entries = entityFieldData.values().toArray(new String[0]);
writeOneLine(entries);
}

Current implementation of write method exhibits wrong behavior. It assumes, that the map entries are given in the same order as the headline elements. However, this is not always the case and especially not the behavior, that one would expect. This possibly leads to data errors, where you can't spot a swapped column (because both are numerical and of same range).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions