Skip to content

Commit 244c633

Browse files
committed
remove dependency on spotbugs annotations as we don't want stuff like
that embedded at runtime. An XML configuration file should be used instead.
1 parent 7525f65 commit 244c633

39 files changed

+462
-514
lines changed

net.lecousin.core/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@
5858
<version>4.12</version>
5959
<scope>test</scope>
6060
</dependency>
61-
<dependency>
62-
<groupId>com.github.spotbugs</groupId>
63-
<artifactId>spotbugs-annotations</artifactId>
64-
<scope>compile</scope>
65-
</dependency>
6661
</dependencies>
6762

6863
<build>

net.lecousin.core/src/main/java/net/lecousin/framework/adapter/AdapterRegistry.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.Collection;
55
import java.util.LinkedList;
66

7-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
87
import net.lecousin.framework.plugins.ExtensionPoint;
98

109
/**
@@ -19,7 +18,6 @@ public class AdapterRegistry implements ExtensionPoint<Adapter> {
1918
public static AdapterRegistry get() { return instance; }
2019

2120
/** Constructor called by the extension points system. */
22-
@SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
2321
public AdapterRegistry() {
2422
if (instance != null) return;
2523
instance = this;

net.lecousin.core/src/main/java/net/lecousin/framework/application/Application.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import java.util.concurrent.Executors;
1818
import java.util.concurrent.ThreadFactory;
1919

20-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
21-
2220
import net.lecousin.framework.application.libraries.LibrariesManager;
2321
import net.lecousin.framework.application.libraries.classpath.DefaultLibrariesManager;
2422
import net.lecousin.framework.concurrent.Console;
@@ -140,7 +138,6 @@ public void setProperty(String name, String value) {
140138
properties.put(name, value);
141139
}
142140

143-
@SuppressFBWarnings("EI_EXPOSE_REP")
144141
public Map<String,String> getApplicationSpecificProperties() {
145142
return properties;
146143
}
@@ -153,7 +150,6 @@ public Console getConsole() {
153150
return console;
154151
}
155152

156-
@SuppressFBWarnings("UG_SYNC_SET_UNSYNC_GET")
157153
public Locale getLocale() {
158154
return locale;
159155
}
@@ -170,7 +166,6 @@ public LocalizedProperties getLocalizedProperties() {
170166
return localizedProperties;
171167
}
172168

173-
@SuppressFBWarnings("EI_EXPOSE_REP")
174169
public String[] getLanguageTag() {
175170
return languageTag;
176171
}

net.lecousin.core/src/main/java/net/lecousin/framework/application/LCCore.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import java.io.Closeable;
44

5-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
65
import net.lecousin.framework.application.libraries.LibrariesManager;
76
import net.lecousin.framework.collections.TurnArray;
87
import net.lecousin.framework.concurrent.Task;
98
import net.lecousin.framework.log.Logger;
109
import net.lecousin.framework.memory.MemoryManager;
10+
import net.lecousin.framework.mutable.MutableBoolean;
1111
import net.lecousin.framework.util.AsyncCloseable;
1212

1313
/**
@@ -129,13 +129,13 @@ public static boolean isStopping() {
129129
}
130130

131131
/** Stop the environement. */
132-
@SuppressFBWarnings("NN_NAKED_NOTIFY")
133-
public static void stop(boolean forceJvmToStop) {
132+
public static MutableBoolean stop(boolean forceJvmToStop) {
134133
if (stop != null) {
135134
new Exception("LCCore already stopped", stop).printStackTrace(System.err);
136-
return;
135+
return new MutableBoolean(true);
137136
}
138137
stop = new Exception("LCCore stop requested here");
138+
MutableBoolean stopped = new MutableBoolean(false);
139139
new Thread("Stopping LCCore") {
140140
@Override
141141
public void run() {
@@ -147,8 +147,13 @@ public void run() {
147147
System.out.println("Stop JVM.");
148148
System.exit(0);
149149
}
150+
synchronized (stopped) {
151+
stopped.set(true);
152+
stopped.notifyAll();
153+
}
150154
}
151155
}.start();
156+
return stopped;
152157
}
153158

154159
/**

net.lecousin.core/src/main/java/net/lecousin/framework/application/StandaloneLCCore.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import java.util.List;
1010
import java.util.Map;
1111

12-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13-
1412
import net.lecousin.framework.LCCoreVersion;
1513
import net.lecousin.framework.application.libraries.LibrariesManager;
1614
import net.lecousin.framework.concurrent.DrivesTaskManager.DrivesProvider;
@@ -76,7 +74,6 @@ public void setDrivesProvider(DrivesProvider provider) {
7674
drivesProvider = provider;
7775
}
7876

79-
@SuppressFBWarnings("MS_SHOULD_BE_FINAL")
8077
public static long logThreadingInterval = 30000;
8178

8279
@Override
Lines changed: 98 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,98 @@
1-
package net.lecousin.framework.application;
2-
3-
import java.util.ArrayList;
4-
5-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
6-
7-
/**
8-
* A version is composed of several numbers, separated by a dot,
9-
* and optionally can end with text such as 'beta', 'snapshot'...
10-
* It is built from a String and can be compared based on the numbers (but not the ending string).
11-
*/
12-
public class Version implements Comparable<Version> {
13-
14-
/** Parse the given String to build a Version. */
15-
public Version(String s) {
16-
ArrayList<Integer> n = new ArrayList<Integer>();
17-
int val = 0;
18-
boolean hasChar = false;
19-
int i;
20-
for (i = 0; i < s.length(); ++i) {
21-
char c = s.charAt(i);
22-
if (c >= '0' && c <= '9') {
23-
val = val * 10 + (c - '0');
24-
hasChar = true;
25-
continue;
26-
}
27-
if (c == '.') {
28-
n.add(Integer.valueOf(val));
29-
val = 0;
30-
hasChar = false;
31-
continue;
32-
}
33-
if (hasChar)
34-
n.add(Integer.valueOf(val));
35-
end = s.substring(i);
36-
break;
37-
}
38-
if (i == s.length()) n.add(Integer.valueOf(val));
39-
numbers = new int[n.size()];
40-
for (i = 0; i < n.size(); ++i)
41-
numbers[i] = n.get(i).intValue();
42-
}
43-
44-
private int[] numbers;
45-
private String end;
46-
47-
@SuppressFBWarnings("EI_EXPOSE_REP")
48-
public int[] getNumbers() { return numbers; }
49-
50-
@Override
51-
public int compareTo(Version o) {
52-
return compare(this.numbers, o.numbers);
53-
}
54-
55-
@Override
56-
public int hashCode() {
57-
int hash = 0;
58-
for (int i = 0; i < numbers.length; ++i)
59-
hash = hash * 100 + numbers[i];
60-
return hash;
61-
}
62-
63-
@Override
64-
public boolean equals(Object obj) {
65-
if (!(obj instanceof Version)) return false;
66-
return compare(numbers, ((Version)obj).numbers) == 0;
67-
}
68-
69-
/** Compare 2 arrays of integers containing versions. */
70-
public static int compare(int[] v1, int[] v2) {
71-
int i = 0;
72-
do {
73-
if (v1.length <= i) {
74-
if (v2.length <= i) return 0;
75-
return -1;
76-
} else
77-
if (v2.length <= i) return 1;
78-
if (v1[i] < v2[i]) return -1;
79-
if (v1[i] > v2[i]) return 1;
80-
i++;
81-
} while (true);
82-
}
83-
84-
@Override
85-
public String toString() {
86-
StringBuilder s = new StringBuilder();
87-
toString(numbers, s);
88-
if (end != null)
89-
s.append(end);
90-
return s.toString();
91-
}
92-
93-
/** Append the given version numbers to the given StringBuilder. */
94-
public static void toString(int[] v, StringBuilder s) {
95-
for (int i = 0; i < v.length; ++i) {
96-
if (i > 0) s.append('.');
97-
s.append(Integer.toString(v[i]));
98-
}
99-
}
100-
101-
}
1+
package net.lecousin.framework.application;
2+
3+
import java.util.ArrayList;
4+
5+
/**
6+
* A version is composed of several numbers, separated by a dot,
7+
* and optionally can end with text such as 'beta', 'snapshot'...
8+
* It is built from a String and can be compared based on the numbers (but not the ending string).
9+
*/
10+
public class Version implements Comparable<Version> {
11+
12+
/** Parse the given String to build a Version. */
13+
public Version(String s) {
14+
ArrayList<Integer> n = new ArrayList<Integer>();
15+
int val = 0;
16+
boolean hasChar = false;
17+
int i;
18+
for (i = 0; i < s.length(); ++i) {
19+
char c = s.charAt(i);
20+
if (c >= '0' && c <= '9') {
21+
val = val * 10 + (c - '0');
22+
hasChar = true;
23+
continue;
24+
}
25+
if (c == '.') {
26+
n.add(Integer.valueOf(val));
27+
val = 0;
28+
hasChar = false;
29+
continue;
30+
}
31+
if (hasChar)
32+
n.add(Integer.valueOf(val));
33+
end = s.substring(i);
34+
break;
35+
}
36+
if (i == s.length()) n.add(Integer.valueOf(val));
37+
numbers = new int[n.size()];
38+
for (i = 0; i < n.size(); ++i)
39+
numbers[i] = n.get(i).intValue();
40+
}
41+
42+
private int[] numbers;
43+
private String end;
44+
45+
public int[] getNumbers() { return numbers; }
46+
47+
@Override
48+
public int compareTo(Version o) {
49+
return compare(this.numbers, o.numbers);
50+
}
51+
52+
@Override
53+
public int hashCode() {
54+
int hash = 0;
55+
for (int i = 0; i < numbers.length; ++i)
56+
hash = hash * 100 + numbers[i];
57+
return hash;
58+
}
59+
60+
@Override
61+
public boolean equals(Object obj) {
62+
if (!(obj instanceof Version)) return false;
63+
return compare(numbers, ((Version)obj).numbers) == 0;
64+
}
65+
66+
/** Compare 2 arrays of integers containing versions. */
67+
public static int compare(int[] v1, int[] v2) {
68+
int i = 0;
69+
do {
70+
if (v1.length <= i) {
71+
if (v2.length <= i) return 0;
72+
return -1;
73+
} else
74+
if (v2.length <= i) return 1;
75+
if (v1[i] < v2[i]) return -1;
76+
if (v1[i] > v2[i]) return 1;
77+
i++;
78+
} while (true);
79+
}
80+
81+
@Override
82+
public String toString() {
83+
StringBuilder s = new StringBuilder();
84+
toString(numbers, s);
85+
if (end != null)
86+
s.append(end);
87+
return s.toString();
88+
}
89+
90+
/** Append the given version numbers to the given StringBuilder. */
91+
public static void toString(int[] v, StringBuilder s) {
92+
for (int i = 0; i < v.length; ++i) {
93+
if (i > 0) s.append('.');
94+
s.append(Integer.toString(v[i]));
95+
}
96+
}
97+
98+
}

net.lecousin.core/src/main/java/net/lecousin/framework/application/libraries/artifacts/maven/MavenSettings.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@
99
import javax.xml.stream.XMLStreamConstants;
1010
import javax.xml.stream.XMLStreamReader;
1111

12+
/**
13+
* Information parsed from the settings.xml file for Maven.
14+
*/
1215
public class MavenSettings {
1316

1417
public String localRepository = null;
1518
public ArrayList<String> activeProfiles = new ArrayList<>();
1619

20+
/** Load a settings file. */
1721
public static MavenSettings load(File file) throws Exception {
1822
try (FileInputStream input = new FileInputStream(file)) {
1923
return load(input);
2024
}
2125
}
2226

27+
/** Load a settings file. */
2328
public static MavenSettings load(InputStream input) throws Exception {
2429
XMLStreamReader xml = XMLInputFactory.newFactory().createXMLStreamReader(input);
2530
while (xml.hasNext()) {

net.lecousin.core/src/main/java/net/lecousin/framework/application/libraries/classpath/DefaultLibrariesManager.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import java.util.LinkedList;
1111
import java.util.List;
1212

13-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
14-
1513
import net.lecousin.framework.application.Application;
1614
import net.lecousin.framework.application.libraries.LibrariesManager;
1715
import net.lecousin.framework.concurrent.Task;
@@ -45,7 +43,6 @@ public DefaultLibrariesManager() {
4543
}
4644

4745
@SuppressWarnings("unchecked")
48-
@SuppressFBWarnings("DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED")
4946
@Override
5047
public DefaultApplicationClassLoader start(Application app) {
5148
this.app = app;

net.lecousin.core/src/main/java/net/lecousin/framework/collections/ArrayIterator.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import java.lang.reflect.Array;
44
import java.util.NoSuchElementException;
55

6-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
7-
86
/**
97
* Iterate on an array. It does not support the remove method.
108
* @param <T> type of elements
@@ -15,14 +13,12 @@ public class ArrayIterator<T> implements java.util.Iterator<T> {
1513
* @param array the array
1614
* @param max number of elements in the array to iterate on
1715
*/
18-
@SuppressFBWarnings("EI_EXPOSE_REP2")
1916
public ArrayIterator(T[] array, int max) {
2017
this.array = array;
2118
this.max = max;
2219
}
2320

2421
/** Constructor. */
25-
@SuppressFBWarnings("EI_EXPOSE_REP2")
2622
public ArrayIterator(T[] array) {
2723
this.array = array;
2824
this.max = array.length;

0 commit comments

Comments
 (0)