Skip to content

Commit 533f47a

Browse files
committed
Fixes potential NPE on clearing attributes
Signed-off-by: Christopher Grote <[email protected]>
1 parent bfe5987 commit 533f47a

File tree

1 file changed

+21
-26
lines changed
  • package-toolkit/runtime/src/main/kotlin/com/atlan/pkg/serde/csv

1 file changed

+21
-26
lines changed

package-toolkit/runtime/src/main/kotlin/com/atlan/pkg/serde/csv/CSVImporter.kt

+21-26
Original file line numberDiff line numberDiff line change
@@ -200,36 +200,31 @@ abstract class CSVImporter(
200200
Serde.getAssetClassForType(candidate.typeName),
201201
field.atlanFieldName,
202202
)
203-
val value = getter.invoke(candidate)
204-
if (value == null ||
205-
(Collection::class.java.isAssignableFrom(value.javaClass) && (value as Collection<*>).isEmpty())
206-
) {
207-
builder.nullField(field.atlanFieldName)
208-
return true
203+
if (getter == null) {
204+
logger.warn {
205+
"Field ${field.atlanFieldName} not known on ${candidate.typeName} -- skipping clearing it."
206+
}
207+
} else {
208+
val value = getter.invoke(candidate)
209+
if (value == null ||
210+
(Collection::class.java.isAssignableFrom(value.javaClass) && (value as Collection<*>).isEmpty())
211+
) {
212+
builder.nullField(field.atlanFieldName)
213+
return true
214+
}
209215
}
210216
} catch (e: ClassNotFoundException) {
211-
logger.error(
212-
"Unknown type {} — cannot clear {}.",
213-
candidate.typeName,
214-
field.atlanFieldName,
215-
e,
216-
)
217+
logger.error(e) {
218+
"Unknown type ${candidate.typeName} — cannot clear ${field.atlanFieldName}."
219+
}
217220
} catch (e: IllegalAccessException) {
218-
logger.error(
219-
"Unable to clear {} on: {}::{}",
220-
field.atlanFieldName,
221-
candidate.typeName,
222-
candidate.qualifiedName,
223-
e,
224-
)
221+
logger.error(e) {
222+
"Unable to clear ${field.atlanFieldName} on: ${candidate.typeName}::${candidate.qualifiedName}"
223+
}
225224
} catch (e: InvocationTargetException) {
226-
logger.error(
227-
"Unable to clear {} on: {}::{}",
228-
field.atlanFieldName,
229-
candidate.typeName,
230-
candidate.qualifiedName,
231-
e,
232-
)
225+
logger.error(e) {
226+
"Unable to clear ${field.atlanFieldName} on: ${candidate.typeName}::${candidate.qualifiedName}"
227+
}
233228
}
234229
return false
235230
}

0 commit comments

Comments
 (0)