Skip to content

Commit 5d83fc7

Browse files
committed
WIP fixing errorporne reported errors
1 parent b8556a5 commit 5d83fc7

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

geowebcache/core/src/main/java/org/geowebcache/GeoWebCacheDispatcher.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.net.URL;
2222
import java.nio.channels.Channels;
2323
import java.nio.channels.ReadableByteChannel;
24+
import java.nio.charset.StandardCharsets;
2425
import java.util.ArrayList;
2526
import java.util.HashMap;
2627
import java.util.List;
@@ -285,7 +286,7 @@ public ServletOutputStream getOutputStream() throws IOException {
285286
response,
286287
e.getErrorCode(),
287288
"text/plain",
288-
new ByteArrayResource(e.getMessage().getBytes()),
289+
new ByteArrayResource(e.getMessage().getBytes(StandardCharsets.UTF_8)),
289290
CacheResult.OTHER,
290291
runtimeStats);
291292
} catch (RequestFilterException e) {
@@ -313,7 +314,7 @@ public ServletOutputStream getOutputStream() throws IOException {
313314
response,
314315
403,
315316
"text/plain",
316-
new ByteArrayResource("Not Authorized".getBytes()),
317+
new ByteArrayResource("Not Authorized".getBytes(StandardCharsets.UTF_8)),
317318
CacheResult.OTHER,
318319
runtimeStats);
319320
LOG.warning(e.getMessage());
@@ -377,7 +378,7 @@ private String[] parseRequest(String servletPath) throws GeoWebCacheException {
377378
private void handleServiceRequest(String serviceStr, HttpServletRequest request, HttpServletResponse response)
378379
throws Exception {
379380

380-
Conveyor conv = null;
381+
Conveyor conv;
381382

382383
// 1) Figure out what Service should handle this request
383384
Service service = findService(serviceStr);

geowebcache/core/src/main/java/org/geowebcache/config/GridSetConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public interface GridSetConfiguration extends BaseConfiguration {
2626
/**
2727
* Get a GridSet by name
2828
*
29-
* @throw NoSuchElementException if the named gridset is not available.
29+
* @throws NoSuchElementException if the named gridset is not available.
3030
*/
3131
Optional<GridSet> getGridSet(final String name);
3232

geowebcache/core/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
package org.geowebcache.layer;
1515

1616
import com.google.common.base.Preconditions;
17+
import com.google.common.collect.Iterables;
1718
import java.io.IOException;
1819
import java.util.ArrayList;
19-
import java.util.Collection;
2020
import java.util.Collections;
2121
import java.util.HashSet;
22-
import java.util.LinkedList;
2322
import java.util.List;
2423
import java.util.Map;
2524
import java.util.Map.Entry;
@@ -28,7 +27,6 @@
2827
import java.util.Optional;
2928
import java.util.Set;
3029
import java.util.stream.Collectors;
31-
import java.util.stream.Stream;
3230
import java.util.stream.StreamSupport;
3331
import org.geowebcache.GeoWebCacheException;
3432
import org.geowebcache.GeoWebCacheExtensions;
@@ -65,8 +63,9 @@ public class TileLayerDispatcher
6563
private ApplicationContext applicationContext;
6664

6765
/**
68-
* Used for testing only, in production use {@link #TileLayerDispatcher(GridSetBroker)} instead, configurations are
69-
* loaded from the application context, the {@code config} parameter will be overwritten
66+
* Used for testing only, in production use {@link #TileLayerDispatcher(GridSetBroker, TileLayerDispatcherFilter)}
67+
* instead, configurations are loaded from the application context, the {@code configs} parameter will be
68+
* overwritten
7069
*/
7170
public TileLayerDispatcher(
7271
GridSetBroker gridSetBroker,
@@ -154,13 +153,10 @@ public Iterable<TileLayer> getLayerList() {
154153
*
155154
* @return all layers, but filtered based on the tileLayerDispatcherFilter.
156155
*/
157-
@SuppressWarnings("unchecked")
158156
public Iterable<TileLayer> getLayerListFiltered() {
159157
Iterable<TileLayer> result = getLayerList();
160158
if (tileLayerDispatcherFilter != null) {
161-
Stream s = StreamSupport.stream(result.spliterator(), false)
162-
.filter(x -> !tileLayerDispatcherFilter.exclude(x));
163-
result = s::iterator;
159+
result = Iterables.filter(result, x -> !tileLayerDispatcherFilter.exclude(x));
164160
}
165161
return result;
166162
}
@@ -270,7 +266,7 @@ public synchronized void removeGridSet(String gridsetToRemove) {
270266
}
271267

272268
public synchronized void removeGridSetRecursive(String gridsetToRemove) {
273-
Collection<TileLayer> deletedLayers = new LinkedList<>();
269+
List<TileLayer> deletedLayers = new ArrayList<>();
274270
try {
275271
for (TileLayer tl : getLayerList()) {
276272
if (Objects.nonNull(tl.getGridSubset(gridsetToRemove))) {
@@ -334,6 +330,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
334330
}
335331

336332
/** @deprecated use GeoWebCacheExtensions.reinitializeConfigurations instead */
333+
@Deprecated
337334
public void reInit() { // do not know how to get rid of it, it's used in mock testing...
338335
GeoWebCacheExtensions.reinitialize(this.applicationContext);
339336
}

geowebcache/core/src/main/java/org/geowebcache/stats/RuntimeStats.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class RuntimeStats {
7272
* @param intervalDescs the description for each of the previously defined intervals
7373
*/
7474
public RuntimeStats(int pollInterval, List<Integer> intervals, List<String> intervalDescs) {
75-
this(pollInterval, intervals, intervalDescs, Clock.systemDefaultZone());
75+
this(pollInterval, intervals, intervalDescs, Clock.systemUTC());
7676
}
7777
/**
7878
* @param pollInterval seconds between recording aggregate values
@@ -122,6 +122,8 @@ public void start() {
122122
statsThread.start();
123123
}
124124

125+
@SuppressWarnings(
126+
"ThreadPriorityCheck") // errorprone complaint on Thread.yield(), revisit, might indeed be unnecessary
125127
public void destroy() {
126128
if (this.statsThread != null) {
127129
statsThread.run = false;
@@ -177,18 +179,18 @@ public String getHTMLStats() {
177179

178180
str.append("<tr><th colspan=\"2\" scope=\"row\">Total number of requests:</th><td colspan=\"3\">"
179181
+ totalRequests);
180-
str.append(" (" + totalRequests / (runningTime) + "/s ) ");
182+
str.append(" (" + totalRequests / runningTime + "/s ) ");
181183
str.append("</td></tr>\n");
182184

183185
str.append(
184186
"<tr><th colspan=\"2\" scope=\"row\">Total number of untiled WMS requests:</th><td colspan=\"3\">"
185187
+ totalWMS);
186-
str.append(" (" + totalWMS / (runningTime) + "/s ) ");
188+
str.append(" (" + totalWMS / runningTime + "/s ) ");
187189
str.append("</td></tr>\n");
188190

189191
str.append("<tr><th colspan=\"2\" scope=\"row\">Total number of bytes:</th><td colspan=\"3\">"
190192
+ totalBytes);
191-
str.append(" (" + formatBits((totalBytes * 8.0) / (runningTime)) + ") ");
193+
str.append(" (" + formatBits((totalBytes * 8.0) / runningTime) + ") ");
192194
str.append("</td></tr>\n");
193195

194196
str.append("</tbody>");
@@ -379,7 +381,7 @@ private RuntimeStatsThread(RuntimeStats runtimeStats) {
379381
public void run() {
380382
try {
381383
while (run) {
382-
Thread.sleep(stats.pollInterval * 1000);
384+
Thread.sleep(stats.pollInterval * 1000L);
383385
updateLists();
384386
}
385387
} catch (InterruptedException e) {

geowebcache/core/src/main/java/org/geowebcache/storage/BlobStoreAggregator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public void addConfiguration(BlobStoreConfiguration config) {
7171

7272
/**
7373
* Indicates if this configurations contains a {@link BlobStoreInfo) identified by a given name.
74+
*
7475
* @param blobStoreInfoName the name of a {@link BlobStoreInfo} for which existence is desired.
76+
*
7577
* @return True if a {@link BlobStoreInfo} currently exists with the unique name provided, false otherwise.
7678
*/
7779
public boolean blobStoreExists(final String blobStoreInfoName) {

geowebcache/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@
979979
-Xep:SelfAssertion:OFF \
980980
-Xep:MissingSummary:OFF \
981981
-Xep:StringSplitter:OFF \
982+
-Xep:UnrecognisedJavadocTag:OFF \
982983
${errorProneFlags}</arg>
983984
<arg>-Xlint:${lint}</arg>
984985
<arg>-Werror</arg>

0 commit comments

Comments
 (0)