From 8d37f4251023d5a22bf55b39374840d5ccddcf6b Mon Sep 17 00:00:00 2001 From: Andrea Aime Date: Sun, 9 Jun 2024 18:52:03 +0200 Subject: [PATCH 1/3] Updating PMD to 7.2.0, mostly cleaning up unecessary type specs and empty statements --- ...nLayerConformanceWithArcGisLayersTest.java | 4 +-- .../org/geowebcache/azure/AzureBlobStore.java | 6 ++-- .../org/geowebcache/azure/DeleteManager.java | 2 +- .../geowebcache/config/DefaultGridsets.java | 29 ++--------------- .../geowebcache/config/FileBlobStoreInfo.java | 2 +- .../org/geowebcache/conveyor/Conveyor.java | 4 +-- .../org/geowebcache/io/ByteArrayResource.java | 8 ++--- .../java/org/geowebcache/io/FileResource.java | 7 ++-- .../org/geowebcache/io/TreeSetConverter.java | 2 +- .../layer/TileLayerDispatcher.java | 2 +- .../layer/meta/VectorLayerMetadata.java | 2 +- .../org/geowebcache/layer/wms/WMSLayer.java | 2 +- .../java/org/geowebcache/mime/ImageMime.java | 4 +-- .../java/org/geowebcache/seed/GWCTask.java | 4 +-- .../java/org/geowebcache/seed/SeedTask.java | 8 ++--- .../geowebcache/storage/StorageObject.java | 2 +- .../geowebcache/storage/TransientCache.java | 2 +- .../blobstore/file/TileFileVisitor.java | 4 +-- .../blobstore/file/XYZFilePathGenerator.java | 2 +- .../org/geowebcache/util/ExceptionUtils.java | 2 +- .../org/geowebcache/util/ServletUtils.java | 4 +-- .../java/org/geowebcache/TestHelpers.java | 1 + .../geowebcache/config/ConfigurationTest.java | 2 +- ...tsConfigurationGridsetConformanceTest.java | 4 +-- ...ConfigurationBlobStoreConformanceTest.java | 4 +-- ...MLConfigurationGridsetConformanceTest.java | 4 +-- .../XMLConfigurationLayerConformanceTest.java | 4 +-- .../parameters/ParametersUtilsTest.java | 2 +- .../org/geowebcache/seed/SeedTaskTest.java | 2 +- .../org/geowebcache/util/FileMatchers.java | 14 ++++---- .../geowebcache/util/MockWMSSourceHelper.java | 5 --- .../geowebcache/util/SetSingletonRule.java | 4 +-- .../java/org/geowebcache/util/TestUtils.java | 8 ++--- .../diskquota/BDBQuotaStoreTest.java | 2 +- .../geowebcache/diskquota/CacheCleaner.java | 1 - .../rest/controller/DiskQuotaController.java | 4 +-- .../diskquota/jdbc/SQLDialect.java | 32 +++++++++---------- .../org/geowebcache/georss/GeoRSSPoller.java | 2 +- .../geowebcache/service/kml/KMLService.java | 2 +- .../geowebcache/service/kml/KMZHelper.java | 16 +++++----- .../mbtiles/layer/MBTilesInfo.java | 4 +-- geowebcache/pmd-junit-ruleset.xml | 2 +- geowebcache/pmd-ruleset.xml | 6 ++-- geowebcache/pom.xml | 5 ++- .../rest/controller/BlobStoreController.java | 2 +- .../rest/controller/BoundsController.java | 4 +-- .../rest/controller/ByteStreamController.java | 4 +-- .../controller/FilterUpdateController.java | 2 +- .../rest/controller/GridSetController.java | 2 +- .../controller/MassTruncateController.java | 4 +-- .../rest/controller/ReloadController.java | 4 +-- .../rest/controller/SeedController.java | 6 ++-- .../rest/controller/ServerController.java | 2 +- .../rest/controller/TileLayerController.java | 6 ++-- .../geowebcache/rest/service/FormService.java | 4 +-- .../java/org/geowebcache/s3/S3BlobStore.java | 2 +- .../geowebcache/sqlite/MbtilesBlobStore.java | 4 ++- .../sqlite/OperationsRestTest.java | 2 +- .../org/geowebcache/swift/SwiftBlobStore.java | 2 +- .../geowebcache/service/wms/WMSService.java | 1 + .../geowebcache/service/wms/WMSTileFuser.java | 4 +-- ...esGridSetConfigurationConformanceTest.java | 4 +-- .../service/wmts/WMTSServiceTest.java | 22 ++++++------- 63 files changed, 140 insertions(+), 173 deletions(-) diff --git a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java index 127fc7e1d..101bc4290 100644 --- a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java +++ b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java @@ -122,7 +122,7 @@ public ConveyorTile doNonMetatilingRequest(ConveyorTile tile) @Override protected Matcher infoEquals(TileLayer expected) { - return new CustomMatcher( + return new CustomMatcher<>( "ArcGISCacheLayer matching " + expected.getName() + " with " @@ -140,7 +140,7 @@ public boolean matches(Object item) { @Override protected Matcher infoEquals(int expected) { - return new CustomMatcher("ArcGISCacheLayer with value" + expected) { + return new CustomMatcher<>("ArcGISCacheLayer with value" + expected) { @Override public boolean matches(Object item) { diff --git a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureBlobStore.java b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureBlobStore.java index 3a9eada75..abde0fabc 100644 --- a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureBlobStore.java +++ b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureBlobStore.java @@ -207,7 +207,7 @@ public boolean delete(TileRange tileRange) throws StorageException { // open an iterator oer tile locations, to avoid memory accumulation final Iterator tileLocations = - new AbstractIterator() { + new AbstractIterator<>() { // TileRange iterator with 1x1 meta tiling factor private TileRangeIterator trIter = @@ -405,7 +405,7 @@ public boolean removeListener(BlobStoreListener listener) { @Override public boolean rename(String oldLayerName, String newLayerName) throws StorageException { log.fine("No need to rename layers, AzureBlobStore uses layer id as key root"); - if (client.listBlobs(oldLayerName, 1).size() > 0) { + if (!client.listBlobs(oldLayerName, 1).isEmpty()) { listeners.sendLayerRenamed(oldLayerName, newLayerName); } return true; @@ -443,7 +443,7 @@ private Properties getLayerMetadata(String layerName) { @Override public boolean layerExists(String layerName) { final String coordsPrefix = keyBuilder.forLayer(layerName); - return client.listBlobs(coordsPrefix, 1).size() > 0; + return !client.listBlobs(coordsPrefix, 1).isEmpty(); } @Override diff --git a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/DeleteManager.java b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/DeleteManager.java index aaa1e585e..efce89a94 100644 --- a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/DeleteManager.java +++ b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/DeleteManager.java @@ -199,7 +199,7 @@ public void issuePendingBulkDeletes() throws StorageException { public synchronized boolean asyncDelete(String prefix, long timestamp) { // do we have anything to delete? - if (client.listBlobs(prefix, 1).size() == 0) { + if (client.listBlobs(prefix, 1).isEmpty()) { return false; } diff --git a/geowebcache/core/src/main/java/org/geowebcache/config/DefaultGridsets.java b/geowebcache/core/src/main/java/org/geowebcache/config/DefaultGridsets.java index a9dc751e1..905fb0f4f 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/config/DefaultGridsets.java +++ b/geowebcache/core/src/main/java/org/geowebcache/config/DefaultGridsets.java @@ -424,7 +424,7 @@ public DefaultGridsets(boolean useEPSG900913, boolean useGWC11xNames) { 266.144470692553, 133.072235346276, 66.5361176731382, - 33.2680588365691, + 33.2680588365691 }; // the 60 UTM zones from the OGC TMS specification @@ -441,32 +441,7 @@ public DefaultGridsets(boolean useEPSG900913, boolean useGWC11xNames) { 20003931.4586255), true, null, - new double[] { - 279072704.500914, - 139536352.250457, - 69768176.1252285, - 34884088.0626143, - 17442044.0313071, - 8721022.01565356, - 4360511.00782678, - 2180255.50391339, - 1090127.7519567, - 545063.875978348, - 272531.937989174, - 136265.968994587, - 68132.9844972935, - 34066.4922486467, - 17033.2461243234, - 8516.62306216168, - 4258.31153108084, - 2129.15576554042, - 1064.57788277021, - 532.288941385105, - 266.144470692553, - 133.072235346276, - 66.5361176731382, - 33.2680588365691 - }, + UTM_SCALES, 1d, GridSetFactory.DEFAULT_PIXEL_SIZE_METER, new String[] { diff --git a/geowebcache/core/src/main/java/org/geowebcache/config/FileBlobStoreInfo.java b/geowebcache/core/src/main/java/org/geowebcache/config/FileBlobStoreInfo.java index 789dd88fd..8f89e4b45 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/config/FileBlobStoreInfo.java +++ b/geowebcache/core/src/main/java/org/geowebcache/config/FileBlobStoreInfo.java @@ -37,7 +37,7 @@ public static enum PathGeneratorType { DEFAULT, TMS, SLIPPY - }; + } private static final long serialVersionUID = -6470560864068854508L; diff --git a/geowebcache/core/src/main/java/org/geowebcache/conveyor/Conveyor.java b/geowebcache/core/src/main/java/org/geowebcache/conveyor/Conveyor.java index 8227be2f1..93fcf446d 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/conveyor/Conveyor.java +++ b/geowebcache/core/src/main/java/org/geowebcache/conveyor/Conveyor.java @@ -28,14 +28,14 @@ public abstract class Conveyor { public static enum RequestHandler { LAYER, SERVICE - }; + } public static enum CacheResult { HIT, MISS, WMS, OTHER - }; + } private String layerId = null; diff --git a/geowebcache/core/src/main/java/org/geowebcache/io/ByteArrayResource.java b/geowebcache/core/src/main/java/org/geowebcache/io/ByteArrayResource.java index f399cab22..fd54ede86 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/io/ByteArrayResource.java +++ b/geowebcache/core/src/main/java/org/geowebcache/io/ByteArrayResource.java @@ -92,18 +92,19 @@ public long getSize() { /** @see org.geowebcache.io.Resource#transferTo(java.nio.channels.WritableByteChannel) */ @Override + @SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.EmptyControlStatement"}) public long transferTo(WritableByteChannel channel) throws IOException { if (length > 0) { ByteBuffer buffer = ByteBuffer.wrap(data, offset, length); long written = 0; - while ((written += channel.write(buffer)) < length) {; - } + while ((written += channel.write(buffer)) < length) ; } return length; } /** @see org.geowebcache.io.Resource#transferFrom(java.nio.channels.ReadableByteChannel) */ @Override + @SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.EmptyControlStatement"}) public long transferFrom(ReadableByteChannel channel) throws IOException { if (channel instanceof FileChannel) { FileChannel fc = (FileChannel) channel; @@ -114,8 +115,7 @@ public long transferFrom(ReadableByteChannel channel) throws IOException { } ByteBuffer buffer = ByteBuffer.wrap(data); int read = 0; - while ((read += channel.read(buffer)) < length) {; - } + while ((read += channel.read(buffer)) < length) ; } else { offset = 0; length = 0; diff --git a/geowebcache/core/src/main/java/org/geowebcache/io/FileResource.java b/geowebcache/core/src/main/java/org/geowebcache/io/FileResource.java index c0f8598b0..bd4df67b7 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/io/FileResource.java +++ b/geowebcache/core/src/main/java/org/geowebcache/io/FileResource.java @@ -49,6 +49,7 @@ public long getSize() { } @Override + @SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.EmptyControlStatement"}) public long transferTo(WritableByteChannel target) throws IOException { // FileLock lock = in.lock(); @@ -56,17 +57,17 @@ public long transferTo(WritableByteChannel target) throws IOException { FileChannel in = fis.getChannel(); ) { final long size = in.size(); long written = 0; - while ((written += in.transferTo(written, size, target)) < size) {; - } + while ((written += in.transferTo(written, size, target)) < size) ; return size; } } @Override + @SuppressWarnings("PMD.UnusedLocalVariable") public long transferFrom(ReadableByteChannel channel) throws IOException { try (FileOutputStream fos = new FileOutputStream(file); FileChannel out = fos.getChannel(); - FileLock lock = out.lock(); ) { + FileLock lock = out.lock()) { final int buffsize = 4096; long position = 0; long read; diff --git a/geowebcache/core/src/main/java/org/geowebcache/io/TreeSetConverter.java b/geowebcache/core/src/main/java/org/geowebcache/io/TreeSetConverter.java index 4b4fcd8ce..2cdc4a591 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/io/TreeSetConverter.java +++ b/geowebcache/core/src/main/java/org/geowebcache/io/TreeSetConverter.java @@ -78,7 +78,7 @@ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext co reader.moveUp(); } populateCollection(reader, context, result, set); - if (set.size() > 0) { + if (!set.isEmpty()) { result.addAll(set); // comparator will not be called if internally optimized } return result; diff --git a/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java b/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java index 09a545754..df82f2e3f 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java @@ -168,7 +168,7 @@ public Iterable getLayerListFiltered() { Stream s = StreamSupport.stream(result.spliterator(), false) .filter(x -> !tileLayerDispatcherFilter.exclude(x)); - result = (Iterable) s::iterator; + result = s::iterator; } return result; } diff --git a/geowebcache/core/src/main/java/org/geowebcache/layer/meta/VectorLayerMetadata.java b/geowebcache/core/src/main/java/org/geowebcache/layer/meta/VectorLayerMetadata.java index dac91adc9..a6420e4cc 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/meta/VectorLayerMetadata.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/meta/VectorLayerMetadata.java @@ -27,7 +27,7 @@ public enum GeometryType { point, line, polygon - }; + } String id; String description; diff --git a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSLayer.java b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSLayer.java index c5532db7c..d7a226948 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSLayer.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSLayer.java @@ -64,7 +64,7 @@ public class WMSLayer extends AbstractTileLayer implements ProxyLayer { public enum RequestType { MAP, FEATUREINFO - }; + } public enum HttpRequestMode { Get, diff --git a/geowebcache/core/src/main/java/org/geowebcache/mime/ImageMime.java b/geowebcache/core/src/main/java/org/geowebcache/mime/ImageMime.java index 0fe3ecce4..790b23af8 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/mime/ImageMime.java +++ b/geowebcache/core/src/main/java/org/geowebcache/mime/ImageMime.java @@ -59,7 +59,7 @@ public class ImageMime extends MimeType { public boolean isCompatible(String otherMimeType) { return super.isCompatible(otherMimeType) || otherMimeType.startsWith("image/png"); - }; + } }; public static final ImageMime jpeg = @@ -336,7 +336,7 @@ public String getMimeType(org.geowebcache.io.Resource resource) throws IOExcepti return pngDelegate.getMimeType(); } } - }; + } @Override public boolean isCompatible(String otherMimeType) { diff --git a/geowebcache/core/src/main/java/org/geowebcache/seed/GWCTask.java b/geowebcache/core/src/main/java/org/geowebcache/seed/GWCTask.java index 629809283..e8a29535b 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/seed/GWCTask.java +++ b/geowebcache/core/src/main/java/org/geowebcache/seed/GWCTask.java @@ -29,7 +29,7 @@ public static enum TYPE { SEED, RESEED, TRUNCATE - }; + } public static enum STATE { UNSET, @@ -37,7 +37,7 @@ public static enum STATE { RUNNING, DONE, DEAD - }; + } /** * Value shared between all the threads in the group, is incremented each time a task starts diff --git a/geowebcache/core/src/main/java/org/geowebcache/seed/SeedTask.java b/geowebcache/core/src/main/java/org/geowebcache/seed/SeedTask.java index 87b8d34b5..9a52a447a 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/seed/SeedTask.java +++ b/geowebcache/core/src/main/java/org/geowebcache/seed/SeedTask.java @@ -285,11 +285,9 @@ private void updateStatusInfo(TileLayer layer, long tilesCount, long start_time) // estimated time of completion in seconds, use a moving average over the last this.timeSpent = (int) (System.currentTimeMillis() - start_time) / 1000; - int threadCount = sharedThreadCount.get(); - long timeTotal = - Math.round( - (double) timeSpent - * (((double) tilesTotal / threadCount) / (double) tilesCount)); + // using double to force the next calcuation to double type + double threadCount = sharedThreadCount.get(); + long timeTotal = Math.round(timeSpent * ((tilesTotal / threadCount) / tilesCount)); this.timeRemaining = (int) (timeTotal - timeSpent); } diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/StorageObject.java b/geowebcache/core/src/main/java/org/geowebcache/storage/StorageObject.java index 1d2fb1195..a9184e80a 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/StorageObject.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/StorageObject.java @@ -22,7 +22,7 @@ public static enum Status { MISS, LOCK, EXPIRED_LOCK - }; + } Status status = Status.UNSET; diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/TransientCache.java b/geowebcache/core/src/main/java/org/geowebcache/storage/TransientCache.java index 17d831d4d..9ae019ff5 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/TransientCache.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/TransientCache.java @@ -52,7 +52,7 @@ public class TransientCache { private static FilePathGenerator keyGenerator = new DefaultFilePathGenerator(""); private Map cache = - new LinkedHashMap() { + new LinkedHashMap<>() { /** serialVersionUID */ private static final long serialVersionUID = -4106644240603796847L; diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/TileFileVisitor.java b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/TileFileVisitor.java index 49d4a9465..56ec950e7 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/TileFileVisitor.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/TileFileVisitor.java @@ -23,11 +23,11 @@ public interface TileFileVisitor { /** Invoked before visitng a directory */ - default void preVisitDirectory(File dir) {}; + default void preVisitDirectory(File dir) {} /** Invoked on a specific tile file */ public void visitFile(File tile, long x, long y, int z); /** Invoked on a directory post file visit */ - default void postVisitDirectory(File dir) {}; + default void postVisitDirectory(File dir) {} } diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/XYZFilePathGenerator.java b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/XYZFilePathGenerator.java index 62dbcb26f..05451f7f6 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/XYZFilePathGenerator.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/XYZFilePathGenerator.java @@ -46,7 +46,7 @@ public enum Convention { TMS, /** Slippy map convention, where tile coordinates have their * origin at top left (NW) */ XYZ - }; + } @SuppressWarnings("unused") private static Logger log = Logging.getLogger(XYZFilePathGenerator.class.getName()); diff --git a/geowebcache/core/src/main/java/org/geowebcache/util/ExceptionUtils.java b/geowebcache/core/src/main/java/org/geowebcache/util/ExceptionUtils.java index a843a66ef..a31c62fe2 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/util/ExceptionUtils.java +++ b/geowebcache/core/src/main/java/org/geowebcache/util/ExceptionUtils.java @@ -28,5 +28,5 @@ private ExceptionUtils() {} public static boolean isOrSuppresses(T e, Class klazz) { return Streams.concat(Stream.of(e), Arrays.stream(e.getSuppressed())) .anyMatch(klazz::isInstance); - }; + } } diff --git a/geowebcache/core/src/main/java/org/geowebcache/util/ServletUtils.java b/geowebcache/core/src/main/java/org/geowebcache/util/ServletUtils.java index 53b4665c7..9a463e665 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/util/ServletUtils.java +++ b/geowebcache/core/src/main/java/org/geowebcache/util/ServletUtils.java @@ -111,8 +111,8 @@ public static String[][] selectedStringArraysFromMap( public static Map selectedStringsFromMap( Map map, String encoding, String... keys) { - map = new CaseInsensitiveMap(map); - Map selected = new CaseInsensitiveMap(); + map = new CaseInsensitiveMap<>(map); + Map selected = new CaseInsensitiveMap<>(); for (String key : keys) { Object value = map.get(key); if (value != null) { diff --git a/geowebcache/core/src/test/java/org/geowebcache/TestHelpers.java b/geowebcache/core/src/test/java/org/geowebcache/TestHelpers.java index 643144af2..b7976097e 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/TestHelpers.java +++ b/geowebcache/core/src/test/java/org/geowebcache/TestHelpers.java @@ -120,6 +120,7 @@ public static SeedRequest createRequest( } /** Matcher for an {@link HttpServletResponse} that checks its status. */ + @SuppressWarnings("PMD.UseDiamondOperator") public static Matcher hasStatus(HttpStatus expected) { return new BaseMatcher() { diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java index 2b6ef36c9..670cc7c15 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java @@ -233,7 +233,7 @@ public void testGetExisting() throws Exception { assertThat(retrieved, isPresent()); } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "PMD.UnnecessaryCast"}) @Test public void testCantModifyReturnedCollection() throws Exception { I info = getGoodInfo("test", 1); diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java index da30357b0..efb7674f4 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java @@ -39,7 +39,7 @@ protected GridSetConfiguration getSecondConfig() throws Exception { @Override protected Matcher infoEquals(GridSet expected) { - return new CustomMatcher( + return new CustomMatcher<>( "GridSet matching " + expected.getName() + " with " + expected.getDescription()) { @Override @@ -53,7 +53,7 @@ public boolean matches(Object item) { @Override protected Matcher infoEquals(int expected) { - return new CustomMatcher("GridSet with value " + expected) { + return new CustomMatcher<>("GridSet with value " + expected) { @Override public boolean matches(Object item) { diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBlobStoreConformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBlobStoreConformanceTest.java index aa1d2a4ec..68c237aa7 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBlobStoreConformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBlobStoreConformanceTest.java @@ -137,7 +137,7 @@ protected String getExistingInfo() { @Override protected Matcher infoEquals(BlobStoreInfo expected) { - return new CustomMatcher("BlobStoreInfo Matcher") { + return new CustomMatcher<>("BlobStoreInfo Matcher") { @Override public boolean matches(Object item) { return expected.equals(item); @@ -147,7 +147,7 @@ public boolean matches(Object item) { @Override protected Matcher infoEquals(int expected) { - return new CustomMatcher("BlobStoreInfo with value " + expected) { + return new CustomMatcher<>("BlobStoreInfo with value " + expected) { @Override public boolean matches(Object item) { diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationGridsetConformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationGridsetConformanceTest.java index eafd176ba..87b1d284d 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationGridsetConformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationGridsetConformanceTest.java @@ -68,7 +68,7 @@ protected void makeConfigFile() throws IOException { @Override protected Matcher infoEquals(GridSet expected) { - return new CustomMatcher( + return new CustomMatcher<>( "GridSet matching " + expected.getName() + " with " + expected.getDescription()) { @Override @@ -82,7 +82,7 @@ public boolean matches(Object item) { @Override protected Matcher infoEquals(int expected) { - return new CustomMatcher("GridSet with value " + expected) { + return new CustomMatcher<>("GridSet with value " + expected) { @Override public boolean matches(Object item) { diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java index d1144d04e..8ffc3b09f 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java @@ -144,7 +144,7 @@ protected void makeConfigFile() throws Exception { @Override protected Matcher infoEquals(TileLayer expected) { - return new CustomMatcher( + return new CustomMatcher<>( "Layer matching " + expected.getId() + " with " @@ -163,7 +163,7 @@ public boolean matches(Object item) { @Override protected Matcher infoEquals(int expected) { - return new CustomMatcher("Layer with value" + expected) { + return new CustomMatcher<>("Layer with value" + expected) { @Override public boolean matches(Object item) { diff --git a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/ParametersUtilsTest.java b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/ParametersUtilsTest.java index a3cfe73b0..5c4efcd9b 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/ParametersUtilsTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/ParametersUtilsTest.java @@ -139,7 +139,7 @@ public void testAmpToMap() { static Matcher> hasEntries(Matcher>... entryMatchers) { final Matcher>> entrySetMatcher = Matchers.containsInAnyOrder(entryMatchers); - return new BaseMatcher>() { + return new BaseMatcher<>() { @Override public boolean matches(Object item) { diff --git a/geowebcache/core/src/test/java/org/geowebcache/seed/SeedTaskTest.java b/geowebcache/core/src/test/java/org/geowebcache/seed/SeedTaskTest.java index 69f7dc0e3..4beabb1d9 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/seed/SeedTaskTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/seed/SeedTaskTest.java @@ -93,7 +93,7 @@ public void testSeedWMSRequests() throws Exception { Capture resourceCapturer = EasyMock.newCapture(); IAnswer answer = - new IAnswer() { + new IAnswer<>() { @Override public Void answer() throws Throwable { wmsRequestsCounter.incrementAndGet(); diff --git a/geowebcache/core/src/test/java/org/geowebcache/util/FileMatchers.java b/geowebcache/core/src/test/java/org/geowebcache/util/FileMatchers.java index db27106b3..b3149b5a9 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/util/FileMatchers.java +++ b/geowebcache/core/src/test/java/org/geowebcache/util/FileMatchers.java @@ -36,11 +36,11 @@ public class FileMatchers { private FileMatchers() { throw new IllegalStateException(); - }; + } /** Matcher for a file that exists */ public static Matcher exists() { - return new BaseMatcher() { + return new BaseMatcher<>() { @Override public boolean matches(Object item) { @@ -71,7 +71,7 @@ public void describeMismatch(Object item, Description description) { /** Matcher for a regular (non-directory) file */ public static Matcher file() { - return new BaseMatcher() { + return new BaseMatcher<>() { @Override public boolean matches(Object item) { @@ -107,7 +107,7 @@ public void describeMismatch(Object item, Description description) { /** Matcher for a directory */ public static Matcher directory() { - return new BaseMatcher() { + return new BaseMatcher<>() { @Override public boolean matches(Object item) { @@ -143,7 +143,7 @@ public void describeMismatch(Object item, Description description) { /** Matcher for a directory's contents */ public static Matcher directoryContaining(Matcher> filesMatcher) { - return new BaseMatcher() { + return new BaseMatcher<>() { @Override public boolean matches(Object item) { @@ -187,7 +187,7 @@ public static Matcher directoryEmpty() { /** Matcher for last modified time */ public static Matcher lastModified(final Matcher timeMatcher) { - return new BaseMatcher() { + return new BaseMatcher<>() { @Override public boolean matches(Object item) { @@ -241,7 +241,7 @@ public static Matcher whileRunning(Callable stuffToDo) throws Except } public static Matcher resource(final Resource expected) { - return new BaseMatcher() { + return new BaseMatcher<>() { @Override public boolean matches(Object item) { diff --git a/geowebcache/core/src/test/java/org/geowebcache/util/MockWMSSourceHelper.java b/geowebcache/core/src/test/java/org/geowebcache/util/MockWMSSourceHelper.java index 02ae97d4c..ea06ad301 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/util/MockWMSSourceHelper.java +++ b/geowebcache/core/src/test/java/org/geowebcache/util/MockWMSSourceHelper.java @@ -71,13 +71,8 @@ protected void makeRequest( graphics.setColor(Color.LIGHT_GRAY); graphics.fillRect(0, 0, width, height); - // graphics.setColor(Color.BLACK); - // graphics.setFont(font); - int tileN = 0; for (int y = 0; y < tilesY; y++) { for (int x = 0; x < tilesX; x++) { - long[] t = tiles[tileN]; - tileN++; int gx = x * tileW; int gy = y * tileH; // gx += 15; diff --git a/geowebcache/core/src/test/java/org/geowebcache/util/SetSingletonRule.java b/geowebcache/core/src/test/java/org/geowebcache/util/SetSingletonRule.java index 7794a901d..fc968d270 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/util/SetSingletonRule.java +++ b/geowebcache/core/src/test/java/org/geowebcache/util/SetSingletonRule.java @@ -43,7 +43,7 @@ public SetSingletonRule() { */ public static SetSingletonRule create( Supplier get, Consumer set, @Nullable Supplier newValue) { - return new SetSingletonRule(newValue) { + return new SetSingletonRule<>(newValue) { @Override public void setValue(T value) { @@ -83,7 +83,7 @@ protected void init() { if (Objects.nonNull(newValue)) { setValue(newValue.get()); } - }; + } /** Getter for the singleton value */ public abstract T getValue(); diff --git a/geowebcache/core/src/test/java/org/geowebcache/util/TestUtils.java b/geowebcache/core/src/test/java/org/geowebcache/util/TestUtils.java index 04ca1adb5..6f1ee6c9d 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/util/TestUtils.java +++ b/geowebcache/core/src/test/java/org/geowebcache/util/TestUtils.java @@ -157,7 +157,7 @@ public static Matcher> notPresent() { } public static Matcher> isPresent(Matcher valueMatcher) { - return new BaseMatcher>() { + return new BaseMatcher<>() { @Override public boolean matches(Object item) { @@ -193,7 +193,7 @@ public static Matcher> isPresent() { /** Match string matching a regular expression */ public static Matcher matchesRegex(String regex) { final Pattern p = Pattern.compile(regex); - return new CustomMatcher("matching /" + regex + "/") { + return new CustomMatcher<>("matching /" + regex + "/") { @Override public boolean matches(Object arg0) { @@ -210,7 +210,7 @@ public boolean matches(Object arg0) { */ public static T assertPresent(Optional opt) throws AssertionError { return opt.orElseThrow(() -> new AssertionError("Optional was not present")); - }; + } /** * Require that an Optional is present, and returns its value if it is. Use this where the test @@ -223,5 +223,5 @@ public static T requirePresent(Optional opt) throws IllegalStateException () -> new IllegalStateException( "Optional was not present and is required for test")); - }; + } } diff --git a/geowebcache/diskquota/bdb/src/test/java/org/geowebcache/diskquota/BDBQuotaStoreTest.java b/geowebcache/diskquota/bdb/src/test/java/org/geowebcache/diskquota/BDBQuotaStoreTest.java index 6d9621585..cc0fee112 100644 --- a/geowebcache/diskquota/bdb/src/test/java/org/geowebcache/diskquota/BDBQuotaStoreTest.java +++ b/geowebcache/diskquota/bdb/src/test/java/org/geowebcache/diskquota/BDBQuotaStoreTest.java @@ -595,7 +595,7 @@ public void testCreatesVersion() throws Exception { } static Matcher closeTo(float f, float epsilon) { - return new BaseMatcher() { + return new BaseMatcher<>() { Matcher doubleMatcher = Matchers.closeTo(f, epsilon); @Override diff --git a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/CacheCleaner.java b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/CacheCleaner.java index 490e9169b..53e7eb6fa 100644 --- a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/CacheCleaner.java +++ b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/CacheCleaner.java @@ -248,7 +248,6 @@ private void expirePage(QuotaStore pageStore, TilePage tilePage) throws Interrup } catch (InterruptedException e) { log.fine("Truncate task interrupted"); Thread.currentThread().interrupt(); - return; } catch (GeoWebCacheException e) { throw new RuntimeException(e); } diff --git a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/rest/controller/DiskQuotaController.java b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/rest/controller/DiskQuotaController.java index c2aac8558..b3870fe11 100644 --- a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/rest/controller/DiskQuotaController.java +++ b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/rest/controller/DiskQuotaController.java @@ -73,7 +73,7 @@ public ResponseEntity doGet(HttpServletRequest request) { try { return getJsonRepresentation(config); } catch (JSONException e) { - return new ResponseEntity( + return new ResponseEntity<>( "Caught JSON Execption.", HttpStatus.INTERNAL_SERVER_ERROR); } } else { @@ -102,7 +102,7 @@ public ResponseEntity doPut(HttpServletRequest request) { } } catch (IOException | JSONException e) { - return new ResponseEntity( + return new ResponseEntity<>( "Error writing input stream to string", HttpStatus.INTERNAL_SERVER_ERROR); } } diff --git a/geowebcache/diskquota/jdbc/src/main/java/org/geowebcache/diskquota/jdbc/SQLDialect.java b/geowebcache/diskquota/jdbc/src/main/java/org/geowebcache/diskquota/jdbc/SQLDialect.java index 197a0a191..919842c3d 100644 --- a/geowebcache/diskquota/jdbc/src/main/java/org/geowebcache/diskquota/jdbc/SQLDialect.java +++ b/geowebcache/diskquota/jdbc/src/main/java/org/geowebcache/diskquota/jdbc/SQLDialect.java @@ -150,23 +150,21 @@ private boolean tableExists( try { DataSource ds = ((JdbcAccessor) template.getJdbcOperations()).getDataSource(); if (ds == null) return false; - return (Boolean) - JdbcUtils.extractDatabaseMetaData( - ds, - dbmd -> { - try (ResultSet rs = - dbmd.getTables( - null, schema, tableName.toLowerCase(), null)) { - boolean exists = rs.next(); - rs.close(); - if (exists) { - return true; - } - } - try (ResultSet rs = dbmd.getTables(null, schema, tableName, null)) { - return rs.next(); - } - }); + return JdbcUtils.extractDatabaseMetaData( + ds, + dbmd -> { + try (ResultSet rs = + dbmd.getTables(null, schema, tableName.toLowerCase(), null)) { + boolean exists = rs.next(); + rs.close(); + if (exists) { + return true; + } + } + try (ResultSet rs = dbmd.getTables(null, schema, tableName, null)) { + return rs.next(); + } + }); } catch (MetaDataAccessException e) { return false; } diff --git a/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPoller.java b/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPoller.java index 9f7c35420..7feb78855 100644 --- a/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPoller.java +++ b/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPoller.java @@ -105,7 +105,7 @@ public GeoRSSPoller(final TileBreeder seeder, final int startUpDelaySecs) { private void findEnabledPolls() { final Iterable layers = seeder.getLayers(); for (TileLayer layer : layers) { - if (layer.getUpdateSources().size() == 0) { + if (layer.getUpdateSources().isEmpty()) { continue; } if (!layer.isEnabled()) { diff --git a/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMLService.java b/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMLService.java index 6de02e678..1fa47da16 100644 --- a/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMLService.java +++ b/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMLService.java @@ -283,7 +283,7 @@ private static String urlPrefix(String requestUrl, String[] parsed) { endOffset -= parsed[3].length() + 1; } - return new String(requestUrl.substring(0, endOffset - 1)); + return requestUrl.substring(0, endOffset - 1); } /** Creates a superoverlay, ie. a short description and network links to the first overlays. */ diff --git a/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMZHelper.java b/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMZHelper.java index 1636f93ab..d905cf72a 100644 --- a/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMZHelper.java +++ b/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMZHelper.java @@ -68,15 +68,15 @@ public static long[][] filterGridLocs( long[][] linkGridLocs) throws GeoWebCacheException { - for (int i = 0; i < linkGridLocs.length; i++) { - if (linkGridLocs[i][2] > 0) { + for (long[] linkGridLock : linkGridLocs) { + if (linkGridLock[2] > 0) { ConveyorTile tile = new ConveyorTile( sb, tileLayer.getName(), gridSetId, - linkGridLocs[i], + linkGridLock, mime, null, null, @@ -89,11 +89,11 @@ public static long[][] filterGridLocs( secDisp.checkSecurity(tile); tileLayer.applyRequestFilters(tile); } catch (SecurityException ex) { - linkGridLocs[i][2] = -1; + linkGridLock[2] = -1; } catch (GreenTileException e) { // We will link to this one } catch (RequestFilterException e) { - linkGridLocs[i][2] = -1; + linkGridLock[2] = -1; continue; } @@ -103,14 +103,14 @@ public static long[][] filterGridLocs( tileLayer.getTile(tile); } catch (IOException ioe) { log.log(Level.SEVERE, ioe.getMessage()); - linkGridLocs[i][2] = -1; + linkGridLock[2] = -1; } catch (GeoWebCacheException gwce) { - linkGridLocs[i][2] = -1; + linkGridLock[2] = -1; } // If it's a 204 it means no content -> don't link to it if (tile.getStatus() == 204) { - linkGridLocs[i][2] = -1; + linkGridLock[2] = -1; } else if (tile.getStatus() != 200) { throw new GeoWebCacheException( "Unexpected response code from server " + tile.getStatus()); diff --git a/geowebcache/mbtiles/src/main/java/org/geowebcache/mbtiles/layer/MBTilesInfo.java b/geowebcache/mbtiles/src/main/java/org/geowebcache/mbtiles/layer/MBTilesInfo.java index e767daf7c..2d894a4f8 100644 --- a/geowebcache/mbtiles/src/main/java/org/geowebcache/mbtiles/layer/MBTilesInfo.java +++ b/geowebcache/mbtiles/src/main/java/org/geowebcache/mbtiles/layer/MBTilesInfo.java @@ -161,9 +161,7 @@ public void decorateTileJSON(TileJSON tileJSON) { ObjectMapper mapper = new ObjectMapper(); List layers = null; try { - layers = - mapper.readValue( - json, new TypeReference>() {}); + layers = mapper.readValue(json, new TypeReference<>() {}); } catch (JsonProcessingException e) { throw new IllegalArgumentException( "Exception occurred while parsing the layers metadata. " + e); diff --git a/geowebcache/pmd-junit-ruleset.xml b/geowebcache/pmd-junit-ruleset.xml index 3b25aac85..66c500dca 100644 --- a/geowebcache/pmd-junit-ruleset.xml +++ b/geowebcache/pmd-junit-ruleset.xml @@ -30,7 +30,7 @@ GeoTools Junit ruleset. See https://pmd.github.io/latest/pmd_userdocs_understand + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" > Don't use JUnit3, use JUnit4 instead diff --git a/geowebcache/pmd-ruleset.xml b/geowebcache/pmd-ruleset.xml index 9f09cb7b5..190ac5095 100644 --- a/geowebcache/pmd-ruleset.xml +++ b/geowebcache/pmd-ruleset.xml @@ -47,6 +47,7 @@ GeoTools ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_ru + @@ -78,7 +79,7 @@ GeoTools ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_ru - + @@ -89,13 +90,12 @@ GeoTools ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_ru - + Don't use wildcard imports 3 - 2.24.1 9+181-r4173-1 - 6.55.0 + 7.2.0 false false deprecation,unchecked @@ -797,7 +797,7 @@ maven-pmd-plugin - 3.20.0 + 3.22.0 @@ -835,7 +835,6 @@ 3 3 - true true true diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BlobStoreController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BlobStoreController.java index c3c8e37e5..8a7099338 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BlobStoreController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BlobStoreController.java @@ -86,7 +86,7 @@ public ResponseEntity blobStorePut( blobStores.modifyBlobStore(blobStore); } else { blobStores.addBlobStore(blobStore); - return new ResponseEntity("", HttpStatus.CREATED); + return new ResponseEntity<>("", HttpStatus.CREATED); } return null; } diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BoundsController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BoundsController.java index 8909637a6..deeb7fa02 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BoundsController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BoundsController.java @@ -42,7 +42,7 @@ public class BoundsController extends GWCController { public ResponseEntity handleRestException(RestException ex) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); - return new ResponseEntity(ex.toString(), headers, ex.getStatus()); + return new ResponseEntity<>(ex.toString(), headers, ex.getStatus()); } @RequestMapping(value = "/bounds/{layer}/{srs}/{type}", method = RequestMethod.GET) @@ -86,7 +86,7 @@ public ResponseEntity doGet( } str.append("}"); - return new ResponseEntity(str.toString(), HttpStatus.OK); + return new ResponseEntity<>(str.toString(), HttpStatus.OK); } else { throw new RestException( "Unknown or missing format extension : " + type, HttpStatus.BAD_REQUEST); diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ByteStreamController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ByteStreamController.java index fa23daf7a..eba08de49 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ByteStreamController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ByteStreamController.java @@ -113,7 +113,7 @@ ResponseEntity doGet(HttpServletRequest request, HttpServletResponse response try { mime = MimeType.createFromExtension(extension); } catch (MimeException e) { - return new ResponseEntity( + return new ResponseEntity<>( "Unable to create MimeType for " + extension, HttpStatus.INTERNAL_SERVER_ERROR); } @@ -124,7 +124,7 @@ ResponseEntity doGet(HttpServletRequest request, HttpServletResponse response ServletOutputStream outputStream = response.getOutputStream(); ) { StreamUtils.copy(inputStream, outputStream); } catch (IOException e) { - return new ResponseEntity("Internal error", HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>("Internal error", HttpStatus.INTERNAL_SERVER_ERROR); } return new ResponseEntity<>(HttpStatus.OK); diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/FilterUpdateController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/FilterUpdateController.java index e08bd860b..1db7e8a43 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/FilterUpdateController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/FilterUpdateController.java @@ -98,7 +98,7 @@ public ResponseEntity doPost( // prepare response content type HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); - return new ResponseEntity( + return new ResponseEntity<>( "Filter update completed, no problems encountered.\n", headers, HttpStatus.OK); } diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/GridSetController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/GridSetController.java index 88f806b32..7bdefb284 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/GridSetController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/GridSetController.java @@ -84,7 +84,7 @@ public ResponseEntity gridSetPut( broker.put(gridSet); } else { broker.addGridSet(gridSet); - return new ResponseEntity("", HttpStatus.CREATED); + return new ResponseEntity<>("", HttpStatus.CREATED); } return null; } diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/MassTruncateController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/MassTruncateController.java index 72feccc87..f99926cef 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/MassTruncateController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/MassTruncateController.java @@ -69,7 +69,7 @@ public MassTruncateController(ApplicationContextProvider appCtx) { @ExceptionHandler(RestException.class) public ResponseEntity handleRestException(RestException ex) { - return new ResponseEntity(ex.toString(), ex.getStatus()); + return new ResponseEntity<>(ex.toString(), ex.getStatus()); } public void setStorageBroker(StorageBroker broker) { @@ -113,7 +113,7 @@ public ResponseEntity doGet(HttpServletRequest req) { } sb.append(""); - return new ResponseEntity(sb.toString(), HttpStatus.OK); + return new ResponseEntity<>(sb.toString(), HttpStatus.OK); } /** Issue a mass truncate request. */ diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ReloadController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ReloadController.java index a694741cd..f4465a694 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ReloadController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ReloadController.java @@ -57,7 +57,7 @@ public class ReloadController implements ApplicationContextAware { @ExceptionHandler(RestException.class) public ResponseEntity handleRestException(RestException ex) { - return new ResponseEntity(ex.toString(), ex.getStatus()); + return new ResponseEntity<>(ex.toString(), ex.getStatus()); } @RequestMapping(value = "/reload", method = RequestMethod.POST) @@ -124,7 +124,7 @@ public ResponseEntity handleRestException(RestException ex) { doc.append("

Go back

\n"); doc.append(""); - return new ResponseEntity(doc.toString(), HttpStatus.OK); + return new ResponseEntity<>(doc.toString(), HttpStatus.OK); } public void setTileLayerDispatcher(TileLayerDispatcher tileLayerDispatcher) { diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/SeedController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/SeedController.java index 161334fc7..315cd7948 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/SeedController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/SeedController.java @@ -94,7 +94,7 @@ public ResponseEntity doFormGet(HttpServletRequest request, @PathVariable Str public ResponseEntity doPost(HttpServletRequest request) { String response = seedService.handleKillAllThreads(request, null); if (response.equalsIgnoreCase("error")) { - return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } else { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); @@ -126,7 +126,7 @@ public ResponseEntity doPost( } catch (UnsupportedEncodingException e) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); - return new ResponseEntity( + return new ResponseEntity<>( "Unable to parse form result.", headers, HttpStatus.BAD_REQUEST); } } @@ -165,7 +165,7 @@ private ResponseEntity handleFormPostInternal(String layer, Map("error", headers, HttpStatus.INTERNAL_SERVER_ERROR); + return new ResponseEntity<>("error", headers, HttpStatus.INTERNAL_SERVER_ERROR); } } diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ServerController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ServerController.java index 1c72f5821..2e4386142 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ServerController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ServerController.java @@ -41,7 +41,7 @@ public class ServerController { public ResponseEntity handleRestException(RestException ex) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); - return new ResponseEntity(ex.toString(), headers, ex.getStatus()); + return new ResponseEntity<>(ex.toString(), headers, ex.getStatus()); } @RequestMapping(method = RequestMethod.GET) diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/TileLayerController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/TileLayerController.java index 58b39410a..c99c39665 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/TileLayerController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/TileLayerController.java @@ -82,7 +82,7 @@ public ResponseEntity layerPost(@RequestBody TileLayer tl, @PathVariable Stri try { layerDispatcher.modify(tl); } catch (IllegalArgumentException e) { - return new ResponseEntity( + return new ResponseEntity<>( "Layer " + tl.getName() + " is not known by the configuration." @@ -115,7 +115,7 @@ public ResponseEntity layerPut(@RequestBody TileLayer tl, @PathVariable Strin } else { layerDispatcher.modify(tl); } - return new ResponseEntity("layer saved", HttpStatus.OK); + return new ResponseEntity<>("layer saved", HttpStatus.OK); } /* @@ -157,7 +157,7 @@ public ResponseEntity doDelete(HttpServletRequest req, @PathVariable String l HttpStatus.INTERNAL_SERVER_ERROR, storageBrokerDeleteException); } - return new ResponseEntity(layerName + " deleted", HttpStatus.OK); + return new ResponseEntity<>(layerName + " deleted", HttpStatus.OK); } @SuppressWarnings("PMD.EmptyControlStatement") diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/service/FormService.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/service/FormService.java index d8afb564e..57b7f57d7 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/service/FormService.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/service/FormService.java @@ -143,7 +143,7 @@ public ResponseEntity handleKillThreadPost(Map form, TileLaye doc.append("

Go back

\n"); } - return new ResponseEntity(doc.toString(), getHeaders(), HttpStatus.OK); + return new ResponseEntity<>(doc.toString(), getHeaders(), HttpStatus.OK); } public ResponseEntity handleFormPost(String layer, Map params) @@ -267,7 +267,7 @@ private ResponseEntity handleDoSeedPost(Map form, TileLayer t Thread.currentThread().interrupt(); } - return new ResponseEntity(this.makeResponsePage(tl), getHeaders(), HttpStatus.OK); + return new ResponseEntity<>(this.makeResponsePage(tl), getHeaders(), HttpStatus.OK); } private long getOptionalLongParam(Map form, String key, long defaultValue) { diff --git a/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3BlobStore.java b/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3BlobStore.java index 4c222ef70..30cd34ac9 100644 --- a/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3BlobStore.java +++ b/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3BlobStore.java @@ -317,7 +317,7 @@ public boolean delete(final TileRange tileRange) throws StorageException { } final Iterator tileLocations = - new AbstractIterator() { + new AbstractIterator<>() { // TileRange iterator with 1x1 meta tiling factor private TileRangeIterator trIter = diff --git a/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/MbtilesBlobStore.java b/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/MbtilesBlobStore.java index 27c1dde6f..47574d27f 100644 --- a/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/MbtilesBlobStore.java +++ b/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/MbtilesBlobStore.java @@ -169,7 +169,9 @@ public void put(TileObject tile) throws StorageException { byte[] bytes; if (gzipped) { try (ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); - GZIPOutputStream gzOut = new GZIPOutputStream(byteStream); ) { + GZIPOutputStream gzOut = new GZIPOutputStream(byteStream)) { + gzOut.write(Utils.resourceToByteArray(tile.getBlob())); + gzOut.flush(); bytes = byteStream.toByteArray(); } } else { diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java index 2f6956c56..36ff6e9c8 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java @@ -246,7 +246,7 @@ private void zipDirectory(Path directoryToZip, File outputZipFile) throws IOExce ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream)) { Files.walkFileTree( directoryToZip, - new SimpleFileVisitor() { + new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile( diff --git a/geowebcache/swiftblob/src/main/java/org/geowebcache/swift/SwiftBlobStore.java b/geowebcache/swiftblob/src/main/java/org/geowebcache/swift/SwiftBlobStore.java index 9113e76d1..f7c2f900c 100644 --- a/geowebcache/swiftblob/src/main/java/org/geowebcache/swift/SwiftBlobStore.java +++ b/geowebcache/swiftblob/src/main/java/org/geowebcache/swift/SwiftBlobStore.java @@ -204,7 +204,7 @@ public boolean delete(final TileRange tileRange) { } final Iterator tileLocations = - new AbstractIterator() { + new AbstractIterator<>() { // TileRange iterator with 1x1 meta tiling factor private final TileRangeIterator trIter = diff --git a/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSService.java b/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSService.java index 54304c7fe..00b2372f7 100644 --- a/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSService.java +++ b/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSService.java @@ -534,6 +534,7 @@ protected Collection getDefaultProxyRequestWhitelist() { } } + @SuppressWarnings("PMD.UnnecessaryCast") protected Collection getProxyRequestWhitelist() { return Optional.ofNullable( GeoWebCacheExtensions.getProperty(GEOWEBCACHE_WMS_PROXY_REQUEST_WHITELIST)) diff --git a/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSTileFuser.java b/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSTileFuser.java index e6831bdc3..698397a75 100644 --- a/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSTileFuser.java +++ b/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSTileFuser.java @@ -122,14 +122,14 @@ static class SpatialOffsets { double bottom; double left; double right; - }; + } static class PixelOffsets { int top; int bottom; int left; int right; - }; + } /** These are values before scaling */ PixelOffsets canvOfs = new PixelOffsets(); diff --git a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java index 68d322f10..31d463070 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java @@ -136,7 +136,7 @@ public void testLayerGridsets() throws Exception { @Override protected Matcher infoEquals(GridSet expected) { - return new CustomMatcher( + return new CustomMatcher<>( "GridSet matching " + expected.getName() + " with " + expected.getDescription()) { @Override @@ -150,7 +150,7 @@ public boolean matches(Object item) { @Override protected Matcher infoEquals(int expected) { - return new CustomMatcher("GridSet with value " + expected) { + return new CustomMatcher<>("GridSet with value " + expected) { @Override public boolean matches(Object item) { diff --git a/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSServiceTest.java b/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSServiceTest.java index a97baa10b..3d65c4733 100644 --- a/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSServiceTest.java +++ b/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSServiceTest.java @@ -303,7 +303,7 @@ public void testGetCap() throws Exception { service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); @SuppressWarnings("unchecked") - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetCapabilities"}); @@ -596,7 +596,7 @@ public ServiceInformation getServiceInformation() { service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); extensions.forEach(service::addExtension); @SuppressWarnings("unchecked") - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetCapabilities"}); @@ -691,7 +691,7 @@ public void testGetCapServiceInfo() throws Exception { service = new WMTSService(sb, tldx, null, mock(RuntimeStats.class)); @SuppressWarnings("unchecked") - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetCapabilities"}); @@ -771,7 +771,7 @@ public void testGetCapOneWGS84BBox() throws Exception { service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); @SuppressWarnings("unchecked") - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetCapabilities"}); @@ -854,7 +854,7 @@ public void testGetCapUnboundedStyleFilter() throws Exception { service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); @SuppressWarnings("unchecked") - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetCapabilities"}); @@ -938,7 +938,7 @@ public void testGetCapEmptyStyleFilter() throws Exception { service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); @SuppressWarnings("unchecked") - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetCapabilities"}); @@ -1022,7 +1022,7 @@ public void testGetCapMultipleStyles() throws Exception { service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); @SuppressWarnings("unchecked") - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetCapabilities"}); @@ -1135,7 +1135,7 @@ public void testGetCapWithMultipleDimensions() throws Exception { service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetCapabilities"}); @@ -1233,7 +1233,7 @@ public void testGetTileWithStyle() throws Exception { service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetTile"}); @@ -1303,7 +1303,7 @@ public void testDispatchCustomOperations() throws Exception { when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); @SuppressWarnings("unchecked") - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"CustomOperation"}); @@ -1525,7 +1525,7 @@ public void testGetCapWithTileJSONDifferentUrls() throws Exception { service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); @SuppressWarnings("unchecked") - Map kvp = new CaseInsensitiveMap(); + Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); kvp.put("version", new String[] {"1.0.0"}); kvp.put("request", new String[] {"GetCapabilities"}); From f8c0049ca5fc55d469b9de895074d2b2d75fe423 Mon Sep 17 00:00:00 2001 From: Andrea Aime Date: Sat, 15 Jun 2024 16:38:46 +0200 Subject: [PATCH 2/3] PMD 7.2, web module tests --- .../test/java/org/geowebcache/jetty/RestIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java b/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java index 2adc2e7bc..8c458010d 100644 --- a/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java +++ b/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java @@ -670,7 +670,7 @@ public void testLayerNoAuth() throws Exception { * Check that the given request gives a 401 Forbidden when not authenticated, and otherwise has * a response matching the given matcher */ - @SuppressWarnings("PMD.CloseResource") + @SuppressWarnings({"PMD.CloseResource", "PMD.UnusedLocalVariable"}) protected void testSecured(HttpUriRequest request, Matcher authenticatedStatus) throws Exception { { @@ -1249,7 +1249,7 @@ public void testLayerKillAll() throws Exception { } @Test - @SuppressWarnings("PMD.EmptyControlStatement") + @SuppressWarnings({"PMD.EmptyControlStatement", "PMD.UnusedLocalVariable"}) public void testNewFileBlobstoreDontDeleteExistingContent() throws Exception { // The directory already has stuff in it File bsDir = temp.newFolder(); From fd081a2b2382d1531fdad0fadbf270cb35ed94c9 Mon Sep 17 00:00:00 2001 From: Andrea Aime Date: Fri, 28 Jun 2024 08:34:33 +0200 Subject: [PATCH 3/3] Some more extra semicolons removed --- .../geowebcache/arcgis/compact/ArcGISCompactCacheTest.java | 2 +- .../main/java/org/geowebcache/config/XMLConfiguration.java | 2 +- .../java/org/geowebcache/config/XMLFileResourceProvider.java | 2 +- .../java/org/geowebcache/filter/request/FileRasterFilter.java | 2 +- .../org/geowebcache/filter/request/GreenTileException.java | 2 +- .../core/src/main/java/org/geowebcache/io/FileResource.java | 2 +- .../core/src/main/java/org/geowebcache/layer/MetaTile.java | 2 +- .../src/main/java/org/geowebcache/layer/wms/WMSLayer.java | 2 +- .../src/test/java/org/geowebcache/storage/BlobStoreTest.java | 2 +- .../test/java/org/geowebcache/storage/TransientCacheTest.java | 2 +- .../core/src/test/java/org/geowebcache/util/FileMatchers.java | 2 +- .../main/java/org/geowebcache/diskquota/ExpirationPolicy.java | 2 +- .../test/java/org/geowebcache/diskquota/ConfigLoaderTest.java | 2 +- .../org/geowebcache/diskquota/jdbc/JDBCQuotaStoreTest.java | 2 +- .../org/geowebcache/diskquota/jdbc/OracleQuotaStoreTest.java | 2 +- .../org/geowebcache/georss/GeoRSSTileRangeBuilderTest.java | 2 +- .../org/geowebcache/rest/controller/ByteStreamController.java | 2 +- .../main/java/org/geowebcache/sqlite/MbtilesBlobStore.java | 2 +- .../src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java | 2 +- .../src/test/java/org/geowebcache/sqlite/SqlitlePerf.java | 4 ++-- .../src/test/java/org/geowebcache/sqlite/TestSupport.java | 2 +- .../java/org/geowebcache/service/wms/WMSGetCapabilities.java | 2 +- 22 files changed, 23 insertions(+), 23 deletions(-) diff --git a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/compact/ArcGISCompactCacheTest.java b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/compact/ArcGISCompactCacheTest.java index 77ba4926f..603925fb7 100755 --- a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/compact/ArcGISCompactCacheTest.java +++ b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/compact/ArcGISCompactCacheTest.java @@ -164,7 +164,7 @@ public void testBundleFileResourceV2() throws Exception { } private boolean startsWithJPEGHeader(File f) { - try (FileInputStream fis = new FileInputStream(f); ) { + try (FileInputStream fis = new FileInputStream(f)) { byte[] fileHeader = new byte[JFIFHeader.length]; diff --git a/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java b/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java index 30513e3af..7bb2a8163 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java +++ b/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java @@ -799,7 +799,7 @@ static void validate(Node rootNode) throws SAXException, IOException { static String getCurrentSchemaVersion() { Document dom; - try (InputStream is = XMLConfiguration.class.getResourceAsStream("geowebcache.xsd"); ) { + try (InputStream is = XMLConfiguration.class.getResourceAsStream("geowebcache.xsd")) { dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is); } catch (Exception e) { throw new RuntimeException(e); diff --git a/geowebcache/core/src/main/java/org/geowebcache/config/XMLFileResourceProvider.java b/geowebcache/core/src/main/java/org/geowebcache/config/XMLFileResourceProvider.java index ba403a62b..e039bb4d8 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/config/XMLFileResourceProvider.java +++ b/geowebcache/core/src/main/java/org/geowebcache/config/XMLFileResourceProvider.java @@ -224,7 +224,7 @@ private File findOrCreateConfFile() throws IOException { // grab template from classpath try { try (InputStream templateStream = getClass().getResourceAsStream(templateLocation); - OutputStream output = new FileOutputStream(xmlFile); ) { + OutputStream output = new FileOutputStream(xmlFile)) { IOUtils.copy(templateStream, output); output.flush(); } diff --git a/geowebcache/core/src/main/java/org/geowebcache/filter/request/FileRasterFilter.java b/geowebcache/core/src/main/java/org/geowebcache/filter/request/FileRasterFilter.java index fae74263d..fc874f61f 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/filter/request/FileRasterFilter.java +++ b/geowebcache/core/src/main/java/org/geowebcache/filter/request/FileRasterFilter.java @@ -100,7 +100,7 @@ public void saveMatrix(byte[] data, TileLayer layer, String gridSetId, int zoomL throws IOException { // Persist File fh = new File(createFilePath(gridSetId, zoomLevel)); - try (FileOutputStream fos = new FileOutputStream(fh); ) { + try (FileOutputStream fos = new FileOutputStream(fh)) { fos.write(data); } } diff --git a/geowebcache/core/src/main/java/org/geowebcache/filter/request/GreenTileException.java b/geowebcache/core/src/main/java/org/geowebcache/filter/request/GreenTileException.java index 8aba92e26..c8c6966bc 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/filter/request/GreenTileException.java +++ b/geowebcache/core/src/main/java/org/geowebcache/filter/request/GreenTileException.java @@ -42,7 +42,7 @@ public GreenTileException(RequestFilter reqFilter) { private Resource getGreenTile() { byte[] green = new byte[659]; - try (InputStream is = GreenTileException.class.getResourceAsStream("green.png"); ) { + try (InputStream is = GreenTileException.class.getResourceAsStream("green.png")) { int ret = is.read(green); log.info("Read " + ret + " from gree PNG file (expected 659)."); } catch (IOException ioe) { diff --git a/geowebcache/core/src/main/java/org/geowebcache/io/FileResource.java b/geowebcache/core/src/main/java/org/geowebcache/io/FileResource.java index bd4df67b7..a5ff47701 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/io/FileResource.java +++ b/geowebcache/core/src/main/java/org/geowebcache/io/FileResource.java @@ -54,7 +54,7 @@ public long transferTo(WritableByteChannel target) throws IOException { // FileLock lock = in.lock(); try (FileInputStream fis = new FileInputStream(file); - FileChannel in = fis.getChannel(); ) { + FileChannel in = fis.getChannel()) { final long size = in.size(); long written = 0; while ((written += in.transferTo(written, size, target)) < size) ; diff --git a/geowebcache/core/src/main/java/org/geowebcache/layer/MetaTile.java b/geowebcache/core/src/main/java/org/geowebcache/layer/MetaTile.java index eca5d0b29..3ea06a896 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/MetaTile.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/MetaTile.java @@ -379,7 +379,7 @@ public boolean writeTileToStream(final int tileIdx, Resource target) throws IOEx param = formatModifier.adjustImageWriteParam(param); } try (OutputStream outputStream = target.getOutputStream(); - ImageOutputStream imgOut = new MemoryCacheImageOutputStream(outputStream); ) { + ImageOutputStream imgOut = new MemoryCacheImageOutputStream(outputStream)) { writer.setOutput(imgOut); IIOImage image = new IIOImage(tile, null, null); writer.write(null, image, param); diff --git a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSLayer.java b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSLayer.java index d7a226948..cae8e4ebb 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSLayer.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSLayer.java @@ -68,7 +68,7 @@ public enum RequestType { public enum HttpRequestMode { Get, - FormPost; + FormPost } private String[] wmsUrl; diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreTest.java index 950c49db6..6a539f66d 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreTest.java @@ -172,7 +172,7 @@ public void testTilRangeDelete() throws Exception { layerName, tos[0].xyz, srs.toString(), mime.getFormat(), parameters); fbs.get(firstTO); try (InputStream is = firstTO.getBlob().getInputStream(); - InputStream is2 = bytes.getInputStream(); ) { + InputStream is2 = bytes.getInputStream()) { Assert.assertTrue(IOUtils.contentEquals(is, is2)); } TileObject lastTO = diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/TransientCacheTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/TransientCacheTest.java index e5eac76d7..d1a045eb2 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/TransientCacheTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/TransientCacheTest.java @@ -55,7 +55,7 @@ public void testHit() throws Exception { Resource result = transCache.get("foo"); assertThat(result, notNullValue()); assertThat(r.getLastModified(), equalTo(r.getLastModified())); - try (InputStream is = result.getInputStream(); ) { + try (InputStream is = result.getInputStream()) { assertThat(is.read(), equalTo(1)); assertThat(is.read(), equalTo(2)); assertThat(is.read(), equalTo(3)); diff --git a/geowebcache/core/src/test/java/org/geowebcache/util/FileMatchers.java b/geowebcache/core/src/test/java/org/geowebcache/util/FileMatchers.java index b3149b5a9..8a0ecabd3 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/util/FileMatchers.java +++ b/geowebcache/core/src/test/java/org/geowebcache/util/FileMatchers.java @@ -247,7 +247,7 @@ public static Matcher resource(final Resource expected) { public boolean matches(Object item) { if (item instanceof Resource) { try (InputStream itemStream = ((Resource) item).getInputStream(); - InputStream expectedStream = expected.getInputStream(); ) { + InputStream expectedStream = expected.getInputStream()) { return IOUtils.contentEquals(itemStream, expectedStream); } catch (IOException e) { return false; diff --git a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/ExpirationPolicy.java b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/ExpirationPolicy.java index cc89debd5..910250e85 100644 --- a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/ExpirationPolicy.java +++ b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/ExpirationPolicy.java @@ -16,5 +16,5 @@ public enum ExpirationPolicy { LRU, - LFU; + LFU } diff --git a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/ConfigLoaderTest.java b/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/ConfigLoaderTest.java index 1d11e42ad..c9c8bc475 100644 --- a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/ConfigLoaderTest.java +++ b/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/ConfigLoaderTest.java @@ -68,7 +68,7 @@ public void setUp() throws Exception { // copy configuration file to cache directory try (InputStream in = getClass().getResourceAsStream("/geowebcache-diskquota.xml"); FileOutputStream out = - new FileOutputStream(new File(cacheDir, "geowebcache-diskquota.xml")); ) { + new FileOutputStream(new File(cacheDir, "geowebcache-diskquota.xml"))) { int c; while ((c = in.read()) != -1) { out.write(c); diff --git a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreTest.java b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreTest.java index 65675cc9e..42f718c8d 100644 --- a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreTest.java +++ b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreTest.java @@ -283,7 +283,7 @@ protected BasicDataSource getDataSource() throws IOException, SQLException { protected void cleanupDatabase(DataSource dataSource) throws SQLException { // cleanup try (Connection cx = dataSource.getConnection(); - Statement st = cx.createStatement(); ) { + Statement st = cx.createStatement()) { try { st.execute("DROP TABLE TILEPAGE CASCADE"); } catch (Exception e) { diff --git a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OracleQuotaStoreTest.java b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OracleQuotaStoreTest.java index 84f92094a..11e3a2b2e 100644 --- a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OracleQuotaStoreTest.java +++ b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OracleQuotaStoreTest.java @@ -52,7 +52,7 @@ protected BasicDataSource getDataSource() throws IOException, SQLException { // cleanup try (Connection cx = dataSource.getConnection(); - Statement st = cx.createStatement(); ) { + Statement st = cx.createStatement()) { try { st.execute("DROP TABLE TILEPAGE CASCADE CONSTRAINTS"); } catch (Exception e) { diff --git a/geowebcache/georss/src/test/java/org/geowebcache/georss/GeoRSSTileRangeBuilderTest.java b/geowebcache/georss/src/test/java/org/geowebcache/georss/GeoRSSTileRangeBuilderTest.java index 1d4045514..e8f17776e 100644 --- a/geowebcache/georss/src/test/java/org/geowebcache/georss/GeoRSSTileRangeBuilderTest.java +++ b/geowebcache/georss/src/test/java/org/geowebcache/georss/GeoRSSTileRangeBuilderTest.java @@ -119,7 +119,7 @@ private void assertLatestUpdate(String expected, String fileName) throws IOException, XMLStreamException, FactoryConfigurationError { try (InputStream stream = getClass().getResourceAsStream("test-data/" + fileName); - Reader feed = new BufferedReader(new InputStreamReader(stream, UTF_8)); ) { + Reader feed = new BufferedReader(new InputStreamReader(stream, UTF_8))) { StaxGeoRSSReader reader = new StaxGeoRSSReader(feed); GeoRSSTileRangeBuilder b = new GeoRSSTileRangeBuilder(layer, gridsetId, 10); b.buildTileRangeMask(reader, null); diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ByteStreamController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ByteStreamController.java index eba08de49..5e579d6b2 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ByteStreamController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ByteStreamController.java @@ -121,7 +121,7 @@ ResponseEntity doGet(HttpServletRequest request, HttpServletResponse response response.setContentType(mime.getFormat()); try (InputStream inputStream = resource.openStream(); - ServletOutputStream outputStream = response.getOutputStream(); ) { + ServletOutputStream outputStream = response.getOutputStream()) { StreamUtils.copy(inputStream, outputStream); } catch (IOException e) { return new ResponseEntity<>("Internal error", HttpStatus.INTERNAL_SERVER_ERROR); diff --git a/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/MbtilesBlobStore.java b/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/MbtilesBlobStore.java index 47574d27f..c44c25837 100644 --- a/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/MbtilesBlobStore.java +++ b/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/MbtilesBlobStore.java @@ -257,7 +257,7 @@ public boolean get(final TileObject tile) throws StorageException { ByteArrayInputStream byteIn = new ByteArrayInputStream(gtTile.getData()); GZIPInputStream gzIn = - new GZIPInputStream(byteIn); ) { + new GZIPInputStream(byteIn)) { IOUtils.copy(gzIn, byteOut); bytes = byteOut.toByteArray(); } diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java index 7ccf1b13e..f32335bcc 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java @@ -47,7 +47,7 @@ public void copyData() throws Exception { URL template = org.geotools.mbtiles.MBTilesFileVectorTileTest.class.getResource("planet.mbtiles"); try (InputStream in = template.openStream(); - OutputStream out = new FileOutputStream(file); ) { + OutputStream out = new FileOutputStream(file)) { IOUtils.copy(in, out); } layer = "planet"; diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java index 4ef0f39f3..94692d151 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java @@ -84,7 +84,7 @@ private static void rawSqlitle(File rootDirectory, File seedFile, long[][] tiles ExecutorService executor = Executors.newFixedThreadPool(WORKERS); long startTime = System.currentTimeMillis(); try (Connection connection = - DriverManager.getConnection("jdbc:sqlite:" + seedFile.getPath()); ) { + DriverManager.getConnection("jdbc:sqlite:" + seedFile.getPath())) { for (int i = 0; i < tiles.length; i++) { long[] tile = tiles[i]; executor.submit((Runnable) () -> getTile(connection, tile)); @@ -383,7 +383,7 @@ private static byte[] getTile(Connection connection, long[] xyz) { statement.setLong(1, xyz[2]); statement.setLong(2, xyz[0]); statement.setLong(3, xyz[1]); - try (ResultSet resultSet = statement.executeQuery(); ) { + try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { // the tile exists byte[] data = resultSet.getBytes(1); diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/TestSupport.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/TestSupport.java index c140bf86a..16d178928 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/TestSupport.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/TestSupport.java @@ -94,7 +94,7 @@ protected File buildFile(String... pathParts) { protected void writeToFile(File file, String content) { Utils.createFileParents(file); - try (FileWriter writer = new FileWriter(file); ) { + try (FileWriter writer = new FileWriter(file)) { writer.write(content); writer.flush(); } catch (Exception exception) { diff --git a/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSGetCapabilities.java b/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSGetCapabilities.java index 4822777a3..5d2db9d55 100644 --- a/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSGetCapabilities.java +++ b/geowebcache/wms/src/main/java/org/geowebcache/service/wms/WMSGetCapabilities.java @@ -98,7 +98,7 @@ protected void writeResponse(HttpServletResponse response) { response.setContentLength(data.length); response.setHeader("content-disposition", "inline;filename=wms-getcapabilities.xml"); - try (OutputStream os = response.getOutputStream(); ) { + try (OutputStream os = response.getOutputStream()) { os.write(data); os.flush(); } catch (IOException ioe) {