Skip to content

Commit 47b3922

Browse files
authored
Fix some issues detected by sonar (#870)
* Correctly skip bytes * Suppress warning on controlled input * Improve exception handling * Fix issues reported by sonar * Format code with spotless * Suppress some warnings * Fix sonar issues and clean code
1 parent c259a2d commit 47b3922

File tree

32 files changed

+379
-300
lines changed

32 files changed

+379
-300
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.baremaps.cli;
19+
20+
21+
/** Signals that an exception occurred in the {@link Baremaps} CLI. */
22+
public class BaremapsException extends RuntimeException {
23+
24+
/** Constructs a {@link BaremapsException} with {@code null} as its error detail message. */
25+
public BaremapsException() {}
26+
27+
/**
28+
* Constructs an {@link BaremapsException} with the specified detail message.
29+
*
30+
* @param message the message
31+
*/
32+
public BaremapsException(String message) {
33+
super(message);
34+
}
35+
36+
/**
37+
* Constructs a {@link BaremapsException} with the specified cause.
38+
*
39+
* @param cause the cause
40+
*/
41+
public BaremapsException(Throwable cause) {
42+
super(cause);
43+
}
44+
45+
/**
46+
* Constructs a {@link BaremapsException} with the specified detail message and cause.
47+
*
48+
* @param message the message
49+
* @param cause the cause
50+
*/
51+
public BaremapsException(String message, Throwable cause) {
52+
super(message, cause);
53+
}
54+
}

baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.nio.file.Path;
3131
import java.util.concurrent.Callable;
3232
import java.util.function.Supplier;
33+
import org.apache.baremaps.cli.BaremapsException;
3334
import org.apache.baremaps.cli.Options;
3435
import org.apache.baremaps.config.ConfigReader;
3536
import org.apache.baremaps.maplibre.style.Style;
@@ -88,7 +89,7 @@ public Integer call() throws Exception {
8889
var config = configReader.read(tilesetPath);
8990
return objectMapper.readValue(config, Tileset.class);
9091
} catch (IOException e) {
91-
throw new RuntimeException(e);
92+
throw new BaremapsException(e);
9293
}
9394
};
9495

@@ -102,7 +103,7 @@ public Integer call() throws Exception {
102103
var config = configReader.read(stylePath);
103104
return objectMapper.readValue(config, Style.class);
104105
} catch (IOException e) {
105-
throw new RuntimeException(e);
106+
throw new BaremapsException(e);
106107
}
107108
};
108109

baremaps-core/src/main/java/org/apache/baremaps/database/DiffService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ public class DiffService implements Callable<List<TileCoord>> {
5858
public DiffService(
5959
Map<Long, Coordinate> coordinateMap,
6060
Map<Long, List<Long>> referenceMap,
61-
HeaderRepository headerRepository, Repository<Long, Node> nodeRepository,
62-
Repository<Long, Way> wayRepository, Repository<Long, Relation> relationRepository, int srid,
61+
HeaderRepository headerRepository,
62+
Repository<Long, Node> nodeRepository,
63+
Repository<Long, Way> wayRepository,
64+
Repository<Long, Relation> relationRepository,
65+
int srid,
6366
int zoom) {
6467
this.coordinateMap = coordinateMap;
6568
this.referenceMap = referenceMap;

0 commit comments

Comments
 (0)