You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/12/21 12:59:18 UTC
(camel) branch main updated: camel-geocoder - Fix potential NPE if no data
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 0eceb328241 camel-geocoder - Fix potential NPE if no data
0eceb328241 is described below
commit 0eceb3282413765d4d7adf3108e23305d80a9e68
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Dec 21 13:59:05 2023 +0100
camel-geocoder - Fix potential NPE if no data
---
.../camel/component/geocoder/GeoCoderNominatimProducer.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java
index 7194b3f66bd..fc7c4137e68 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java
+++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java
@@ -153,10 +153,12 @@ public class GeoCoderNominatimProducer extends DefaultProducer {
}
private void setLatLngToExchangeHeader(String resLat, String resLng, Exchange exchange) {
- exchange.getIn().setHeader(GeoCoderConstants.LAT, formatLatOrLon(resLat));
- exchange.getIn().setHeader(GeoCoderConstants.LNG, formatLatOrLon(resLng));
- String resLatlng = formatLatOrLon(resLat) + ", " + formatLatOrLon(resLng);
- exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng);
+ if (resLat != null && resLng != null) {
+ exchange.getIn().setHeader(GeoCoderConstants.LAT, formatLatOrLon(resLat));
+ exchange.getIn().setHeader(GeoCoderConstants.LNG, formatLatOrLon(resLng));
+ String resLatlng = formatLatOrLon(resLat) + ", " + formatLatOrLon(resLng);
+ exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng);
+ }
}
private void extractCountry(DocumentContext doc, Message in) {