github-advanced-security[bot] commented on code in PR #841:
URL: 
https://github.com/apache/incubator-baremaps/pull/841#discussion_r1512585144


##########
baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/xml/XmlChangeSpliterator.java:
##########
@@ -155,8 +155,10 @@
   private Node readNode() throws XMLStreamException {
     long id = Long.parseLong(reader.getAttributeValue(null, 
ATTRIBUTE_NAME_ID));
     Info info = readInfo();
-    double lat = Double.parseDouble(reader.getAttributeValue(null, 
ATTRIBUTE_NAME_LATITUDE));
-    double lon = Double.parseDouble(reader.getAttributeValue(null, 
ATTRIBUTE_NAME_LONGITUDE));
+    var latAttribute = reader.getAttributeValue(null, ATTRIBUTE_NAME_LATITUDE);
+    var lonAttribute = reader.getAttributeValue(null, 
ATTRIBUTE_NAME_LONGITUDE);
+    var latValue = latAttribute != null ? Double.parseDouble(latAttribute) : 
Double.NaN;

Review Comment:
   ## Missing catch of NumberFormatException
   
   Potential uncaught 'java.lang.NumberFormatException'.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/990)



##########
baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/repository/ChangeElementsImporter.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.baremaps.openstreetmap.repository;
+
+
+import java.util.function.Consumer;
+import org.apache.baremaps.openstreetmap.model.Change;
+import org.apache.baremaps.openstreetmap.model.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** A consumer for importing change nodes in a database. */
+public class ChangeElementsImporter<T extends Element> implements 
Consumer<Change> {
+
+  private static final Logger logger = 
LoggerFactory.getLogger(ChangeElementsImporter.class);
+
+  private final Class<T> type;
+
+  private final Repository<Long, T> nodeRepository;
+
+  /**
+   * Constructs a {@code ChangeNodesImporter}.
+   *
+   * @param nodeRepository the node repository
+   */
+  public ChangeElementsImporter(
+      Class<T> type,
+      Repository<Long, T> nodeRepository) {
+    this.type = type;
+    this.nodeRepository = nodeRepository;
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void accept(Change change) {
+    switch (change.getType()) {

Review Comment:
   ## Missing enum case in switch
   
   Switch statement does not have a case for [MODIFY](1).
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/992)



##########
baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/xml/XmlChangeSpliterator.java:
##########
@@ -155,8 +155,10 @@
   private Node readNode() throws XMLStreamException {
     long id = Long.parseLong(reader.getAttributeValue(null, 
ATTRIBUTE_NAME_ID));
     Info info = readInfo();
-    double lat = Double.parseDouble(reader.getAttributeValue(null, 
ATTRIBUTE_NAME_LATITUDE));
-    double lon = Double.parseDouble(reader.getAttributeValue(null, 
ATTRIBUTE_NAME_LONGITUDE));
+    var latAttribute = reader.getAttributeValue(null, ATTRIBUTE_NAME_LATITUDE);
+    var lonAttribute = reader.getAttributeValue(null, 
ATTRIBUTE_NAME_LONGITUDE);
+    var latValue = latAttribute != null ? Double.parseDouble(latAttribute) : 
Double.NaN;
+    var lonValue = lonAttribute != null ? Double.parseDouble(lonAttribute) : 
Double.NaN;

Review Comment:
   ## Missing catch of NumberFormatException
   
   Potential uncaught 'java.lang.NumberFormatException'.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/991)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to