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