diff --git a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java index 4a5ac008d2..b817ecdd33 100644 --- a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java +++ b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java @@ -40,7 +40,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.Proxy; -import java.net.URL; +import java.net.URI; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -86,7 +86,7 @@ public AzureClient(AzureBlobStoreData configuration) throws StorageException { PipelineOptions options = new PipelineOptions().withClient(client); ServiceURL serviceURL = new ServiceURL( - new URL(getServiceURL(configuration)), + new URI(getServiceURL(configuration)).toURL(), StorageURL.createPipeline(creds, options)); String containerName = configuration.getContainer(); 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 e9c65be9cb..ca58a432ce 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java +++ b/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java @@ -24,6 +24,8 @@ import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; @@ -266,13 +268,13 @@ public void setDefaultValues(TileLayer layer) { URL proxyUrl = null; try { if (getGwcConfig().getProxyUrl() != null) { - proxyUrl = new URL(getGwcConfig().getProxyUrl()); + proxyUrl = new URI(getGwcConfig().getProxyUrl()).toURL(); log.fine("Using proxy " + proxyUrl.getHost() + ":" + proxyUrl.getPort()); } else if (wl.getProxyUrl() != null) { - proxyUrl = new URL(wl.getProxyUrl()); + proxyUrl = new URI(wl.getProxyUrl()).toURL(); log.fine("Using proxy " + proxyUrl.getHost() + ":" + proxyUrl.getPort()); } - } catch (MalformedURLException e) { + } catch (MalformedURLException | URISyntaxException e) { log.log( Level.SEVERE, "could not parse proxy URL " diff --git a/geowebcache/core/src/main/java/org/geowebcache/config/XMLOldGrid.java b/geowebcache/core/src/main/java/org/geowebcache/config/XMLOldGrid.java index b2e465b7d1..f4b2e11378 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/config/XMLOldGrid.java +++ b/geowebcache/core/src/main/java/org/geowebcache/config/XMLOldGrid.java @@ -22,6 +22,7 @@ import org.geowebcache.grid.GridSubset; import org.geowebcache.grid.GridSubsetFactory; import org.geowebcache.grid.SRS; +import org.geowebcache.util.SuppressFBWarnings; /** * This class exists mainly to parse the old XML objects using XStream @@ -29,6 +30,11 @@ *

The problem is that it cannot use the GridSetBroker, so we end up with one GridSet per layer * anyway. */ +@SuppressFBWarnings({ + "NP_UNWRITTEN_FIELD", + "NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", + "UWF_NULL_FIELD" +}) // field assignment done by XStream public class XMLOldGrid implements Serializable { private static final long serialVersionUID = 1413422643636728997L; diff --git a/geowebcache/core/src/main/java/org/geowebcache/filter/request/WMSRasterFilter.java b/geowebcache/core/src/main/java/org/geowebcache/filter/request/WMSRasterFilter.java index 4e866e324a..9f91de4275 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/filter/request/WMSRasterFilter.java +++ b/geowebcache/core/src/main/java/org/geowebcache/filter/request/WMSRasterFilter.java @@ -18,6 +18,9 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.HashMap; import java.util.Map; @@ -110,7 +113,13 @@ protected BufferedImage loadMatrix(TileLayer tlayer, String gridSetId, int z) + ") , " + urlStr); - URL wmsUrl = new URL(urlStr); + URL wmsUrl; + try { + wmsUrl = new URI(urlStr).toURL(); + } catch (URISyntaxException e) { + // preserve behavior from when new URL(urlStr) was used + throw new MalformedURLException(e.getMessage()); + } if (backendTimeout == null) { backendTimeout = 120; 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 93b7729900..09a545754a 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java @@ -113,7 +113,7 @@ public TileLayer getTileLayer(final String layerName) throws GeoWebCacheExceptio } throw new GeoWebCacheException( "Thread " - + Thread.currentThread().getId() + + Thread.currentThread().getName() + " Unknown layer " + layerName + ". Check the logfiles," diff --git a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java index 58fa3b66c4..9dfb789af8 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java @@ -18,6 +18,8 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLEncoder; import java.nio.channels.Channels; @@ -115,8 +117,8 @@ protected void makeRequest( String requestUrl = layer.nextWmsURL(); try { - wmsBackendUrl = new URL(requestUrl); - } catch (MalformedURLException maue) { + wmsBackendUrl = new URI(requestUrl).toURL(); + } catch (URISyntaxException | MalformedURLException maue) { throw new GeoWebCacheException( "Malformed URL: " + requestUrl + " " + maue.getMessage()); } 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 c5acd475e4..2998383ca7 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 @@ -16,6 +16,8 @@ import java.io.IOException; import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; @@ -803,9 +805,9 @@ public void proxyRequest(ConveyorTile tile) throws GeoWebCacheException { try { URL url; if (serverStr.contains("?")) { - url = new URL(serverStr + "&" + queryStr); + url = new URI(serverStr + "&" + queryStr).toURL(); } else { - url = new URL(serverStr + queryStr); + url = new URI(serverStr + queryStr).toURL(); } WMSSourceHelper helper = getSourceHelper(); @@ -839,7 +841,7 @@ public void proxyRequest(ConveyorTile tile) throws GeoWebCacheException { } } } - } catch (IOException ioe) { + } catch (IOException | URISyntaxException ioe) { tile.servletResp.setStatus(500); log.log(Level.SEVERE, ioe.getMessage()); } diff --git a/geowebcache/core/src/main/java/org/geowebcache/locks/NIOLockProvider.java b/geowebcache/core/src/main/java/org/geowebcache/locks/NIOLockProvider.java index 500945e1b3..cdedf4aa7f 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/locks/NIOLockProvider.java +++ b/geowebcache/core/src/main/java/org/geowebcache/locks/NIOLockProvider.java @@ -115,7 +115,7 @@ public LockProvider.Lock getLock(final String lockKey) throws GeoWebCacheExcepti "Lock " + lockKey + " acquired by thread " - + Thread.currentThread().getId() + + Thread.currentThread().getName() + " on file " + file); } @@ -151,7 +151,7 @@ public void release() throws GeoWebCacheException { + " for releasing lock is unkonwn, it means " + "this lock was never acquired, or was released twice. " + "Current thread is: " - + Thread.currentThread().getId() + + Thread.currentThread().getName() + ". " + "Are you running two GWC instances in the same JVM using NIO locks? " + "This case is not supported and will generate exactly this error message"); @@ -170,7 +170,7 @@ public void release() throws GeoWebCacheException { + " on file " + lockFile + " released by thread " - + Thread.currentThread().getId()); + + Thread.currentThread().getName()); } } catch (IOException e) { throw new GeoWebCacheException( diff --git a/geowebcache/core/src/main/java/org/geowebcache/proxy/ProxyDispatcher.java b/geowebcache/core/src/main/java/org/geowebcache/proxy/ProxyDispatcher.java index 1db4fe9527..4b3f16113d 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/proxy/ProxyDispatcher.java +++ b/geowebcache/core/src/main/java/org/geowebcache/proxy/ProxyDispatcher.java @@ -15,6 +15,7 @@ package org.geowebcache.proxy; import java.net.HttpURLConnection; +import java.net.URI; import java.net.URL; import java.net.URLDecoder; import java.util.logging.Logger; @@ -62,7 +63,7 @@ protected ModelAndView handleRequestInternal( } String decodedUrl = URLDecoder.decode(urlStr, charEnc); - URL url = new URL(decodedUrl); + URL url = new URI(decodedUrl).toURL(); HttpURLConnection wmsBackendCon = (HttpURLConnection) url.openConnection(); if (wmsBackendCon.getContentEncoding() != null) { diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/BlobStoreAggregator.java b/geowebcache/core/src/main/java/org/geowebcache/storage/BlobStoreAggregator.java index 1ccbe669cf..bc6d841ae2 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/BlobStoreAggregator.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/BlobStoreAggregator.java @@ -103,7 +103,7 @@ public BlobStoreInfo getBlobStore(final String blobStoreName) throws GeoWebCache () -> new GeoWebCacheException( "Thread " - + Thread.currentThread().getId() + + Thread.currentThread().getName() + " Unknown blob store " + blobStoreName + ". Check the logfiles," diff --git a/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/FileBlobStoreComformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/FileBlobStoreComformanceTest.java index b4e9397e12..0050490bf5 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/FileBlobStoreComformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/FileBlobStoreComformanceTest.java @@ -50,6 +50,7 @@ public void createTestUnit() throws Exception { private void putLayerMetadataConcurrently( final int srcStoreKey, final FileBlobStore srcStore, int numberOfThreads) throws InterruptedException { + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService service = Executors.newFixedThreadPool(numberOfThreads); CountDownLatch latch = new CountDownLatch(numberOfThreads); for (int i = 0; i < numberOfThreads; i++) { @@ -75,6 +76,7 @@ private void putLayerMetadataConcurrently( private void executeStoresConcurrently(int numberOfStores, int numberOfThreads) throws InterruptedException { + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService service = Executors.newFixedThreadPool(numberOfStores); CountDownLatch latch = new CountDownLatch(numberOfStores); for (int i = 0; i < numberOfStores; i++) { @@ -106,6 +108,7 @@ public void testMetadataWithPointInKey() throws Exception { public void testConcurrentMetadataWithPointInKey() throws InterruptedException { assertThat(store.getLayerMetadata("testLayer", "test.Key"), nullValue()); int numberOfThreads = 2; + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService service = Executors.newFixedThreadPool(numberOfThreads); CountDownLatch latch = new CountDownLatch(numberOfThreads); for (int i = 0; i < numberOfThreads; i++) { 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 9e967a28f3..2b6ef36c9e 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java @@ -345,6 +345,7 @@ public void testConcurrentAdds() throws Exception { defaultCount + 10, getInfoNames(config).size()); // get a thread pool + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService pool = Executors.newFixedThreadPool( 16, (Runnable r) -> new Thread(r, "Info Concurrency Test for ADD")); @@ -389,6 +390,7 @@ public void testConcurrentDeletes() throws Exception { defaultCount + 100, getInfoNames(config).size()); // get a thread pool + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService pool = Executors.newFixedThreadPool( 16, (Runnable r) -> new Thread(r, "Info Concurrency Test for DELETE")); @@ -431,6 +433,7 @@ public void testConcurrentModifies() throws Exception { defaultCount + 100, getInfoNames(config).size()); // get a thread pool + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService pool = Executors.newFixedThreadPool( 16, (Runnable r) -> new Thread(r, "Info Concurrency Test for MODIFY")); diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/DefaultingConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/DefaultingConfigurationTest.java index 6b5a2e1457..1d2b68a39f 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/DefaultingConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/DefaultingConfigurationTest.java @@ -19,6 +19,8 @@ import static org.junit.Assert.assertNull; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; import java.util.Set; @@ -111,11 +113,11 @@ public void setDefaultValues(TileLayer layer) { URL proxyUrl = null; try { if (getGwcConfig().getProxyUrl() != null) { - proxyUrl = new URL(getGwcConfig().getProxyUrl()); + proxyUrl = new URI(getGwcConfig().getProxyUrl()).toURL(); } else if (wl.getProxyUrl() != null) { - proxyUrl = new URL(wl.getProxyUrl()); + proxyUrl = new URI(wl.getProxyUrl()).toURL(); } - } catch (MalformedURLException e) { + } catch (MalformedURLException | URISyntaxException e) { } final WMSHttpHelper sourceHelper; diff --git a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java index dbb4f32a2d..353bbdaea9 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java @@ -601,6 +601,7 @@ private List getTiles( long[] gridLoc = trIter.nextMetaGridLocation(new long[3]); // six concurrent requests max + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService requests = Executors.newFixedThreadPool(6); ExecutorCompletionService completer = new ExecutorCompletionService<>(requests); diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/TileRangeIteratorTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/TileRangeIteratorTest.java index 0a096a751b..2108b390e5 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/TileRangeIteratorTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/TileRangeIteratorTest.java @@ -215,6 +215,7 @@ private long traverseTileRangeIter( final int[] metaTilingFactors) throws Exception { + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 final ExecutorService executorService = Executors.newFixedThreadPool(nThreads); final TileRange tileRange; diff --git a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/storage/PagePyramid.java b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/storage/PagePyramid.java index b558728661..579db35cd6 100644 --- a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/storage/PagePyramid.java +++ b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/storage/PagePyramid.java @@ -16,7 +16,6 @@ import java.math.BigInteger; import java.text.NumberFormat; -import java.util.Locale; import java.util.Map; import java.util.TreeMap; import org.geowebcache.grid.GridSubset; @@ -84,7 +83,7 @@ public PageLevelInfo( @Override public String toString() { - NumberFormat nf = NumberFormat.getInstance(new Locale("es")); + NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(true); return "Pages: " diff --git a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PagePyramidTest.java b/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PagePyramidTest.java index 1aa008da3e..cd0d1d0502 100644 --- a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PagePyramidTest.java +++ b/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PagePyramidTest.java @@ -22,7 +22,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Locale; import java.util.logging.Logger; import org.geotools.util.logging.Logging; import org.geowebcache.config.DefaultGridsets; @@ -76,7 +75,7 @@ public void testCalculatePageInfo() { } private void printPyramid(int zoomStart, int zoomStop, PagePyramid pp) { - NumberFormat nf = NumberFormat.getInstance(new Locale("es")); + NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(true); long totalPages = 0; diff --git a/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPollTask.java b/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPollTask.java index 1c9b5be259..8a23d1b4a8 100644 --- a/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPollTask.java +++ b/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPollTask.java @@ -17,6 +17,9 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.Iterator; import java.util.LinkedList; @@ -128,7 +131,12 @@ private void runPollAndLaunchSeed() throws IOException { final String previousUpdatedEntry = storageBroker.getLayerMetadata(layerName, LAST_UPDATED); final String gridSetId = pollDef.getGridSetId(); - final URL feedUrl = new URL(templateFeedUrl(pollDef.getFeedUrl(), previousUpdatedEntry)); + URL feedUrl; + try { + feedUrl = new URI(templateFeedUrl(pollDef.getFeedUrl(), previousUpdatedEntry)).toURL(); + } catch (URISyntaxException e) { + throw new MalformedURLException(e.getMessage()); + } final String httpUsername = pollDef.getHttpUsername(); final String httpPassword = pollDef.getHttpUsername(); diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java index 9e3b0fb4b7..d472f3d074 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java @@ -161,6 +161,7 @@ private void genericMultiThreadsTest( int threadsNumber, int workersNumber, long poolSize, File... files) throws Exception { SqliteConnectionManager connectionManager = new SqliteConnectionManager(poolSize, 10); connectionManagersToClean.add(connectionManager); + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService executor = Executors.newFixedThreadPool(threadsNumber); Random random = new Random(); List>> results = new ArrayList<>(); 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 da6fe3ac53..4ef0f39f3c 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java @@ -80,6 +80,7 @@ private static void rawSqlitle(File rootDirectory, File seedFile, long[][] tiles } FileUtils.copyFile(seedFile, databaseFile); // submitting the select tasks + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService executor = Executors.newFixedThreadPool(WORKERS); long startTime = System.currentTimeMillis(); try (Connection connection = @@ -124,6 +125,7 @@ private static void pooledSqlitle(File rootDirectory, File seedFile, long[][] ti } FileUtils.copyFile(seedFile, databaseFile); // submitting the select tasks + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService executor = Executors.newFixedThreadPool(WORKERS); SqliteConnectionManager connectionManager = new SqliteConnectionManager(10, 2000); long startTime = System.currentTimeMillis(); @@ -179,6 +181,7 @@ private static void mbtilesStore(File rootDirectory, File seedFile, long[][] til } FileUtils.copyFile(seedFile, databaseFile); // submitting the select tasks + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService executor = Executors.newFixedThreadPool(WORKERS); long startTime = System.currentTimeMillis(); // mbtiles store configuration @@ -240,6 +243,7 @@ private static void fileStore(File seedDirectory, long[][] tiles) throws Excepti LOGGER.info(String.format("Start reading from directory'%s'.", seedDirectory)); } // submitting the read tasks + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ExecutorService executor = Executors.newFixedThreadPool(WORKERS); long startTime = System.currentTimeMillis(); // instantiate the file blobstore diff --git a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java index 3a4b82c14b..69bd951611 100644 --- a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java +++ b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java @@ -696,6 +696,7 @@ public void deleteByParametersId() { @Ignore // unreliable test timing public void deleteWhenUploadExists() throws Exception { BlockingQueue taskQueue = spy(new LinkedBlockingQueue<>(1000)); + @SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21 ThreadPoolExecutor executor = spy( new ThreadPoolExecutor( diff --git a/geowebcache/wms/src/main/java/org/geowebcache/config/wms/GetCapabilitiesConfiguration.java b/geowebcache/wms/src/main/java/org/geowebcache/config/wms/GetCapabilitiesConfiguration.java index 5da8b4ab5b..f9f8e148c4 100644 --- a/geowebcache/wms/src/main/java/org/geowebcache/config/wms/GetCapabilitiesConfiguration.java +++ b/geowebcache/wms/src/main/java/org/geowebcache/config/wms/GetCapabilitiesConfiguration.java @@ -16,7 +16,9 @@ import com.google.common.collect.Sets; import java.io.IOException; -import java.net.URL; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -521,7 +523,11 @@ private WMSLayer getLayer( WebMapServer getWMS() throws IOException, ServiceException { Map hints = new HashMap<>(); hints.put(XMLHandlerHints.ENTITY_RESOLVER, PreventLocalEntityResolver.INSTANCE); - return new WebMapServer(new URL(url), HTTPClientFinder.createClient(), hints); + try { + return new WebMapServer(new URI(url).toURL(), HTTPClientFinder.createClient(), hints); + } catch (URISyntaxException e) { + throw new MalformedURLException(e.getMessage()); + } } private String parseVersion(String url) { diff --git a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesConfigurationTest.java b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesConfigurationTest.java index 7dd0e02679..1727b04015 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesConfigurationTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesConfigurationTest.java @@ -29,7 +29,7 @@ import static org.junit.Assert.assertThat; import com.google.common.collect.Sets; -import java.net.URL; +import java.net.URI; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; @@ -78,8 +78,8 @@ public void setUp() throws Exception { expect(req.getGetCapabilities()).andStubReturn(gcOpType); expect(gcOpType.getGet()) .andStubReturn( - new URL( - "http://test/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities")); + new URI("http://test/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities") + .toURL()); expect(cap.getVersion()).andStubReturn("1.1.1"); } @@ -215,8 +215,8 @@ WebMapServer getWMS() { expect(req.getGetCapabilities()).andStubReturn(gcOpType); expect(gcOpType.getGet()) .andStubReturn( - new URL( - "http://test/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities")); + new URI("http://test/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities") + .toURL()); expect(cap.getVersion()).andStubReturn("1.1.1"); 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 0e61c35f7c..a712203dbb 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 @@ -22,7 +22,7 @@ import static org.junit.Assert.assertThat; import com.google.common.base.Objects; -import java.net.URL; +import java.net.URI; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -97,8 +97,8 @@ protected GridSetConfiguration getConfig() throws Exception { expect(req.getGetCapabilities()).andStubReturn(gcOpType); expect(gcOpType.getGet()) .andStubReturn( - new URL( - "http://test/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities")); + new URI("http://test/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities") + .toURL()); expect(cap.getVersion()).andStubReturn("1.1.1"); EasyMock.replay(server, cap, req, gcOpType, globalConfig); diff --git a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java index 7c456bf476..8095b762dc 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java @@ -19,7 +19,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; -import java.net.URL; +import java.net.URI; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -120,8 +120,8 @@ protected TileLayerConfiguration getConfig() throws Exception { expect(req.getGetCapabilities()).andStubReturn(gcOpType); expect(gcOpType.getGet()) .andStubReturn( - new URL( - "http://test/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities")); + new URI("http://test/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities") + .toURL()); expect(cap.getVersion()).andStubReturn("1.1.1"); EasyMock.replay(server, cap, req, gcOpType, globalConfig); 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 a3def36831..05ccc52e9e 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 @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.net.URI; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -358,7 +359,9 @@ public void testGetCap() throws Exception { // add some layer metadata MetadataURL metadataURL = new MetadataURL( - "some-type", "some-format", new URL("http://localhost:8080/some-url")); + "some-type", + "some-format", + new URI("http://localhost:8080/some-url").toURL()); when(tileLayer.getMetadataURLs()).thenReturn(Collections.singletonList(metadataURL)); }