@@ -86,9 +86,15 @@ public Optional<IpLocObject> apply(RpslObject nicObject) {
8686
8787 // Use a default name if there is no netname
8888 var network = String .join (", " , attributes .getOrDefault ("netname" , List .of ("unknown" )));
89- var geoloc = String .join (", " , attributes .getOrDefault ("geoloc" , List .of ()));
90- var country = String .join (", " , attributes .getOrDefault ("country" , List .of ()));
91- var source = String .join (", " , attributes .getOrDefault ("source" , List .of ()));
89+ var geoloc = attributes .containsKey ("geoloc" )
90+ ? String .join (", " , attributes .getOrDefault ("geoloc" , List .of ()))
91+ : null ;
92+ var country = attributes .containsKey ("country" )
93+ ? String .join (", " , attributes .getOrDefault ("country" , List .of ()))
94+ : null ;
95+ var source = attributes .containsKey ("source" )
96+ ? String .join (", " , attributes .getOrDefault ("source" , List .of ()))
97+ : null ;
9298
9399 // If there is a geoloc field, we use the latitude and longitude provided
94100 if (attributes .containsKey ("geoloc" )) {
@@ -115,8 +121,10 @@ public Optional<IpLocObject> apply(RpslObject nicObject) {
115121 // build a query text string out of the cherry-picked fields
116122 var queryTextBuilder = new StringBuilder ();
117123 for (String field : searchedFields ) {
118- var fieldValue = String .join (", " , attributes .get (field ));
119- if (!Strings .isNullOrEmpty (fieldValue )) {
124+ var value = attributes .containsKey (field )
125+ ? String .join (", " , attributes .getOrDefault (field , List .of ()))
126+ : null ;
127+ if (!Strings .isNullOrEmpty (value )) {
120128 queryTextBuilder .append (attributes .get (field )).append (" " );
121129 }
122130 }
0 commit comments