Skip to content

Commit fe1971e

Browse files
Fix null projectId
1 parent 24ecfcd commit fe1971e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/radarcns/RestructureAvroRecords.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,13 @@ private void writeRecord(GenericRecord record, String topicName, FileCacheStore
266266
Date time = getDate(keyField, valueField);
267267
java.nio.file.Path outputFileName = createFilename(time);
268268

269-
// Clean Project id for use in final pathname
270-
String projectId = keyField.get("projectId").toString().replaceAll("[^a-zA-Z0-9_-]+", "");
269+
String projectId;
271270

272-
if (projectId == null) {
271+
if(keyField.get("projectId") == null) {
273272
projectId = "unknown-project";
273+
} else {
274+
// Clean Project id for use in final pathname
275+
projectId = keyField.get("projectId").toString().replaceAll("[^a-zA-Z0-9_-]+", "");
274276
}
275277

276278
// Clean user id and create final output pathname

0 commit comments

Comments
 (0)