CSV export 루프를 Java에서 Groovy로 옮겼는데, 이제 nickname이 없는 row에서 작업이 죽어요. Java FieldEncoder에는 encode 오버로드가 세 개(String, Number, Collection) 있고, null은 토큰 NULL로 바뀌어야 해요. 예전 Java 코드에서는 encoder.encode(user.getNickname())가 null이어도 잘 동작했어요.
Groovy 쪽 코드예요:
def cells = COLUMNS.collect { col -> encoder.encode(row[col]) }
3번째 row에는 nickname 키가 없어요. 에러 첫 줄에 ambiguous method overloading이라고 나오고, 인자 목록은 [null]이에요. row[col]을 찍어 보면 null이라고 나와서 map은 정상으로 보여요. nullToken도 바꿔 봤는데 달라진 게 없어요.
Groovy 4.0.22가 없는 키에 대해 이상한 걸 반환하는 건가요, 아니면 null token 옵션을 지원하지 않는 건가요? 왜 Java는 여기서 null을 처리하는데 Groovy는 못 하는 거예요?
도와주시면 감사하겠습니다.
영어에서 번역·원문 보기I moved my CSV export loop from Java to Groovy and now the job dies on the row with missing nickname. Java FieldEncoder has three encode overloads (String, Number, Collection), and null should become token NULL. In old Java code encoder.encode(user.getNickname()) works fine with null.
Groovy side:
def cells = COLUMNS.collect { col -> encoder.encode(row[col]) }
Row 3 has no nickname key. First line of the error say ambiguous method overloading, and the argument list is [null]. I print row[col] and it show null, so map looks normal. I also changed nullToken, no difference.
Is Groovy 4.0.22 returning something strange for missing key, or not supporting the null token option? Why Java handle null here but Groovy cannot?
Thanks for any help.