Merge pull request #689 from zod/pmd-7

Update PMD to 7.0.0
This commit is contained in:
afischerdev 2024-04-17 20:19:52 +02:00 committed by GitHub
commit 36e169ab48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
63 changed files with 193 additions and 207 deletions

View file

@ -20,10 +20,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

View file

@ -16,10 +16,10 @@ jobs:
environment: BRouter
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Create local.properties

2
.gitignore vendored
View file

@ -1,6 +1,7 @@
*.iml
.gradle
.idea/
build
/local.properties
/.idea/caches
/.idea/gradle.xml
@ -10,7 +11,6 @@
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx

View file

@ -1 +0,0 @@
/build/

View file

@ -1,8 +1,7 @@
plugins {
id 'java-library'
id 'brouter.library-conventions'
}
dependencies {
implementation project(':brouter-util')
testImplementation 'junit:junit:4.13.1'
}

View file

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="btools.codec" />

View file

@ -1,6 +1,7 @@
package btools.codec;
import java.util.HashMap;
import java.util.Map;
import btools.util.ByteDataReader;
import btools.util.IByteArrayUnifier;
@ -287,7 +288,7 @@ public final class MicroCache2 extends MicroCache {
@Override
public int encodeMicroCache(byte[] buffer) {
HashMap<Long, Integer> idMap = new HashMap<>();
Map<Long, Integer> idMap = new HashMap<>();
for (int n = 0; n < size; n++) { // loop over nodes
idMap.put(expandId(faid[n]), n);
}
@ -418,7 +419,7 @@ public final class MicroCache2 extends MicroCache {
nlinks++;
if (isInternal) {
int nodeIdx = idx.intValue();
int nodeIdx = idx;
if (dodebug) System.out.println("*** target nodeIdx=" + nodeIdx);
if (nodeIdx == n) throw new RuntimeException("ups: self ref?");
nodeIdxDiff.encodeSignedValue(nodeIdx - n);

View file

@ -4,6 +4,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import btools.util.BitCoderContext;
@ -58,7 +59,7 @@ public final class TagValueCoder {
TagValueSet dummy = new TagValueSet(nextTagValueSetId++);
identityMap.put(dummy, dummy);
}
PriorityQueue<TagValueSet> queue = new PriorityQueue<>(2 * identityMap.size(), new TagValueSet.FrequencyComparator());
Queue<TagValueSet> queue = new PriorityQueue<>(2 * identityMap.size(), new TagValueSet.FrequencyComparator());
queue.addAll(identityMap.values());
while (queue.size() > 1) {
TagValueSet node = new TagValueSet(nextTagValueSetId++);

View file

@ -1 +0,0 @@
/build/

View file

@ -1,5 +1,5 @@
plugins {
id 'java-library'
id 'brouter.library-conventions'
}
dependencies {
@ -7,7 +7,6 @@ dependencies {
implementation project(':brouter-util')
implementation project(':brouter-expressions')
implementation project(':brouter-codec')
testImplementation 'junit:junit:4.13.2'
}
// MapcreatorTest generates segments which are used in tests

View file

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="btools.router" />

View file

@ -168,7 +168,7 @@ public class OsmNogoPolygon extends OsmNodeNamed {
Point p1 = points.get(0);
for (int i = 1; i <= i_last; i++) {
final Point p2 = points.get(i);
if (OsmNogoPolygon.isOnLine(px, py, p1.x, p1.y, p2.x, p2.y)) {
if (isOnLine(px, py, p1.x, p1.y, p2.x, p2.y)) {
return true;
}
p1 = p2;
@ -234,7 +234,7 @@ public class OsmNogoPolygon extends OsmNodeNamed {
final long p1x = p1.x;
final long p1y = p1.y;
if (OsmNogoPolygon.isOnLine(px, py, p0x, p0y, p1x, p1y)) {
if (isOnLine(px, py, p0x, p0y, p1x, p1y)) {
return true;
}

View file

@ -296,7 +296,7 @@ abstract class OsmPath implements OsmLinkHolder {
// apply a start-direction if appropriate (by faking the origin position)
if (isStartpoint) {
if (rc.startDirectionValid) {
double dir = rc.startDirection.intValue() * CheapRuler.DEG_TO_RAD;
double dir = rc.startDirection * CheapRuler.DEG_TO_RAD;
double[] lonlat2m = CheapRuler.getLonLatToMeterScales((lon0 + lat1) >> 1);
lon0 = lon1 - (int) (1000. * Math.sin(dir) / lonlat2m[0]);
lat0 = lat1 - (int) (1000. * Math.cos(dir) / lonlat2m[1]);

View file

@ -166,7 +166,7 @@ public final class OsmTrack {
}
public List<String> aggregateMessages() {
ArrayList<String> res = new ArrayList<>();
List<String> res = new ArrayList<>();
MessageData current = null;
for (OsmPathElement n : nodes) {
if (n.message != null && n.message.wayKeyValues != null) {
@ -188,7 +188,7 @@ public final class OsmTrack {
}
public List<String> aggregateSpeedProfile() {
ArrayList<String> res = new ArrayList<>();
List<String> res = new ArrayList<>();
int vmax = -1;
int vmaxe = -1;
int vmin = -1;

View file

@ -187,7 +187,7 @@ public class RoutingEngine extends Thread {
OsmTrack[] refTracks = new OsmTrack[nsections]; // used ways for alternatives
OsmTrack[] lastTracks = new OsmTrack[nsections];
OsmTrack track = null;
ArrayList<String> messageList = new ArrayList<>();
List<String> messageList = new ArrayList<>();
for (int i = 0; ; i++) {
track = findTrack(refTracks, lastTracks);
track.message = "track-length = " + track.distance + " filtered ascend = " + track.ascend
@ -690,9 +690,9 @@ public class RoutingEngine extends Thread {
return false;
}
}
ArrayList<OsmPathElement> removeBackList = new ArrayList<>();
ArrayList<OsmPathElement> removeForeList = new ArrayList<>();
ArrayList<Integer> removeVoiceHintList = new ArrayList<>();
List<OsmPathElement> removeBackList = new ArrayList<>();
List<OsmPathElement> removeForeList = new ArrayList<>();
List<Integer> removeVoiceHintList = new ArrayList<>();
OsmPathElement last = null;
OsmPathElement lastJunction = null;
CompactLongMap<OsmTrack.OsmPathElementHolder> lastJunctions = new CompactLongMap<>();
@ -1246,7 +1246,7 @@ public class RoutingEngine extends Thread {
addToOpenset(startPath1);
addToOpenset(startPath2);
}
ArrayList<OsmPath> openBorderList = new ArrayList<>(4096);
List<OsmPath> openBorderList = new ArrayList<>(4096);
boolean memoryPanicMode = false;
boolean needNonPanicProcessing = false;

View file

@ -101,7 +101,7 @@ public class RoutingParamCollector {
* @throws UnsupportedEncodingException
*/
public Map<String, String> getUrlParams(String url) throws UnsupportedEncodingException {
HashMap<String, String> params = new HashMap<>();
Map<String, String> params = new HashMap<>();
String decoded = URLDecoder.decode(url, "UTF-8");
StringTokenizer tk = new StringTokenizer(decoded, "?&");
while (tk.hasMoreTokens()) {

View file

@ -1 +0,0 @@
/build/

View file

@ -1,9 +1,8 @@
plugins {
id 'java-library'
id 'brouter.library-conventions'
}
dependencies {
implementation project(':brouter-util')
implementation project(':brouter-codec')
testImplementation 'junit:junit:4.13.1'
}

View file

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="btools.expressions" />

View file

@ -242,15 +242,15 @@ final class BExpression {
}
// parse operands
if (nops > 0) {
exp.op1 = BExpression.parse(ctx, level + 1, exp.typ == ASSIGN_EXP ? "=" : null);
exp.op1 = parse(ctx, level + 1, exp.typ == ASSIGN_EXP ? "=" : null);
}
if (nops > 1) {
if (ifThenElse) checkExpectedToken(ctx, "then");
exp.op2 = BExpression.parse(ctx, level + 1, null);
exp.op2 = parse(ctx, level + 1, null);
}
if (nops > 2) {
if (ifThenElse) checkExpectedToken(ctx, "else");
exp.op3 = BExpression.parse(ctx, level + 1, null);
exp.op3 = parse(ctx, level + 1, null);
}
if (brackets) {
checkExpectedToken(ctx, ")");

View file

@ -14,6 +14,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
@ -227,7 +228,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
}
public List<String> getKeyValueList(boolean inverseDirection, byte[] ab) {
ArrayList<String> res = new ArrayList<>();
List<String> res = new ArrayList<>();
decode(lookupData, inverseDirection, ab);
for (int inum = 0; inum < lookupValues.size(); inum++) { // loop over lookup names
BExpressionLookupValue[] va = lookupValues.get(inum);
@ -245,7 +246,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
public int getLookupKey(String name) {
int res = -1;
try {
res = lookupNumbers.get(name).intValue();
res = lookupNumbers.get(name);
} catch (Exception e) {
}
return res;
@ -433,11 +434,11 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
public void dumpStatistics() {
TreeMap<String, String> counts = new TreeMap<>();
NavigableMap<String, String> counts = new TreeMap<>();
// first count
for (String name : lookupNumbers.keySet()) {
int cnt = 0;
int inum = lookupNumbers.get(name).intValue();
int inum = lookupNumbers.get(name);
int[] histo = lookupHistograms.get(inum);
// if ( histo.length == 500 ) continue;
for (int i = 2; i < histo.length; i++) {
@ -450,7 +451,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
String key = counts.lastEntry().getKey();
String name = counts.get(key);
counts.remove(key);
int inum = lookupNumbers.get(name).intValue();
int inum = lookupNumbers.get(name);
BExpressionLookupValue[] values = lookupValues.get(inum);
int[] histo = lookupHistograms.get(inum);
if (values.length == 1000) continue;
@ -507,7 +508,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
public String variableName(int idx) {
for (Map.Entry<String, Integer> e : variableNumbers.entrySet()) {
if (e.getValue().intValue() == idx) {
if (e.getValue() == idx) {
return e.getKey();
}
}
@ -544,9 +545,8 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
}
// look for that value
int inum = num.intValue();
BExpressionLookupValue[] values = lookupValues.get(inum);
int[] histo = lookupHistograms.get(inum);
BExpressionLookupValue[] values = lookupValues.get(num);
int[] histo = lookupHistograms.get(num);
int i = 0;
boolean bFoundAsterix = false;
for (; i < values.length; i++) {
@ -558,7 +558,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
if (lookupData2 != null) {
// do not create unknown value for external data array,
// record as 'unknown' instead
lookupData2[inum] = 1; // 1 == unknown
lookupData2[num] = 1; // 1 == unknown
if (bFoundAsterix) {
// found value for lookup *
//System.out.println( "add unknown " + name + " " + value );
@ -652,11 +652,11 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
// found negative maxdraft values
// no negative values
// values are float with 2 decimals
lookupData2[inum] = 1000 + (int) (Math.abs(Float.parseFloat(value)) * 100f);
lookupData2[num] = 1000 + (int) (Math.abs(Float.parseFloat(value)) * 100f);
} catch (Exception e) {
// ignore errors
System.err.println("error for " + name + " " + org + " trans " + value + " " + e.getMessage());
lookupData2[inum] = 0;
lookupData2[num] = 0;
}
}
return newValue;
@ -677,15 +677,15 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
histo = nhisto;
newValue = new BExpressionLookupValue(value);
values[i] = newValue;
lookupHistograms.set(inum, histo);
lookupValues.set(inum, values);
lookupHistograms.set(num, histo);
lookupValues.set(num, values);
}
histo[i]++;
// finally remember the actual data
if (lookupData2 != null) lookupData2[inum] = i;
else lookupData[inum] = i;
if (lookupData2 != null) lookupData2[num] = i;
else lookupData[num] = i;
return newValue;
}
@ -700,11 +700,10 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
}
// look for that value
int inum = num.intValue();
int nvalues = lookupValues.get(inum).length;
int nvalues = lookupValues.get(num).length;
if (valueIndex < 0 || valueIndex >= nvalues)
throw new IllegalArgumentException("value index out of range for name " + name + ": " + valueIndex);
lookupData[inum] = valueIndex;
lookupData[num] = valueIndex;
}
@ -721,9 +720,8 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
}
// look for that value
int inum = num.intValue();
int nvalues = lookupValues.get(inum).length;
int oldValueIndex = lookupData[inum];
int nvalues = lookupValues.get(num).length;
int oldValueIndex = lookupData[num];
if (oldValueIndex > 1 && oldValueIndex < valueIndex) {
return;
}
@ -732,12 +730,12 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
}
if (valueIndex < 0)
throw new IllegalArgumentException("value index out of range for name " + name + ": " + valueIndex);
lookupData[inum] = valueIndex;
lookupData[num] = valueIndex;
}
public boolean getBooleanLookupValue(String name) {
Integer num = lookupNumbers.get(name);
return num != null && lookupData[num.intValue()] == 2;
return num != null && lookupData[num] == 2;
}
public int getOutputVariableIndex(String name, boolean mustExist) {
@ -849,7 +847,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
public void setVariableValue(String name, float value, boolean create) {
Integer num = variableNumbers.get(name);
if (num != null) {
variableData[num.intValue()] = value;
variableData[num] = value;
} else if (create) {
num = getVariableIdx(name, create);
float[] readOnlyData = variableData;
@ -858,13 +856,13 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
for (int i = 0; i < minWriteIdx; i++) {
variableData[i] = readOnlyData[i];
}
variableData[num.intValue()] = value;
variableData[num] = value;
}
}
public float getVariableValue(String name, float defaultValue) {
Integer num = variableNumbers.get(name);
return num == null ? defaultValue : getVariableValue(num.intValue());
return num == null ? defaultValue : getVariableValue(num);
}
float getVariableValue(int variableIdx) {
@ -882,7 +880,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
return -1;
}
}
return num.intValue();
return num;
}
int getMinWriteIdx() {
@ -900,7 +898,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
public int getLookupNameIdx(String name) {
Integer num = lookupNumbers.get(name);
return num == null ? -1 : num.intValue();
return num == null ? -1 : num;
}
public final void markLookupIdxUsed(int idx) {

View file

@ -1 +0,0 @@
/build/

View file

@ -1,5 +1,5 @@
plugins {
id 'java-library'
id 'brouter.application-conventions'
}
dependencies {
@ -8,6 +8,4 @@ dependencies {
implementation project(':brouter-expressions')
implementation group: 'org.openstreetmap.osmosis', name: 'osmosis-osm-binary', version: '0.48.3'
testImplementation('junit:junit:4.13.1')
}

View file

@ -184,10 +184,10 @@ public class CreateElevationRasterImage {
if (DEBUG) System.out.println(line);
String[] sa = line.split(",");
if (!line.startsWith("#") && sa.length == 4) {
short e = Short.valueOf(sa[0].trim());
short r = Short.valueOf(sa[1].trim());
short g = Short.valueOf(sa[2].trim());
short b = Short.valueOf(sa[3].trim());
short e = Short.parseShort(sa[0].trim());
short r = Short.parseShort(sa[1].trim());
short g = Short.parseShort(sa[2].trim());
short b = Short.parseShort(sa[3].trim());
colorMap.put(e, new Color(r, g, b));
}
// read next line

View file

@ -90,7 +90,6 @@ public class ElevationRasterTileConverter {
} else {
System.out.println("usage: java <srtm-filename> <hgt-data-dir> <srtm-output-dir> [arc seconds (1 or 3,default=3)] [hgt-fallback-data-dir]");
System.out.println("or java all <hgt-data-dir> <srtm-output-dir> [arc seconds (1 or 3, default=3)] [hgt-fallback-data-dir]");
return;
}
}

View file

@ -8,6 +8,8 @@ package btools.mapcreator;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import btools.codec.MicroCache;
import btools.codec.MicroCache2;
@ -105,7 +107,7 @@ public class OsmNodeP extends OsmLinkP {
}
public void checkDuplicateTargets() {
HashMap<OsmNodeP, OsmLinkP> targets = new HashMap<>();
Map<OsmNodeP, OsmLinkP> targets = new HashMap<>();
for (OsmLinkP link0 = getFirstLink(); link0 != null; link0 = link0.getNext(this)) {
OsmLinkP link = link0;
@ -165,14 +167,14 @@ public class OsmNodeP extends OsmLinkP {
mc.writeVarBytes(getNodeDecsription());
// buffer internal reverse links
ArrayList<OsmNodeP> internalReverse = new ArrayList<>();
List<OsmNodeP> internalReverse = new ArrayList<>();
for (OsmLinkP link0 = getFirstLink(); link0 != null; link0 = link0.getNext(this)) {
OsmLinkP link = link0;
OsmNodeP origin = this;
OsmNodeP target = null;
ArrayList<OsmNodeP> linkNodes = new ArrayList<>();
List<OsmNodeP> linkNodes = new ArrayList<>();
linkNodes.add(this);
// first pass just to see if that link is consistent
@ -226,7 +228,7 @@ public class OsmNodeP extends OsmLinkP {
origin = this;
for (int i = 1; i < linkNodes.size() - 1; i++) {
OsmNodeP tranferNode = linkNodes.get(i);
if ((tranferNode.bits & OsmNodeP.DP_SURVIVOR_BIT) != 0) {
if ((tranferNode.bits & DP_SURVIVOR_BIT) != 0) {
mc.writeVarLengthSigned(tranferNode.ilon - origin.ilon);
mc.writeVarLengthSigned(tranferNode.ilat - origin.ilat);
mc.writeVarLengthSigned(tranferNode.getSElev() - origin.getSElev());

View file

@ -4,6 +4,7 @@ import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
/**
* WayCutter does 2 step in map-processing:
@ -25,7 +26,7 @@ public class RelationStatistics extends MapCreatorBase {
}
public void process(File relationFileIn) throws Exception {
HashMap<String, long[]> relstats = new HashMap<>();
Map<String, long[]> relstats = new HashMap<>();
DataInputStream dis = createInStream(relationFileIn);
try {

View file

@ -9,6 +9,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.RandomAccessFile;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import btools.codec.DataBuffers;
@ -481,7 +482,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
MicroCache mc = new MicroCache2(size, abBuf2, lonIdxDiv, latIdxDiv, divisor);
// sort via treemap
TreeMap<Integer, OsmNodeP> sortedList = new TreeMap<>();
Map<Integer, OsmNodeP> sortedList = new TreeMap<>();
for (OsmNodeP n : subList) {
long longId = n.getIdFromPos();
int shrinkid = mc.shrinkId(longId);

View file

@ -1 +0,0 @@
/build/

View file

@ -1,12 +1,11 @@
plugins {
id 'java-library'
id 'brouter.library-conventions'
}
dependencies {
implementation project(':brouter-util')
implementation project(':brouter-codec')
implementation project(':brouter-expressions')
testImplementation 'junit:junit:4.13.2'
}
// MapcreatorTest generates segments which are used in tests

View file

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="btools.mapaccess" />

View file

@ -31,7 +31,6 @@ final class OsmFile {
private int divisor;
private int cellsize;
private int ncaches;
private int indexsize;
protected byte elevationType = 3;
@ -47,7 +46,7 @@ final class OsmFile {
elevationType = rafile.elevationType;
cellsize = 1000000 / divisor;
ncaches = divisor * divisor;
int ncaches = divisor * divisor;
indexsize = ncaches * 4;
byte[] iobuffer = dataBuffers.iobuffer;

View file

@ -21,7 +21,7 @@ public class OsmNodePairSet {
n2a = new long[maxTempNodes];
}
private static class OsmNodePair {
private static final class OsmNodePair {
public long node2;
public OsmNodePair next;
}

View file

@ -51,7 +51,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
}
// sort result list
comparator = new Comparator<MatchedWaypoint>() {
comparator = new Comparator<>() {
@Override
public int compare(MatchedWaypoint mw1, MatchedWaypoint mw2) {
int cmpDist = Double.compare(mw1.radius, mw2.radius);

View file

@ -1 +0,0 @@
/build/

View file

@ -2,6 +2,8 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
plugins {
id 'com.android.application'
id 'checkstyle'
id 'brouter.version-conventions'
}
android {
@ -51,7 +53,7 @@ android {
buildTypes {
release {
minifyEnabled false
minifyEnabled true
debuggable false
if (project.hasProperty("RELEASE_STORE_FILE") && RELEASE_STORE_FILE.length() > 0) {
signingConfig signingConfigs.release
@ -74,6 +76,10 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
aidl true
buildConfig true
}
applicationVariants.all {
variant ->
@ -84,6 +90,11 @@ android {
}
}
repositories {
mavenCentral()
google()
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation "androidx.constraintlayout:constraintlayout:2.1.4"

View file

@ -1 +0,0 @@
/build/

View file

@ -1,13 +1,10 @@
plugins {
id 'application'
id 'brouter.application-conventions'
}
application {
mainClass.set('btools.server.BRouter')
distTar.enabled = false
jar {
manifest {
attributes "Main-Class": getMainClass(), "Implementation-Version": project.version
@ -35,6 +32,7 @@ application {
distZip {
dependsOn fatJar
if (file('../local.properties').exists()) dependsOn (':brouter-routing-app:assemble')
archiveFileName = 'brouter-' + project.version + '.zip'
}
@ -77,6 +75,5 @@ dependencies {
implementation project(':brouter-mapaccess')
implementation project(':brouter-util')
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.json:json:20180813'
}

View file

@ -15,7 +15,7 @@ public class IpAccessMonitor {
synchronized (sync) {
Long lastTime = ipAccess.get(ip);
ipAccess.put(ip, t);
return lastTime == null || t - lastTime.longValue() > MAX_IDLE;
return lastTime == null || t - lastTime > MAX_IDLE;
}
}
@ -31,9 +31,9 @@ public class IpAccessMonitor {
}
private static void cleanup(long t) {
HashMap<String, Long> newMap = new HashMap<>(ipAccess.size());
Map<String, Long> newMap = new HashMap<>(ipAccess.size());
for (Map.Entry<String, Long> e : ipAccess.entrySet()) {
if (t - e.getValue().longValue() <= MAX_IDLE) {
if (t - e.getValue() <= MAX_IDLE) {
newMap.put(e.getKey(), e.getValue());
}
}

View file

@ -3,6 +3,7 @@ package btools.server;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class Polygon {
@ -15,7 +16,7 @@ public class Polygon {
private int maxy = Integer.MIN_VALUE;
public Polygon(BufferedReader br) throws IOException {
ArrayList<String> lines = new ArrayList<>();
List<String> lines = new ArrayList<>();
for (; ; ) {
String line = br.readLine();

View file

@ -21,6 +21,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.zip.GZIPOutputStream;
@ -299,7 +300,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
ProfileCache.setSize(2 * maxthreads);
PriorityQueue<RouteServer> threadQueue = new PriorityQueue<>();
Queue<RouteServer> threadQueue = new PriorityQueue<>();
ServerSocket serverSocket = args.length > 5 ? new ServerSocket(Integer.parseInt(args[3]), 100, InetAddress.getByName(args[5])) : new ServerSocket(Integer.parseInt(args[3]));
@ -364,7 +365,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
private static Map<String, String> getUrlParams(String url) throws UnsupportedEncodingException {
HashMap<String, String> params = new HashMap<>();
Map<String, String> params = new HashMap<>();
String decoded = URLDecoder.decode(url, "UTF-8");
StringTokenizer tk = new StringTokenizer(decoded, "?&");
while (tk.hasMoreTokens()) {
@ -417,7 +418,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
bw.write("\n");
}
private static void cleanupThreadQueue(PriorityQueue<RouteServer> threadQueue) {
private static void cleanupThreadQueue(Queue<RouteServer> threadQueue) {
for (; ; ) {
boolean removedItem = false;
for (RouteServer t : threadQueue) {

View file

@ -9,6 +9,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
@ -244,7 +245,7 @@ public class SuspectManager extends Thread {
bw.write("<table>\n");
File countryParent = new File("worldpolys" + country);
File[] files = countryParent.listFiles();
TreeSet<String> names = new TreeSet<>();
Set<String> names = new TreeSet<>();
for (File f : files) {
String name = f.getName();
if (name.endsWith(".poly")) {

View file

@ -37,7 +37,7 @@ public class ProfileUploadHandler {
String id;
if (profileId != null) {
// update existing file when id appended
id = profileId.substring(ProfileUploadHandler.CUSTOM_PREFIX.length());
id = profileId.substring(CUSTOM_PREFIX.length());
} else {
id = "" + System.currentTimeMillis();
}

View file

@ -5,6 +5,7 @@ import org.junit.Ignore;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import btools.router.RoutingContext;
import btools.server.request.ServerHandler;
@ -13,7 +14,7 @@ public class RequestHandlerTest {
@Test
@Ignore("Parameters are currently handled by RouteServer, not RequestHandler")
public void parseParameters() {
HashMap<String, String> params = new HashMap<>();
Map<String, String> params = new HashMap<>();
params.put("lonlats", "8.799297,49.565883|8.811764,49.563606");
params.put("profile", "trekking");
params.put("alternativeidx", "0");

View file

@ -1 +0,0 @@
/build/

View file

@ -1,7 +1,3 @@
plugins {
id 'java-library'
}
dependencies {
testImplementation('junit:junit:4.13.1')
id 'brouter.library-conventions'
}

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.btools</groupId>
<artifactId>brouter</artifactId>
<version>1.6.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>brouter-util</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="btools.util" />

View file

@ -9,6 +9,7 @@ import java.util.List;
*
* @author ab
*/
@SuppressWarnings("PMD.LooseCoupling")
public class LazyArrayOfLists<E> {
private List<ArrayList<E>> lists;

View file

@ -51,12 +51,12 @@ public class StackSampler extends Thread {
try {
int wait1 = rand.nextInt(interval);
int wait2 = interval - wait1;
Thread.sleep(wait1);
sleep(wait1);
StringBuilder sb = new StringBuilder(df.format(new Date()) + " THREADDUMP\n");
Map<Thread, StackTraceElement[]> allThreads = Thread.getAllStackTraces();
Map<Thread, StackTraceElement[]> allThreads = getAllStackTraces();
for (Map.Entry<Thread, StackTraceElement[]> e : allThreads.entrySet()) {
Thread t = e.getKey();
if (t == Thread.currentThread()) {
if (t == currentThread()) {
continue; // not me
}
@ -76,7 +76,7 @@ public class StackSampler extends Thread {
flushCnt = 0;
bw.flush();
}
Thread.sleep(wait2);
sleep(wait2);
} catch (Exception e) {
// ignore
}

View file

@ -4,6 +4,7 @@ import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
public class CompactMapTest {
@ -22,7 +23,7 @@ public class CompactMapTest {
private void hashMapComparison(int mapsize, int trycount) {
Random rand = new Random(12345);
HashMap<Long, String> hmap = new HashMap<>();
Map<Long, String> hmap = new HashMap<>();
CompactLongMap<String> cmap_slow = new CompactLongMap<>();
CompactLongMap<String> cmap_fast = new CompactLongMap<>();

View file

@ -5,6 +5,7 @@ import org.junit.Test;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
public class CompactSetTest {
@Test
@ -22,7 +23,7 @@ public class CompactSetTest {
private void hashSetComparison(int setsize, int trycount) {
Random rand = new Random(12345);
HashSet<Long> hset = new HashSet<>();
Set<Long> hset = new HashSet<>();
CompactLongSet cset_slow = new CompactLongSet();
CompactLongSet cset_fast = new CompactLongSet();

View file

@ -5,7 +5,9 @@ import org.junit.Test;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Random;
import java.util.Set;
public class DenseLongMapTest {
@Test
@ -16,7 +18,7 @@ public class DenseLongMapTest {
private void hashMapComparison(int mapsize, int trycount, long keyrange) {
Random rand = new Random(12345);
HashMap<Long, Integer> hmap = new HashMap<>();
Map<Long, Integer> hmap = new HashMap<>();
DenseLongMap dmap = new DenseLongMap(512);
for (int i = 0; i < mapsize; i++) {
@ -32,7 +34,7 @@ public class DenseLongMapTest {
long k = (long) (rand.nextDouble() * keyrange);
Long KK = k;
Integer VV = hmap.get(KK);
int hvalue = VV == null ? -1 : VV.intValue();
int hvalue = VV == null ? -1 : VV;
int dvalue = dmap.getInt(k);
if (hvalue != dvalue) {
@ -48,7 +50,7 @@ public class DenseLongMapTest {
int trycount = 100000;
Random rand = new Random(12345);
HashSet<Long> hset = new HashSet<>();
Set<Long> hset = new HashSet<>();
DenseLongMap dmap = new DenseLongMap(512);
for (int i = 0; i < mapputs; i++) {

View file

@ -1,65 +1,18 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
// NOTE:
// there are four places to change the version number
// this file
// app: build.gradle (versionCode only)
// OsmTrack (version and versionDate)
// docs revisions.md (version and versionDate)
project.version "1.7.4"
group 'org.btools'
repositories {
mavenCentral()
google()
}
apply plugin: "maven-publish"
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/$System.env.REPO")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
}
}
}
publications {
gpr(MavenPublication)
}
}
apply plugin: "checkstyle"
apply plugin: "pmd"
pmd {
consoleOutput = true
toolVersion = "6.51.0"
rulesMinimumPriority = 5
ruleSetFiles = files("${rootProject.rootDir}/config/pmd/pmd-ruleset.xml")
ruleSets = []
// ignoreFailures = true
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

3
buildSrc/build.gradle Normal file
View file

@ -0,0 +1,3 @@
plugins {
id 'groovy-gradle-plugin'
}

View file

@ -0,0 +1,8 @@
plugins {
id 'application'
id 'brouter.java-conventions'
}
application {
distTar.enabled = false
}

View file

@ -0,0 +1,29 @@
plugins {
id 'java'
id 'checkstyle'
id 'pmd'
id 'brouter.version-conventions'
}
group 'org.btools'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'junit:junit:4.13.2'
}
compileJava {
options.release = 11
}
pmd {
consoleOutput = true
toolVersion = '7.0.0'
rulesMinimumPriority = 5
ruleSetFiles = files("${rootProject.rootDir}/config/pmd/pmd-ruleset.xml")
ruleSets = []
// ignoreFailures = true
}

View file

@ -0,0 +1,21 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'brouter.java-conventions'
}
publishing {
repositories {
maven {
name = 'GitHubPackages'
url = uri("https://maven.pkg.github.com/$System.env.REPO")
credentials {
username = project.findProperty('gpr.user') ?: System.getenv('USERNAME')
password = project.findProperty('gpr.key') ?: System.getenv('TOKEN')
}
}
}
publications {
gpr(MavenPublication)
}
}

View file

@ -0,0 +1,7 @@
// NOTE:
// there are four places to change the version number
// this file
// app: build.gradle (versionCode only)
// OsmTrack (version and versionDate)
// docs revisions.md (version and versionDate)
version '1.7.4'

View file

@ -29,6 +29,7 @@
<exclude name="OverrideBothEqualsAndHashcode" />
<exclude name="PreserveStackTrace" />
<exclude name="ReturnEmptyCollectionRatherThanNull" />
<exclude name="SimplifyBooleanReturns" />
<exclude name="UncommentedEmptyConstructor" />
<exclude name="UncommentedEmptyMethodBody" />
<exclude name="UnusedFormalParameter" />
@ -51,7 +52,6 @@
<!-- <rule ref="category/java/bestpractices.xml/UnusedAssignment" /> -->
<rule ref="category/java/codestyle.xml/UseDiamondOperator" />
<!-- <rule ref="category/java/design.xml/ImmutableField" /> -->
<!-- Will be added in PMD 7 -->
<!-- <rule ref="category/java/codestyle.xml/UnnecessaryBoxing" /> -->
<rule ref="category/java/codestyle.xml/UnnecessaryBoxing" />
</ruleset>

View file

@ -17,5 +17,5 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=false
android.nonTransitiveRClass=false
android.nonFinalResIds=false

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip