From de648b8e35a1f59e7f9350589522f2b0dc872cf0 Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Tue, 8 Jul 2025 18:36:18 -0300 Subject: [PATCH] Upgrade GeoWebCache build to Java 17 * Upgrade build to use Java 17 as the baseline version. * Configure maven-enforcer-plugin to require Java 17. * Upgrade GitHub Actions workflows to use Java 17. * Update documentation for Java 17, including developer and user guides. * Upgrade Jetty from 9.x to 10.0.25, the last version to support `javax.servlet`. * Replace `com.google.common.base.Objects.equal()` with `java.util.Objects.equal()`. * Update test configurations to use `localhost:8080` instead of deprecated demo servers. * Fix REST integration tests and address other issues found during local testing on Java 17. * Increase heap size for the QA build profile. * Fix swapped Assert.equals arguments Plugin version upgrades: * maven-jar-plugin 2.4 -> 3.0.2 * maven-enforcer-plugin 3.0.0-M3 -> 3.5.0 * maven-compiler-plugin 3.10.1 -> 3.14.0 * maven-surefire-plugin 2.22.1 -> 3.5.3 * maven-failsafe-plugin 3.3.1 -> 3.5.3 * maven-war-plugin 3.3.2 -> 3.4.0 * jetty-maven-plugin 9.4.14.v20181114 -> 10.0.25 * maven-javadoc-plugin 3.4.1 -> 3.11.2 * maven-checkstyle-plugin 3.1.1 -> 3.6.0 Co-authored-by: Andrea Aime Co-authored-by: Jody Garnett --- .github/workflows/azure-integration.yml | 4 +- .github/workflows/integration.yml | 4 +- .github/workflows/linux.yml | 28 +-- .github/workflows/macos.yml | 4 +- .github/workflows/windows.yml | 4 +- RELEASE_NOTES.txt | 8 +- documentation/en/build.xml | 24 ++ .../source/configuration/layers/howto.rst | 4 +- .../en/user/source/configuration/storage.rst | 58 ++--- .../en/user/source/development/index.rst | 21 +- documentation/en/user/source/faq/index.rst | 4 +- .../user/source/installation/geowebcache.rst | 24 +- .../en/user/source/installation/index.rst | 11 +- .../installation/prerequisites/linux.rst | 31 ++- .../installation/prerequisites/macosx.rst | 53 ++++- .../installation/prerequisites/windows.rst | 36 ++- .../en/user/source/installation/upgrading.rst | 57 ++++- .../en/user/source/production/index.rst | 31 +-- .../en/user/source/quickstart/index.rst | 10 +- .../geowebcache/arcgis/config/CacheInfo.java | 1 + .../arcgis/config/CacheStorageInfo.java | 1 + .../arcgis/layer/ArcGISCacheLayer.java | 12 - .../arcgis/config/CacheInfoPersisterTest.java | 4 +- .../org/geowebcache/azure/AzureClient.java | 3 +- .../org/geowebcache/azure/DeleteManager.java | 1 + .../azure/AzureBlobStoreConformanceTest.java | 1 + .../geowebcache/GeoWebCacheDispatcher.java | 7 +- .../geowebcache/GeoWebCacheEnvironment.java | 2 +- .../config/GridSetConfiguration.java | 2 +- .../main/java/org/geowebcache/demo/Demo.java | 4 +- .../filter/parameters/ParameterFilter.java | 6 +- .../org/geowebcache/grid/BoundingBox.java | 6 +- .../java/org/geowebcache/grid/GridSubset.java | 2 +- .../java/org/geowebcache/io/XMLBuilder.java | 2 +- .../java/org/geowebcache/layer/TileLayer.java | 3 +- .../layer/TileLayerDispatcher.java | 17 +- .../layer/wms/WMSSourceHelper.java | 2 +- .../org/geowebcache/mime/FormatModifier.java | 2 +- .../java/org/geowebcache/seed/SeedTask.java | 1 + .../org/geowebcache/seed/TileBreeder.java | 2 +- .../org/geowebcache/service/OWSException.java | 5 + .../org/geowebcache/stats/RuntimeStats.java | 12 +- .../storage/BlobStoreAggregator.java | 2 + .../storage/CompositeBlobStore.java | 1 + .../storage/UnsuitableStorageException.java | 1 + .../blobstore/file/DefaultFilePathFilter.java | 4 +- .../file/DefaultFilePathGenerator.java | 2 +- .../storage/blobstore/file/FileBlobStore.java | 6 +- .../memory/guava/GuavaCacheProvider.java | 105 +++------ .../core/src/main/resources/geowebcache.xml | 16 +- .../src/main/resources/geowebcache_empty.xml | 6 +- .../file/FileBlobStoreComformanceTest.java | 2 + .../file/XYZFileBlobStoreComformanceTest.java | 1 + .../config/DefaultingConfigurationTest.java | 8 +- .../config/GWCConfigIntegrationTestData.java | 3 +- ...nfigurationBackwardsCompatibilityTest.java | 28 +-- .../XMLConfigurationLayerConformanceTest.java | 9 +- .../geowebcache/layer/wms/MetaTileTest.java | 6 +- .../geowebcache/layer/wms/WMSLayerTest.java | 3 +- .../org/geowebcache/mime/XMLMimeTest.java | 1 + .../geowebcache/config/geowebcache_1100.xml | 6 +- .../geowebcache/config/geowebcache_1110.xml | 6 +- .../geowebcache/config/geowebcache_1120.xml | 6 +- .../geowebcache/config/geowebcache_1130.xml | 6 +- .../geowebcache/config/geowebcache_1140.xml | 6 +- .../geowebcache/config/geowebcache_1150.xml | 6 +- .../geowebcache/config/geowebcache_1170.xml | 6 +- .../geowebcache/config/geowebcache_1180.xml | 6 +- .../geowebcache/config/geowebcache_1190.xml | 6 +- .../geowebcache/config/geowebcache_1200.xml | 6 +- .../geowebcache/config/geowebcache_1210.xml | 6 +- .../geowebcache/config/geowebcache_1220.xml | 6 +- .../geowebcache/config/geowebcache_1230.xml | 6 +- .../geowebcache/config/geowebcache_1240.xml | 6 +- .../geowebcache/config/geowebcache_1250.xml | 6 +- .../geowebcache/config/geowebcache_126.xml | 2 +- .../geowebcache/config/geowebcache_1260.xml | 6 +- .../geowebcache/config/geowebcache_140.xml | 6 +- .../geowebcache/config/geowebcache_150.xml | 6 +- .../geowebcache/config/geowebcache_151.xml | 6 +- .../geowebcache/config/geowebcache_153.xml | 6 +- .../geowebcache/config/geowebcache_160.xml | 6 +- .../geowebcache/config/geowebcache_161.xml | 6 +- .../geowebcache/config/geowebcache_170.xml | 6 +- .../geowebcache/config/geowebcache_180.xml | 6 +- .../geowebcache/config/geowebcache_190.xml | 6 +- .../config/geowebcache_4326_override.xml | 6 +- .../diskquota/bdb/BDBQuotaStore.java | 6 +- .../diskquota/bdb/DiskQuotaEntityModel.java | 6 +- .../diskquota/BDBQuotaStoreTest.java | 14 +- .../diskquota/LayerCacheInfoBuilder.java | 4 +- .../diskquota/storage/PagePyramid.java | 2 +- .../diskquota/ConfigLoaderTest.java | 7 +- .../diskquota/storage/PagePyramidTest.java | 10 +- .../diskquota/storage/PageStatsTest.java | 2 +- .../diskquota/jdbc/JDBCQuotaStoreFactory.java | 2 +- .../diskquota/jdbc/JDBCQuotaStoreTest.java | 16 +- .../diskquota/jdbc/OnlineTestRule.java | 3 +- .../src/test/resources/gwc-test-config.xml | 2 +- .../geowebcache/georss/GeoRSSPollTask.java | 1 + .../service/gmaps/GMapsConverterTest.java | 18 +- .../geowebcache/service/kml/KMLService.java | 6 +- .../geowebcache/service/kml/KMLSiteMap.java | 2 +- .../mbtiles/layer/MBTilesLayer.java | 11 - .../mbtiles/layer/MBTilesLayerTest.java | 1 + geowebcache/pom.xml | 221 ++++++++++++++---- .../rest/exception/RestException.java | 1 + .../main/java/org/geowebcache/s3/S3Ops.java | 1 + .../s3/S3BlobStoreConformanceTest.java | 1 + .../geowebcache/sqlite/MbtilesBlobStore.java | 2 +- .../java/org/geowebcache/sqlite/Utils.java | 4 + .../sqlite/SqliteConnectionManagerTest.java | 3 + .../geowebcache/swift/SwiftBlobStoreTest.java | 35 ++- .../service/tms/TMSDocumentFactory.java | 4 +- .../service/tms/TMSServiceTest.java | 4 +- geowebcache/web/pom.xml | 8 +- .../jetty/RestIntegrationTest.java | 25 +- .../java/org/geowebcache/jetty/Start.java | 2 +- .../io/codec/ImageEncoderImpl.java | 7 +- .../geowebcache/service/wms/WMSTileFuser.java | 7 +- ...esGridSetConfigurationConformanceTest.java | 4 +- .../service/wms/WMSServiceTest.java | 1 + .../service/wms/WMSTileFuserTest.java | 1 + .../geowebcache/service/wmts/WMTSService.java | 8 +- .../geowebcache/service/wmts/WMTSUtils.java | 4 +- .../service/wmts/WMTSServiceTest.java | 31 +-- .../service/wmts/geowebcache_190.xml | 6 +- 127 files changed, 783 insertions(+), 586 deletions(-) diff --git a/.github/workflows/azure-integration.yml b/.github/workflows/azure-integration.yml index fc5d1b6d08..66c31eff6a 100644 --- a/.github/workflows/azure-integration.yml +++ b/.github/workflows/azure-integration.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java-version: [ 11, 17, 21 ] + java-version: [ 17, 21 ] steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v3 @@ -57,7 +57,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 11 + java-version: 17 cache: 'maven' - name: Tests against Azure diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index bbd1d5f0b7..6b770666fa 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -16,10 +16,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: 'temurin' - uses: actions/checkout@v4 - name: Maven repository caching diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 4eded7375f..ebdade421a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -7,31 +7,9 @@ concurrency: cancel-in-progress: true env: - MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=3 -Xmx512m -Djava.awt.headless=true -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS + MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=3 -Xmx1g -Djava.awt.headless=true -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS jobs: - openjdk11: - runs-on: [ubuntu-22.04] - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: 'temurin' - - name: Maven repository caching - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: gwc-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Build with Maven - run: mvn -B clean install -Dspotless.apply.skip=true -Dall -T2 --file geowebcache/pom.xml - - name: Remove SNAPSHOT jars from repository - run: | - find .m2/repository -name "*SNAPSHOT*" -type d | xargs rm -rf {} - openjdk17: runs-on: [ubuntu-22.04] steps: @@ -80,10 +58,10 @@ jobs: runs-on: [ubuntu-22.04] steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: 'temurin' - name: Maven repository caching uses: actions/cache@v3 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 2043e3f59e..76a9c5bbda 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -13,10 +13,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: 'temurin' - name: Maven repository caching uses: actions/cache@v3 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e586d4a01c..7dee5c691e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -13,10 +13,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: 'temurin' - name: Maven repository caching uses: actions/cache@v3 diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index ba08337922..2d70b1fe3b 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,16 +1,20 @@ GeoWebCache 1.28-SNAPSHOT (2025-04-03) -------------------------------------- - +Stable release, GeoNetwork 1.28.0 is the first release requiring a Java 17 environment. Improvements: +++++++++++++ -- +- Java 17 minimum Fixes: ++++++ - +Updates: +++++++++ + +- Upgrade to GeoTools 34.x GeoWebCache 1.27.0 (2025-04-02) ------------------------------ diff --git a/documentation/en/build.xml b/documentation/en/build.xml index 448c4ad15a..5bc746d1da 100644 --- a/documentation/en/build.xml +++ b/documentation/en/build.xml @@ -49,6 +49,7 @@ + @@ -72,6 +73,8 @@ + + @@ -79,6 +82,17 @@ + + + + + + @@ -88,6 +102,16 @@ + + + + + diff --git a/documentation/en/user/source/configuration/layers/howto.rst b/documentation/en/user/source/configuration/layers/howto.rst index 441196d84d..92de9d2cc6 100644 --- a/documentation/en/user/source/configuration/layers/howto.rst +++ b/documentation/en/user/source/configuration/layers/howto.rst @@ -33,8 +33,8 @@ It is recommended to use a special XML editing tool or at the very least a text Two recommended free editors, both of which have support for XML validation, are: -* `jEdit `_ (cross platform) -* `Notepad++ `_ (Windows only) +* `jEdit `_ (cross platform) +* `Notepad++ `_ (Windows only) It is also possible to validate an XML document outside of a text editor environment. diff --git a/documentation/en/user/source/configuration/storage.rst b/documentation/en/user/source/configuration/storage.rst index 86cf4ef47f..934743d508 100644 --- a/documentation/en/user/source/configuration/storage.rst +++ b/documentation/en/user/source/configuration/storage.rst @@ -23,13 +23,15 @@ does not explicitly indicate which blobstore shall be used. .. note:: **there will always be a "default" blobstore**. If a blobstore to be used by default is not explicitly configured, one will be created automatically following the legacy cache location lookup mechanism used in versions prior to 1.8.0. - + +.. _configuration.file + Configuration File ------------------ -The location of the configuration file, :file:`geowebcache.xml`, will be defined by the ``GEOWEBCACHE_CACHE_DIR`` application argument. +The location of the configuration file, :file:`geowebcache.xml`, will be defined by the ``GEOWEBCACHE_CACHE_DIR`` application parameter. -There are a few ways to define this argument: +There are a few ways to define ``GEOWEBCACHE_CACHE_DIR``: * JVM system environment variable * Servlet context parameteter @@ -37,39 +39,41 @@ There are a few ways to define this argument: The variable in all cases is defined as ``GEOWEBCACHE_CACHE_DIR``. -To set as a JVM system environment variable, add the parameter ``-DGEOWEBCACHE_CACHE_DIR=`` to your servlet startup script. -In Tomcat, this can be added to the Java Options (JAVA_OPTS) variable in the startup script. - -To set as a servlet context parameter, edit the GeoWebCache :file:`web.xml` file and add the following code: - -.. code-block:: xml - - - GEOWEBCACHE_CACHE_DIR - PATH - - -where ``PATH`` is the location of the cache directory. +1. To set as a JVM system environment variable, add the parameter ``-DGEOWEBCACHE_CACHE_DIR=`` to your servlet startup script. -To set as an operating system environment variable, run one of the the following commands: + In Tomcat, this can be added to the Java Options (``JAVA_OPTS``) variable in the startup script, or by creating :file:`setenv.sh` / :file:`setenv.bat`: -Windows:: +2. To set as a servlet context parameter, edit the GeoWebCache :file:`web.xml` file and add the following code: - > set GEOWEBCACHE_CACHE_DIR= + .. code-block:: xml + + + GEOWEBCACHE_CACHE_DIR + PATH + -Linux/OS X:: + where ``PATH`` is the location of the cache directory. - $ export GEOWEBCACHE_CACHE_DIR= +3. To set as an operating system environment variable, run one of the the following commands: -Finally, although not recommended, it is possible to set this location directly in the :file:`geowebcache-core-context.xml` file. Uncomment this code: + Windows:: + + > set GEOWEBCACHE_CACHE_DIR= + + Linux/OS X:: + + $ export GEOWEBCACHE_CACHE_DIR= -.. code-block:: xml +4. Not recommended: It is possible to set this location directly in the :file:`geowebcache-core-context.xml` file. + However this file will be replaced each update: - + .. code-block:: xml + + -making sure to edit the path. As usual, any changes to the servlet configuration files will require :ref:`configuration.reload`. + making sure to edit the path. As usual, any changes to the servlet configuration files will require :ref:`configuration.reload`. .. note:: if ``GEOWEBCACHE_CACHE_DIR`` is not provided by any of the above mentioned methods, the directory will default to the temporary storage folder specified by the web application container. (For Tomcat, this is the :file:`temp` directory inside the root.) diff --git a/documentation/en/user/source/development/index.rst b/documentation/en/user/source/development/index.rst index 4a39a77366..d71ce0b004 100644 --- a/documentation/en/user/source/development/index.rst +++ b/documentation/en/user/source/development/index.rst @@ -7,11 +7,11 @@ You are encouraged to help contribute code to GeoWebCache. To do so, you will f This is the current prerequisites: - * Java 8 (`OpenJDK `__ linux, `OpenJDK Temurin 8 ` windows and macOS installers) - * `Maven `_ - * `Git `_ + * Java 17 (`OpenJDK `__ linux, `OpenJDK Temurin 17 ` windows and macOS installers) + * `Maven `_ + * `Git `_ -Please make sure you use **Java 8** to compile to ensure that we don't accidentally use new features only available in Java 11. +Please make sure you use **Java 17** to compile to ensure that we don't accidentally use new features only available in Java 21. You are encouraged to join the `GeoWebCache Developers mailing list `__ to discuss your work. It is always a good idea to ask whether anyone else has already solved the same problem. @@ -27,28 +27,28 @@ Setting Up .. code-block:: bash - set JAVA_HOME=c:\Program Files\Temurin\jdk8u322-b06 + set JAVA_HOME=c:\Program Files\Temurin\jdk-17.0.15_6 Linux/OS X: .. code-block:: bash - export JAVA_HOME=/opt/jdk1.7.0_79 + export JAVA_HOME=/opt/jdk-17.0.15_6 -#. You can download maven from http://maven.apache.org/download.html, unpack and include the :file:`bin` directory in your PATH variable. +#. You can download maven from https://maven.apache.org/download.html, unpack and include the :file:`bin` directory in your PATH variable. Windows: .. code-block:: bash - set M2_HOME = C:\java\apache-maven-3.8.5 + set M2_HOME = C:\java\apache-maven-3.9.5 set PATH=%PATH%;%M2_HOME%\bin;%JAVA_HOME%\bin Linux: .. code-block:: bash - export M2_HOME = ~/java/apache-maven-3.8.5 + export M2_HOME = ~/java/apache-maven-3.9.5 export PATH=$PATH:$M2_HOME/bin:$JAVA_HOME/bin For more detail instructions on maven see the `download page `_. @@ -89,6 +89,9 @@ Build cd web mvn jetty:run + + The service is available on http://localhost:8081/geonetwork allowing local testing with http://localhost:8080/geoserver layers. To change the port number use ``jetty.http.port`` + as describde in `jetty 10 documentation `_. #. A WAR is built as the last step in ``mvn clean install`` above. diff --git a/documentation/en/user/source/faq/index.rst b/documentation/en/user/source/faq/index.rst index 90f2158938..0a62244195 100644 --- a/documentation/en/user/source/faq/index.rst +++ b/documentation/en/user/source/faq/index.rst @@ -4,5 +4,7 @@ Frequently Asked Questions This section will answer common questions about GeoWebCache. Does GeoWebCache support WFS feature caching? - Not currently. Earlier versions of GeoWebCache had an experimental prototype of vector feature caching, but it was highly unstable and was removed from GeoWebCache as of version 1.2.5. + Not currently. Earlier versions of GeoWebCache had an experimental prototype of vector feature caching, but it was highly unstable and was removed from GeoWebCache as of version 1.2.5. + + However when used with a vector tiles output format GeoWebCache can cache a vector representation of the features within each tile. It is up to client software to stich together the resulting shapes during vector tile rendering. diff --git a/documentation/en/user/source/installation/geowebcache.rst b/documentation/en/user/source/installation/geowebcache.rst index d51d7e0eed..289434fc93 100644 --- a/documentation/en/user/source/installation/geowebcache.rst +++ b/documentation/en/user/source/installation/geowebcache.rst @@ -3,11 +3,11 @@ Installing GeoWebCache ====================== -Once the :ref:`Java Servlet environment ` is in place, installing GeoWebCache is simple. +Once the :ref:`Java Servlet environment ` is in place: -The latest Web ARchive (WAR) file can be downloaded from `GeoWebCache.osgeo.org `_. +1. The :file:`geowebcache-war.zip` Web ARchive (WAR) file can be downloaded from `GeoWebCache.osgeo.org `_. -Unpack the zip file and make sure to read the software :ref:`license`. +2. Unpack the zip file and make sure to read the software :ref:`license`, and locate the :file:`geowebcache.war` for deployment. Option 1: Tomcat Administration Tool ------------------------------------ @@ -18,13 +18,23 @@ Option 1: Tomcat Administration Tool #. After the upload is complete, look for :guilabel:`geowebcache` in the :guilabel:`Applications` table. -#. GeoWebCache should be installed at ``http://localhost:8080/geowebcache``. +#. Once the application is started, GeoWebCache is available ``http://localhost:8080/geowebcache``. Option 2: Manual Installation ----------------------------- -The file :file:`geowebcache.war` is just a zip file. The Tomcat Administration Tool unpacks this file to a folder inside the Tomcat webapps directory called ``/webapps/geowebcache``. If you wish, you can unpack this archive manually in this location. You can also make configuration changes before copying to the webapps directory. +1. Tomcat will need to be stopped before making any changes to the webapps directory. + + Ensure that the Tomcat process is stopped before proceeding, as the JVM does not always release file handles immediately. -.. note:: Tomcat will need to be stopped before making any changes to the webapps directory. Ensure that the Tomcat process is stopped before proceeding, as the JVM does not always release file handles immediately. +2. To manually deploy: -After restarting Tomcat, GeoWebCache should be installed at ``http://localhost:8080/geowebcache``. + * Copy the file :file:`geowebcache.war` to :file:`/webapps`. + + On startup Tomcat will deploy the application to the folder :file:`/webapps/geowebcache` + + * If you wish, you can unpack this archive manually in this location. The :file:`geowebcache.war` may be treated as a zip file and be unpacked to :file:`/webapps/geowebcache`. + + This approach allows you to make configuration changes before restartig Tomcat. + +3. After restarting Tomcat, GeoWebCache is available ``http://localhost:8080/geowebcache``. diff --git a/documentation/en/user/source/installation/index.rst b/documentation/en/user/source/installation/index.rst index a675a3a04c..61a664bb47 100644 --- a/documentation/en/user/source/installation/index.rst +++ b/documentation/en/user/source/installation/index.rst @@ -3,17 +3,16 @@ Installation ============ -This section describes how to install GeoWebCache on the most common platforms. GeoWebCache will work on any operating system that supports Java 1.5, including FreeBSD and Solaris. +This section describes how to install GeoWebCache, which will work on any operating system that supports Java 17. The following software will need to be set up prior to installing GeoWebCache: - * **Java Runtime Environment (JRE)** (version 1.5 or greater, preferably from Oracle) - * **Java Servlet Container** (such as Apache Tomcat) + * **Java Runtime Environment (JRE)** (version 17 or 21) + * **Java Servlet Container** (such as Apache Tomcat or Jetty) -In essence, GeoWebCache is a set of Java classes (program files) and a number of configuration files. The combination is known as a Java Servlet, and these are commonly distributed in a zip file known as a Web ARchive, or WAR file for short. - -To use its content, we need a Java Virtual Machine and a Servlet Container. The latter is a network service that accepts requests from clients, such as web browsers, and delegates them to the appropriate servlet. +In essence, GeoWebCache is web application consisting of Java classes (program files) and a number of configuration files. The combination is known as a Java Servlet, and these are commonly distributed in a zip file known as a Web ARchive, or WAR file for short. +To run this web application, we need both a Java Runtime Environment (responsible for running the Java program files) and Servlet Container (that accepts HTTPS requests from clients, such as web browsers, and delegates them to the GeoWebCache). .. toctree:: :maxdepth: 2 diff --git a/documentation/en/user/source/installation/prerequisites/linux.rst b/documentation/en/user/source/installation/prerequisites/linux.rst index 60e1dde03a..f91af2f8d9 100644 --- a/documentation/en/user/source/installation/prerequisites/linux.rst +++ b/documentation/en/user/source/installation/prerequisites/linux.rst @@ -3,35 +3,44 @@ Linux ===== -Due to licensing issues, many Linux distributions come with a variety of Java environments. Additionally, to minimize the chance of a security breach with default settings, most versions of Tomcat are configured to not allow access to the file system. Therefore, it is highly recommended to follow these instructions, even if you already have a servlet container set up. +Many linux distirbutions provide their own distirbution of OpenJDK, or you may install your own from OpenJDK or Adoptium (as recommended below). + +Caution is required before considering your Linux distirbution of Apache Tomcat: + +* Package manager may recommend or udpate to Apache Tomcat 10 or newer (which is not supported by GeoWebCache). +* Tomcat may be configured, in the interests of security, to restrict access to the local file system. + +We recommend providing your own environment as outlined below. Java Runtime Environment ------------------------ -In your browser, navigate to ``_, and download the latest JRE (SE is fine; you do not need FX or EE). Make sure to select **Linux_x64** if you are running on an x86_64 kernel. Take note of where you saved the file. (This document will assume the file is saved in ``/home/user/Download/`` and is named ``jre16.bin`` although the file name will likely be different.) - -Next, open a shell and switch to superuser. Depending on your distribution, type ``sudo su`` or just ``su``. Then, ``cd /opt`` and run the command ``sh /home/user/Download/jre1.6.bin>``. This should install Java into /opt. If you receive the message ``ELF not found``, it probably means you need to get the ``Linux`` (i586) version instead of ``Linux_64``. +Make sure you have a Java Runtime Environment (JRE) installed on your system. GeoWebCache requires a Java 17 or Java 21 environment, available from `OpenJDK `__, `Adoptium `_, or provided by your OS distribution. +See :doc:`/installation/upgrading` for compatibility table. + Apache Tomcat ------------- -Back in your browser, navigate to ``_, find the **Tomcat 6.x** link in the **Downloads** section, and save the ``tar.gz`` file listed under **Binary Distributions / Core**. Back in your superuser shell, unpack this file as well by running ``tar xzvf /home/user/Download/apache-tomcat-a.b.c.tar.gz>`` (Make sure to use the correct file name.) +Back in your browser, navigate to ``_, find the **Tomcat 9.x** link in the **Downloads** section, and save the ``tar.gz`` file listed under **Binary Distributions / Core**. Back in your superuser shell, unpack this file as well by running ``tar xzvf /home/user/Download/apache-tomcat-9.0.106.tar.gz>`` (Make sure to use match the version numbers you downloaded name.) Set the owner of the extracted directory to be your user account: ``chown apache-tomcat-a.b.c``. -Using your favorite text editor, open ``/opt/apache-tomcat-a.b.c/bin/catalina.sh``. Because we don't want to worry about system-wide settings, we will make our changes in the top of this file. Find the line that starts with ``# OS specific support`` (around line 81), and insert the following right before, making sure to input the correct path to your JRE:: +Using your favorite text editor, open ``/opt/apache-tomcat-9.0.106/bin/catalina.sh``. Because we don't want to worry about system-wide settings, we will make our changes in the top of this file. Find the line that starts with ``# OS specific support`` (around line 81), and insert the following right before, making sure to input the correct path to your JRE: + +.. code-block:: bash - export PATH="/opt/jre1.6/bin:$PATH" + export PATH="/opt/jdk-17.0.15_6/bin:$PATH" JAVA_OPTS="-server -Xmx256M" The first line sets the the JRE just installed is the one that Tomcat uses. The second line tells Tomcat to run with server settings and to use 256MB for heap memory. (It may be possible to run with less heap memory, but this is no recommended.) On big installations you will want to use 1024MB or more. Note that this resource is shared among all servlets running in the container, so if you add more servlets later you may have to adjust this number. Access Control --------------- +^^^^^^^^^^^^^^ If you wish to use Tomcat's web administration tool, you will need to create an account for the administrator. -Open ``/opt/apache-tomcat-a.b.c/conf/tomcat-users.xml`` in a text editor. Immediately after the line containing ````, insert:: +Open ``/opt/apache-tomcat-9.0.106/conf/tomcat-users.xml`` in a text editor. Immediately after the line containing ````, insert:: @@ -39,10 +48,10 @@ Open ``/opt/apache-tomcat-a.b.c/conf/tomcat-users.xml`` in a text editor. Immedi Replace ``s3cret`` with your actual password. After making this change you will have to restart Tomcat. Controlling Tomcat ------------------- +^^^^^^^^^^^^^^^^^^ Running as your own user, you should be able to start and stop Tomcat by using the scripts -``/opt/apache-tomcat-a.b.c/bin/startup.sh`` and ``/opt/apache-tomcat-a.b.c/bin/shutdown.sh`` +``/opt/apache-tomcat-9.0.106/bin/startup.sh`` and ``/opt/apache-tomcat-a.b.c/bin/shutdown.sh`` Verify Tomcat is running by navigating to to http://localhost:8080 (the default location of the Tomcat web interface). If Tomcat is running correctly, you should see a page congratulating you on a successful installation. diff --git a/documentation/en/user/source/installation/prerequisites/macosx.rst b/documentation/en/user/source/installation/prerequisites/macosx.rst index 00e6528e81..c577b5cc8b 100644 --- a/documentation/en/user/source/installation/prerequisites/macosx.rst +++ b/documentation/en/user/source/installation/prerequisites/macosx.rst @@ -3,5 +3,56 @@ MacOS X ======= -TODO, please contribute +MacOS has a number of command line package managers for open source components. We recommend using `SDKMAN! `_ to manage Java and Tomcat environment. +Java +---- + +Make sure you have a Java Runtime Environment (JRE) installed on your system. GeoWebCache requires a Java 17 or Java 21 environment. + +* Required: Java Development Kit 17 (JDK 17) + + Open JDK: + + https://adoptium.net/temurin/releases/?version=17 Temurin 17 (LTS) - Recommended + +* SDKMan! + + .. code-block:: bash + + # list to determine latest Temurin JDK 17 + sdk list java 17 + + # Installing latest Temurin JDK 17 shown above + sdk install java 17.0.15-tem + + # Select Java for use + sdk use java 17 + +See :doc:`/installation/upgrading` for compatibility table. + +Apache Tomcat +------------- + +GeoWebCache requires Apache Tomcat 9 required for JavaEE environment. + +1. Navigate to `Tomcat 9 `_ **Downloads** section, and save the ``zip`` file listed under **Binary Distributions / Core**. + + * Tomcat 9 Required: GeoWebCache uses the JavaEE environment last supported in Tomcat 9. + + * Tomcat 10 Unsupported: GeoWebCache is not yet compatibile with the JakartaEE environment used by Tomcat 10 and newer. + +* SDKMan! + + .. code-block:: bash + + # list to determine latest Apache Tomcat 9 + sdk list tomcat 9 + + # Installing latest Tomcat 9 shown above + sdk install tomcat 9.0.102 + + # Select tomcat for use + sdk use tomcat 9.0.102 + +GeoWebCache is not compatible with Apache Tomcat 10 JakarataEE environment. diff --git a/documentation/en/user/source/installation/prerequisites/windows.rst b/documentation/en/user/source/installation/prerequisites/windows.rst index 868f9aea55..e846f3ddeb 100644 --- a/documentation/en/user/source/installation/prerequisites/windows.rst +++ b/documentation/en/user/source/installation/prerequisites/windows.rst @@ -6,27 +6,49 @@ Windows Java Runtime Environment ------------------------ -In your browser, navigate to ``_, and download the latest JRE (SE is fine; you do not need FX or EE). You can use either the Online or Offline installer. +Make sure you have a Java Runtime Environment (JRE) installed on your system. GeoWebCache requires a Java 17 or Java 21 environment. + +1. Download an OpenJDK release for your platform: + + * https://adoptium.net/temurin/releases/?version=17 Temurin 17 (LTS) (Recommended) + +2. Choose the options to: + + * Updating the JAVA_HOME environment variable + * Add the installation to the PATH environment variable + +See :doc:`/installation/upgrading` for compatibility table. Apache Tomcat ------------- -Back in your browser, navigate to ``_, find the **Tomcat 6.x** link in the **Downloads** section, and save the ``Windows Service Installer`` file listed under **Binary Distributions / Core**. Run this application to install Tomcat as a Windows service. After installing, you should have a small system tray icon. You can right click on it to ensure that it is running with the latest version of Java, and assign at least 256MB of heap memory. Note that this resource is shared among all servlets running in the container, so if you add more servlets later you may have to adjust this number. +1. Navigate to ``_, find the **Tomcat 9.x** link in the **Downloads** section, and save the ``Windows Service Installer`` file listed under **Binary Distributions / Core**. + + * Tomcat 9 Required: GeoWebCache uses the JavaEE environment last supported in Tomcat 9. + + * Tomcat 10 Unsupported: GeoWebCache is not yet compatibile with the JakartaEE environment used by Tomcat 10 and newer. +2. Run this application to install Tomcat as a Windows service. + + After installing, use the small system tray icon. You can right click on it to ensure that it is running with the latest version of Java, and assign at least 256MB of heap memory. + + Note that this resource is shared among all servlets running in the container, so if you add more servlets later you may have to adjust this number. Access Control --------------- +^^^^^^^^^^^^^^ If you wish to use Tomcat's web administration tool, you will need to create an account for the administrator. -Do this by opening the conf\tomcat-users.xml`` file in from your Tomcat Program Files directory (by default ``C:\Program Files\Apache Software Foundation\Tomcat a.b`` in a text editor. Immediately after ```` insert:: +Do this by opening the :file:`conf\tomcat-users.xml` file in from your Tomcat Program Files directory (by default ``C:\Program Files\Apache Software Foundation\Tomcat 9.0`` in a text editor. Immediately after ```` insert: + +.. code-block:: xml - - + + Replace ``s3cret`` with your actual password. After making this change you will have to restart Tomcat. Controlling Tomcat ------------------- +^^^^^^^^^^^^^^^^^^ By default, Tomcat will now start automatically with your computer. You can modify this by going through the :menuselection:`Control Panel -> Administrative Tools -> Services`, and editing the settings for the **Apache Tomcat** service. diff --git a/documentation/en/user/source/installation/upgrading.rst b/documentation/en/user/source/installation/upgrading.rst index 213aa4ace0..339d2f33db 100644 --- a/documentation/en/user/source/installation/upgrading.rst +++ b/documentation/en/user/source/installation/upgrading.rst @@ -1,9 +1,53 @@ .. _upgrading: -Upgrading from a pre 1.15 release -================================= +Upgrading +========= -In 1.15 GeoWebCache changed to work on Java 9 and higher. This included several changes to package names to avoid splitting packages across modules. If you used any of the following classes in plugins, while emebdding GWC in a larger application, or using modified application contexts, you will need to make the follwing changes. +1. Before you start: + + * Make a note of any customizations made to geowebcache :file:`WEB-INF` folder. + + .. warning:: When updating, be sure to preserve any changes made to :file:`WEB-INF/geowebcache-core-context.xml` or :file:`WEB-INF/web.xml` as these files will be replaced during the upgrading process. + + * To maintain cache location, follow the :ref:`configuration.file` instructions to define ``GEOWEBCACHE_CACHE_DIR`` and the location of :file:`geowebcache.xml` configuration. + +2. Stop Tomcat, follow the installation instructions to download and install the latest GeoWebCache version. + + Deploying a new version of GeoWebCache will replace :file:`/webapps/geowebcache` folder. + +3. Re-apply any customizations made to the :file:`WEB-INF` folder. + +4. Start tomcat + +Java Compatibility +------------------ + +GeoWebCache is compiled with Java 17 (LTS) and tested with Java 17 LTS and Java 21 LTS. + +============ ================= ================ ================ ================== +Java Initial Required Final Tested +============ ================= ================ ================ ================== +Java 21 LTS GeoWebCache 1.25 OpenJDK +Java 17 LTS GeoWebCache 1.22 GeoWebCache 1.28 OpenJDK +Java 11 LTS GeoWebCache 1.15 GeoWebCache 1.22 GeoWebCache 1.27 OpenJDK +Java 8 LTS GeoWebCache 1.9 GeoWebCache 1.9 GeoWebCache 1.22 Oracle and OpenJDK +============ ================= ================ ================ ================== + +GeoWebCache 1.18 Update +----------------------- + +Java 17 Minimum +^^^^^^^^^^^^^^^ + +GeoWebCache 1.18 is now compiled with Java 17 LTS, and is tested with Java 17 LTS and Java 21 LTS. + +GeoWebCache 1.15 Update +----------------------- + +Java 9 Minimum +^^^^^^^^^^^^^^ + +In 1.15 GeoWebCache changed to work with Java 9 or higher, with Java 11 LTS recommended. This included several changes to package names to avoid splitting packages across modules. If you used any of the following classes in plugins, while emebdding GWC in a larger application, or using modified application contexts, you will need to make the follwing changes. +----------------+---------------------------------------+-------------------------------------------+ | Module | ≤ 1.14 | ≥ 1.15 | @@ -38,8 +82,11 @@ In 1.15 GeoWebCache changed to work on Java 9 and higher. This included several +----------------+---------------------------------------+-------------------------------------------+ -Upgrading from a pre 1.4 release -================================ +GeoWebCache 1.4.0 Update +------------------------ + +File Blob Store replaces metastore +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Starting with GeoWebCache 1.4.0 the metastore support has been removed and all its functionality has been moved to the file blob store, including support for tile expiration based on creatin date and request parameter handling. diff --git a/documentation/en/user/source/production/index.rst b/documentation/en/user/source/production/index.rst index f2f8de6a24..8d396d662e 100644 --- a/documentation/en/user/source/production/index.rst +++ b/documentation/en/user/source/production/index.rst @@ -3,14 +3,7 @@ Production ========== -This section is a work in progress, and will eventually be extended to cover topics such as: - -* Service architecture -* Apache Portable Runtime -* Java Advanced Imaging / ImageIO -* External tools for optimizing tiles -* Profiling -* Links for tips on improving WMS performance +While many optimizations are configured for GeoWebCache by default, here are some additional considerations when operating in a production enviornment.. Operating Environment --------------------- @@ -18,16 +11,14 @@ Operating Environment Java Settings +++++++++++++ -GeoWebCache speed depends in part on the chosen Java Runtime Environment (JRE). GeoWebCache is tested with both OpenJDK 8 and OpenJDK 11. JREs other than these may work correctly, but are not tested nor supported. +GeoWebCache speed depends in part on the chosen Java Runtime Environment (JRE). GeoWebCache is compiled for Java 17, and is tested with both OpenJDK 17 and OpenJDK 11. JREs other than these may work correctly, but are not tested nor supported. GeoWebCache does not need a lot of heap memory assigned to the JVM. Usually 512M is just fine if its the only web application running on the servlet container. Java Advanced Imaging / ImageIO +++++++++++++++++++++++++++++++ -GeoWebCache uses the Java Advanced Imaging library (for image processing) and ImageIO for image encoding/decoding. - -The Java 8 plugin system offered native code additions for these two libraries. We no longer recommend use of these plugins due improvements in JIT performance, and native code posing a risk to system stability. +GeoWebCache uses the Java Advanced Imaging library (for image processing) and ImageIO for image encoding/decoding. Servlet container settings ++++++++++++++++++++++++++ @@ -90,18 +81,18 @@ As of version 1.2.5, it is possible to control how GWC behaves in the event that * ``GWC_SEED_RETRY_WAIT`` : specifies how much to wait before each retry upon a failure to seed a tile, in milliseconds. Defaults to ``100ms`` * ``GWC_SEED_ABORT_LIMIT`` : specifies the aggregated number of failures that a group of seeding threads should reach before aborting the seeding operation as a whole. This value is shared by all the threads launched as a single thread group; so if the value is ``10`` and you launch a seed task with four threads, when ``10`` failures are reached by all or any of those four threads the four threads will abort the seeding task. The default is ``1000``. -These environment variables can be established by any of the following ways, in order of precedence: +These applicaiton properties can be established by any of the following ways, in order of precedence: - As a Java environment variable: for example `java -DGWC_SEED_RETRY_COUNT=5 ...` - As a Servlet context parameter in the web application's ``WEB-INF/web.xml`` configuration file. for example: -.. code-block:: xml - - - - GWC_SEED_RETRY_WAIT - 500 - + .. code-block:: xml + + + + GWC_SEED_RETRY_WAIT + 500 + - As a System environment variable: `export GWC_SEED_ABORT_LIMIT=2000; ` (or for Tomcat, use the Tomcat's `CATALINA_OPTS` in Tomcat's `bin/catalina.sh` as this: `CATALINA_OPTS="GWC_SEED_ABORT_LIMIT=2000 GWC_SEED_RETRY_COUNT=2` diff --git a/documentation/en/user/source/quickstart/index.rst b/documentation/en/user/source/quickstart/index.rst index cc4040e651..9ee154fcad 100644 --- a/documentation/en/user/source/quickstart/index.rst +++ b/documentation/en/user/source/quickstart/index.rst @@ -12,9 +12,9 @@ All servers conforming to the `OGC Web Map Service specification + #. Replace the value with a URL pointing to a valid WMS capabilities document, such as: diff --git a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/config/CacheInfo.java b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/config/CacheInfo.java index bfe9ec921a..578d5bfde5 100644 --- a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/config/CacheInfo.java +++ b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/config/CacheInfo.java @@ -73,6 +73,7 @@ public class CacheInfo { private CacheStorageInfo cacheStorageInfo; + @SuppressWarnings("UnusedMethod") // required by serialization private Object readResolve() { if (cacheStorageInfo == null) { cacheStorageInfo = new CacheStorageInfo(); diff --git a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/config/CacheStorageInfo.java b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/config/CacheStorageInfo.java index 34f76b9df9..9a6be38e71 100644 --- a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/config/CacheStorageInfo.java +++ b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/config/CacheStorageInfo.java @@ -42,6 +42,7 @@ public class CacheStorageInfo { private int packetSize; + @SuppressWarnings("UnusedMethod") // required by serialization private Object readResolve() { if (storageFormat == null) { storageFormat = EXPLODED_FORMAT_CODE; diff --git a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/ArcGISCacheLayer.java b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/ArcGISCacheLayer.java index c518ddb3e0..3ae90dfc4c 100644 --- a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/ArcGISCacheLayer.java +++ b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/ArcGISCacheLayer.java @@ -65,8 +65,6 @@ public class ArcGISCacheLayer extends AbstractTileLayer { * configuration properties */ - private Boolean enabled; - /** The location of the conf.xml tiling scheme configuration file */ private File tilingScheme; @@ -100,16 +98,6 @@ public String getBlobStoreId() { return null; } - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - public File getTilingScheme() { return tilingScheme; } diff --git a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/config/CacheInfoPersisterTest.java b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/config/CacheInfoPersisterTest.java index a0b8918400..10eb794c49 100644 --- a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/config/CacheInfoPersisterTest.java +++ b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/config/CacheInfoPersisterTest.java @@ -44,7 +44,7 @@ public void testLoadSpatialReference() { Assert.assertEquals(0.5, sr.getZOrigin(), 1e-6); Assert.assertEquals(1, sr.getZScale(), 1e-6); Assert.assertEquals(10000, sr.getMScale(), 1e-6); - Assert.assertEquals(0.0037383177570093459, sr.getXYTolerance(), 1e-6); + Assert.assertEquals(0.003738317757009346, sr.getXYTolerance(), 1e-6); Assert.assertEquals(2, sr.getZTolerance(), 1e-6); Assert.assertEquals(2, sr.getMTolerance(), 1e-6); Assert.assertTrue(sr.isHighPrecision()); @@ -131,7 +131,7 @@ public void testLoadTileImageInfo() { TileImageInfo tii = (TileImageInfo) xs.fromXML(new StringReader(tileImageInfo)); Assert.assertNotNull(tii); Assert.assertEquals("JPEG", tii.getCacheTileFormat()); - Assert.assertEquals(80f, tii.getCompressionQuality(), 1e-6f); + Assert.assertEquals(80f, tii.getCompressionQuality(), 0); Assert.assertTrue(tii.isAntialiasing()); Assert.assertEquals(1, tii.getBandCount()); Assert.assertEquals(0.0f, tii.getLERCError(), 0d); 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 69ee385c2c..ee61f68fd8 100644 --- a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java +++ b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java @@ -16,7 +16,6 @@ import com.azure.core.credential.AzureNamedKeyCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.ProxyOptions; -import com.azure.core.http.ProxyOptions.Type; import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; @@ -126,7 +125,7 @@ ProxyOptions getProxyOptions(AzureBlobStoreData blobStoreConfig) { ProxyOptions proxyOptions = null; Proxy proxy = blobStoreConfig.getProxy(); if (null != proxy) { - ProxyOptions.Type type = Type.HTTP; + ProxyOptions.Type type = ProxyOptions.Type.HTTP; InetSocketAddress address = (InetSocketAddress) proxy.address(); String proxyUsername = blobStoreConfig.getProxyUsername(); String proxyPassword = blobStoreConfig.getProxyPassword(); 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 b1795be83c..5868695728 100644 --- a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/DeleteManager.java +++ b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/DeleteManager.java @@ -142,6 +142,7 @@ public boolean scheduleAsyncDelete(final String prefix) throws StorageException } } + @SuppressWarnings("Finally") public void issuePendingBulkDeletes() throws StorageException { final String pendingDeletesKey = keyBuilder.pendingDeletes(); Lock lock; diff --git a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreConformanceTest.java b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreConformanceTest.java index ddcca34d62..9d217dd753 100644 --- a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreConformanceTest.java +++ b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreConformanceTest.java @@ -41,6 +41,7 @@ public abstract class AzureBlobStoreConformanceTest extends AbstractBlobStoreTes protected abstract AzureBlobStoreData getConfiguration(); @Override + @SuppressWarnings("CatchFail") public void createTestUnit() throws Exception { AzureBlobStoreData config = getConfiguration(); diff --git a/geowebcache/core/src/main/java/org/geowebcache/GeoWebCacheDispatcher.java b/geowebcache/core/src/main/java/org/geowebcache/GeoWebCacheDispatcher.java index 57bebc3bc5..c7a7fd99c0 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/GeoWebCacheDispatcher.java +++ b/geowebcache/core/src/main/java/org/geowebcache/GeoWebCacheDispatcher.java @@ -21,6 +21,7 @@ import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -285,7 +286,7 @@ public ServletOutputStream getOutputStream() throws IOException { response, e.getErrorCode(), "text/plain", - new ByteArrayResource(e.getMessage().getBytes()), + new ByteArrayResource(e.getMessage().getBytes(StandardCharsets.UTF_8)), CacheResult.OTHER, runtimeStats); } catch (RequestFilterException e) { @@ -313,7 +314,7 @@ public ServletOutputStream getOutputStream() throws IOException { response, 403, "text/plain", - new ByteArrayResource("Not Authorized".getBytes()), + new ByteArrayResource("Not Authorized".getBytes(StandardCharsets.UTF_8)), CacheResult.OTHER, runtimeStats); LOG.warning(e.getMessage()); @@ -377,7 +378,7 @@ private String[] parseRequest(String servletPath) throws GeoWebCacheException { private void handleServiceRequest(String serviceStr, HttpServletRequest request, HttpServletResponse response) throws Exception { - Conveyor conv = null; + Conveyor conv; // 1) Figure out what Service should handle this request Service service = findService(serviceStr); diff --git a/geowebcache/core/src/main/java/org/geowebcache/GeoWebCacheEnvironment.java b/geowebcache/core/src/main/java/org/geowebcache/GeoWebCacheEnvironment.java index 6ab8cbe741..da94b3d4b5 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/GeoWebCacheEnvironment.java +++ b/geowebcache/core/src/main/java/org/geowebcache/GeoWebCacheEnvironment.java @@ -163,7 +163,7 @@ private boolean validateBoolean(String value) { * @return Optional resolved value. */ @SuppressWarnings("unchecked") - public Optional resolveValueIfEnabled(final String value, Class type) { + public Optional resolveValueIfEnabled(final String value, Class type) { if (StringUtils.isBlank(value)) return Optional.empty(); final String resultValue = resolveValueIfEnabled(value); if (type.isAssignableFrom(String.class)) { diff --git a/geowebcache/core/src/main/java/org/geowebcache/config/GridSetConfiguration.java b/geowebcache/core/src/main/java/org/geowebcache/config/GridSetConfiguration.java index 22bac273ac..d39781ace9 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/config/GridSetConfiguration.java +++ b/geowebcache/core/src/main/java/org/geowebcache/config/GridSetConfiguration.java @@ -26,7 +26,7 @@ public interface GridSetConfiguration extends BaseConfiguration { /** * Get a GridSet by name * - * @throw NoSuchElementException if the named gridset is not available. + * @throws NoSuchElementException if the named gridset is not available. */ Optional getGridSet(final String name); diff --git a/geowebcache/core/src/main/java/org/geowebcache/demo/Demo.java b/geowebcache/core/src/main/java/org/geowebcache/demo/Demo.java index df3d073db8..18c840579d 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/demo/Demo.java +++ b/geowebcache/core/src/main/java/org/geowebcache/demo/Demo.java @@ -221,9 +221,9 @@ private static void outputKMLSupport(StringBuffer buf, TileLayer layer) { String prefix = ""; buf.append(layer.getMimeTypes().stream() - .filter(type -> type instanceof ImageMime || type == XMLMime.kml || type == XMLMime.kmz) + .filter(type -> type instanceof ImageMime || XMLMime.kml.equals(type) || XMLMime.kmz.equals(type)) .map(type -> { - if (type == XMLMime.kmz) { + if (XMLMime.kmz.equals(type)) { return String.format( "kmz", prefix, escapeHtml4(layer.getName())); } else { diff --git a/geowebcache/core/src/main/java/org/geowebcache/filter/parameters/ParameterFilter.java b/geowebcache/core/src/main/java/org/geowebcache/filter/parameters/ParameterFilter.java index 7282cf3dab..331ce3daf4 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/filter/parameters/ParameterFilter.java +++ b/geowebcache/core/src/main/java/org/geowebcache/filter/parameters/ParameterFilter.java @@ -13,10 +13,10 @@ */ package org.geowebcache.filter.parameters; -import com.google.common.base.Objects; import com.google.common.base.Preconditions; import java.io.Serializable; import java.util.List; +import java.util.Objects; import java.util.Optional; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; @@ -127,7 +127,7 @@ protected Object readResolve() { /** Is the given value exactly a value that could be produced by the filter. */ public boolean isFilteredValue(final String value) { - if (Objects.equal(value, this.getDefaultValue())) { + if (Objects.equals(value, this.getDefaultValue())) { return true; } if (Optional.ofNullable(this.getLegalValues()) @@ -136,7 +136,7 @@ public boolean isFilteredValue(final String value) { return true; } try { - return Objects.equal(value, this.apply(value)); + return Objects.equals(value, this.apply(value)); } catch (ParameterException ex) { return false; } diff --git a/geowebcache/core/src/main/java/org/geowebcache/grid/BoundingBox.java b/geowebcache/core/src/main/java/org/geowebcache/grid/BoundingBox.java index 20ed77c974..f958f85478 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/grid/BoundingBox.java +++ b/geowebcache/core/src/main/java/org/geowebcache/grid/BoundingBox.java @@ -222,7 +222,7 @@ public String toKMLLatLonAltBox() { */ @Override public boolean equals(Object obj) { - if (obj != null && obj.getClass() == this.getClass()) { + if (obj instanceof BoundingBox) { BoundingBox other = (BoundingBox) obj; return this.equals(other, EQUALITYTHRESHOLD); } @@ -276,10 +276,12 @@ public boolean intersects(BoundingBox other) { || other.getMaxY() < getMinY()); } + @SuppressWarnings("AmbiguousMethodReference") public BoundingBox intersection(BoundingBox bboxB) { - return intersection(this, bboxB); + return BoundingBox.intersection(this, bboxB); } + @SuppressWarnings("AmbiguousMethodReference") public static BoundingBox intersection(BoundingBox bboxA, BoundingBox bboxB) { BoundingBox retBbox = new BoundingBox(0, 0, -1, -1); if (bboxA.intersects(bboxB)) { diff --git a/geowebcache/core/src/main/java/org/geowebcache/grid/GridSubset.java b/geowebcache/core/src/main/java/org/geowebcache/grid/GridSubset.java index e3939f45ac..690f0ab3bd 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/grid/GridSubset.java +++ b/geowebcache/core/src/main/java/org/geowebcache/grid/GridSubset.java @@ -334,7 +334,7 @@ public long[][] getSubGrid(long[] gridLoc) throws GeoWebCacheException { long baseX = gridLoc[0] * 2; long baseY = gridLoc[1] * 2; - long baseZ = idx + 1; + long baseZ = idx + 1L; long[] xOffset = {0, 1, 0, 1}; long[] yOffset = {0, 0, 1, 1}; diff --git a/geowebcache/core/src/main/java/org/geowebcache/io/XMLBuilder.java b/geowebcache/core/src/main/java/org/geowebcache/io/XMLBuilder.java index 93a1c93442..d2885bc4f5 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/io/XMLBuilder.java +++ b/geowebcache/core/src/main/java/org/geowebcache/io/XMLBuilder.java @@ -47,7 +47,7 @@ public XMLBuilder(Appendable builder) { ESCAPE_ENTITIES = Collections.unmodifiableMap(entities); } - class NodeInfo { + static class NodeInfo { String name; boolean indented; boolean containsIndented = false; diff --git a/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayer.java b/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayer.java index 9f70d1924c..e6c6591a2d 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayer.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayer.java @@ -21,6 +21,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -301,7 +302,7 @@ public FormatModifier getFormatModifier(MimeType responseFormat) { Iterator iter = formatModifiers.iterator(); while (iter.hasNext()) { FormatModifier mod = iter.next(); - if (mod.getResponseFormat() == responseFormat) { + if (Objects.equals(mod.getResponseFormat(), responseFormat)) { return mod; } } 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 7926e3cb19..405a643f6a 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java @@ -14,12 +14,11 @@ package org.geowebcache.layer; import com.google.common.base.Preconditions; +import com.google.common.collect.Iterables; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -28,7 +27,6 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.Stream; import java.util.stream.StreamSupport; import org.geowebcache.GeoWebCacheException; import org.geowebcache.GeoWebCacheExtensions; @@ -65,8 +63,9 @@ public class TileLayerDispatcher private ApplicationContext applicationContext; /** - * Used for testing only, in production use {@link #TileLayerDispatcher(GridSetBroker)} instead, configurations are - * loaded from the application context, the {@code config} parameter will be overwritten + * Used for testing only, in production use {@link #TileLayerDispatcher(GridSetBroker, TileLayerDispatcherFilter)} + * instead, configurations are loaded from the application context, the {@code configs} parameter will be + * overwritten */ public TileLayerDispatcher( GridSetBroker gridSetBroker, @@ -154,13 +153,10 @@ public Iterable getLayerList() { * * @return all layers, but filtered based on the tileLayerDispatcherFilter. */ - @SuppressWarnings("unchecked") public Iterable getLayerListFiltered() { Iterable result = getLayerList(); if (tileLayerDispatcherFilter != null) { - Stream s = StreamSupport.stream(result.spliterator(), false) - .filter(x -> !tileLayerDispatcherFilter.exclude(x)); - result = s::iterator; + result = Iterables.filter(result, x -> !tileLayerDispatcherFilter.exclude(x)); } return result; } @@ -270,7 +266,7 @@ public synchronized void removeGridSet(String gridsetToRemove) { } public synchronized void removeGridSetRecursive(String gridsetToRemove) { - Collection deletedLayers = new LinkedList<>(); + List deletedLayers = new ArrayList<>(); try { for (TileLayer tl : getLayerList()) { if (Objects.nonNull(tl.getGridSubset(gridsetToRemove))) { @@ -334,6 +330,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws } /** @deprecated use GeoWebCacheExtensions.reinitializeConfigurations instead */ + @Deprecated public void reInit() { // do not know how to get rid of it, it's used in mock testing... GeoWebCacheExtensions.reinitialize(this.applicationContext); } diff --git a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSSourceHelper.java b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSSourceHelper.java index dd3ea96fcc..1f54ed6d1a 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSSourceHelper.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSSourceHelper.java @@ -74,7 +74,7 @@ public void makeRequest(ConveyorTile tile, Resource target) throws GeoWebCacheEx } wmsParams.putAll(filteringParameters); - if (tile.getMimeType() == XMLMime.kml) { + if (XMLMime.kml.equals(tile.getMimeType())) { // This is a hack for GeoServer to produce regionated KML, // but it is unlikely to do much harm, especially since nobody // else appears to produce regionated KML at this point diff --git a/geowebcache/core/src/main/java/org/geowebcache/mime/FormatModifier.java b/geowebcache/core/src/main/java/org/geowebcache/mime/FormatModifier.java index 45109cdf83..790a71438f 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/mime/FormatModifier.java +++ b/geowebcache/core/src/main/java/org/geowebcache/mime/FormatModifier.java @@ -97,7 +97,7 @@ private Float getCompressionQuality() { public synchronized ImageWriteParam adjustImageWriteParam(ImageWriteParam param) { if (imgWriteParam == null) { if (getCompressionQuality() != null) { - if (getResponseFormat() == ImageMime.jpeg) { + if (ImageMime.jpeg.equals(getResponseFormat())) { param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionQuality(getCompressionQuality()); } else { 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 d319fdb574..967e3b6373 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/seed/SeedTask.java +++ b/geowebcache/core/src/main/java/org/geowebcache/seed/SeedTask.java @@ -208,6 +208,7 @@ protected void doActionInternal() throws GeoWebCacheException, InterruptedExcept super.state = GWCTask.STATE.DONE; } + @SuppressWarnings("ThreadPriorityCheck") private void reprioritize() { Thread.currentThread().setPriority((java.lang.Thread.NORM_PRIORITY + java.lang.Thread.MIN_PRIORITY) / 2); } diff --git a/geowebcache/core/src/main/java/org/geowebcache/seed/TileBreeder.java b/geowebcache/core/src/main/java/org/geowebcache/seed/TileBreeder.java index 9573c04c4a..e10ddb2986 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/seed/TileBreeder.java +++ b/geowebcache/core/src/main/java/org/geowebcache/seed/TileBreeder.java @@ -528,8 +528,8 @@ public Iterator getPendingTasks() { */ private Iterator filterTasks(STATE... filter) { Set states = new HashSet<>(Arrays.asList(filter)); - lock.readLock().lock(); List runningTasks = new ArrayList<>(this.currentPool.size()); + lock.readLock().lock(); try { Collection values = this.currentPool.values(); for (SubmittedTask t : values) { diff --git a/geowebcache/core/src/main/java/org/geowebcache/service/OWSException.java b/geowebcache/core/src/main/java/org/geowebcache/service/OWSException.java index 4fcda3eb82..325ca25bb5 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/service/OWSException.java +++ b/geowebcache/core/src/main/java/org/geowebcache/service/OWSException.java @@ -47,6 +47,11 @@ public Resource getResponse() { return new ByteArrayResource(this.toString().getBytes()); } + @Override + public String getMessage() { + return exceptionText; + } + @Override public String toString() { StringBuilder str = new StringBuilder(); diff --git a/geowebcache/core/src/main/java/org/geowebcache/stats/RuntimeStats.java b/geowebcache/core/src/main/java/org/geowebcache/stats/RuntimeStats.java index 8f70174b34..b5bde28370 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/stats/RuntimeStats.java +++ b/geowebcache/core/src/main/java/org/geowebcache/stats/RuntimeStats.java @@ -72,7 +72,7 @@ public class RuntimeStats { * @param intervalDescs the description for each of the previously defined intervals */ public RuntimeStats(int pollInterval, List intervals, List intervalDescs) { - this(pollInterval, intervals, intervalDescs, Clock.systemDefaultZone()); + this(pollInterval, intervals, intervalDescs, Clock.systemUTC()); } /** * @param pollInterval seconds between recording aggregate values @@ -122,6 +122,8 @@ public void start() { statsThread.start(); } + @SuppressWarnings( + "ThreadPriorityCheck") // errorprone complaint on Thread.yield(), revisit, might indeed be unnecessary public void destroy() { if (this.statsThread != null) { statsThread.run = false; @@ -177,18 +179,18 @@ public String getHTMLStats() { str.append("Total number of requests:" + totalRequests); - str.append(" (" + totalRequests / (runningTime) + "/s ) "); + str.append(" (" + totalRequests / runningTime + "/s ) "); str.append("\n"); str.append( "Total number of untiled WMS requests:" + totalWMS); - str.append(" (" + totalWMS / (runningTime) + "/s ) "); + str.append(" (" + totalWMS / runningTime + "/s ) "); str.append("\n"); str.append("Total number of bytes:" + totalBytes); - str.append(" (" + formatBits((totalBytes * 8.0) / (runningTime)) + ") "); + str.append(" (" + formatBits((totalBytes * 8.0) / runningTime) + ") "); str.append("\n"); str.append(""); @@ -379,7 +381,7 @@ private RuntimeStatsThread(RuntimeStats runtimeStats) { public void run() { try { while (run) { - Thread.sleep(stats.pollInterval * 1000); + Thread.sleep(stats.pollInterval * 1000L); updateLists(); } } catch (InterruptedException e) { 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 25d7549b94..3b09e7cf98 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/BlobStoreAggregator.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/BlobStoreAggregator.java @@ -71,7 +71,9 @@ public void addConfiguration(BlobStoreConfiguration config) { /** * Indicates if this configurations contains a {@link BlobStoreInfo) identified by a given name. + * * @param blobStoreInfoName the name of a {@link BlobStoreInfo} for which existence is desired. + * * @return True if a {@link BlobStoreInfo} currently exists with the unique name provided, false otherwise. */ public boolean blobStoreExists(final String blobStoreInfoName) { diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/CompositeBlobStore.java b/geowebcache/core/src/main/java/org/geowebcache/storage/CompositeBlobStore.java index 45a07b54c3..c3dfa365cc 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/CompositeBlobStore.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/CompositeBlobStore.java @@ -596,6 +596,7 @@ private void loadBlobStoreOverwritingDefault(Map stores, Blob * @param exists The storage is already a GWC cache * @param empty The storage is empty */ + @SuppressWarnings("FallThrough") public static void checkSuitability(String location, final boolean exists, boolean empty) throws UnsuitableStorageException { switch (getStoreSuitabilityCheck()) { diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/UnsuitableStorageException.java b/geowebcache/core/src/main/java/org/geowebcache/storage/UnsuitableStorageException.java index 75a70e44c7..594931cb9b 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/UnsuitableStorageException.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/UnsuitableStorageException.java @@ -27,6 +27,7 @@ public UnsuitableStorageException(String msg) { super(msg); } + @SuppressWarnings("FallThrough") // REVISIT the switch logic is hard to follow public static void checkSuitability(String location, final boolean exists, boolean empty) throws UnsuitableStorageException { switch (CompositeBlobStore.getStoreSuitabilityCheck()) { diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathFilter.java b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathFilter.java index dbe461ec56..d0666bf81a 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathFilter.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathFilter.java @@ -114,8 +114,8 @@ private boolean acceptIntermediateDir(File parent, String name) { String[] parts = name.split("_"); long halfX = Long.parseLong(parts[0]); long halfY = Long.parseLong(parts[1]); - long shift = z / 2; - long half = 2 << shift; + long shift = (long) z / 2; + long half = 2L << shift; long minX = halfX * half; long minY = halfY * half; long maxX = minX + half; diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathGenerator.java b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathGenerator.java index 50f78963fa..ce69e2c25a 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathGenerator.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathGenerator.java @@ -61,7 +61,7 @@ public File tilePath(TileObject tile, MimeType mimeType) { StringBuilder path = new StringBuilder(256); long shift = z / 2; - long half = 2 << shift; + long half = 2L << shift; int digits = 1; if (half > 10) { digits = (int) (Math.log10(half)) + 1; diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/FileBlobStore.java b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/FileBlobStore.java index 19c3455524..1c43922dd9 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/FileBlobStore.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/FileBlobStore.java @@ -348,7 +348,7 @@ public boolean rename(final String oldLayerName, final String newLayerName) thro } else { throw new StorageException("Couldn't rename layer directory " + oldLayerPath + " to " + newLayerPath); } - return renamed; + return true; } private File getLayerPath(String layerName) { @@ -697,7 +697,7 @@ private long padSize(long fileSize) { final int blockSize = this.diskBlockSize; - long actuallyUsedStorage = blockSize * (int) Math.ceil((double) fileSize / blockSize); + long actuallyUsedStorage = blockSize * (long) Math.ceil((double) fileSize / blockSize); return actuallyUsedStorage; } @@ -749,7 +749,7 @@ private Stream layerChildStream(final String layerName, DirectoryStream.Fi if (!layerPath.exists()) { return Stream.of(); } - @SuppressWarnings("PMD.CloseResource") // wrapped and closed in the return value + @SuppressWarnings({"PMD.CloseResource", "StreamResourceLeak"}) // wrapped and closed in the return value final DirectoryStream layerDirStream = Files.newDirectoryStream(layerPath.toPath(), filter); return StreamSupport.stream(layerDirStream.spliterator(), false) .onClose( // Delegate closing so that when the returned stream is closed, so is the diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/memory/guava/GuavaCacheProvider.java b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/memory/guava/GuavaCacheProvider.java index 52f768874e..93528fbe9e 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/memory/guava/GuavaCacheProvider.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/memory/guava/GuavaCacheProvider.java @@ -29,8 +29,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; import java.util.logging.Level; import java.util.logging.Logger; @@ -588,24 +588,15 @@ public boolean isAvailable() { * @author Nicola Lagomarsini, GeoSolutions */ static class LayerMap { - - /** {@link ReentrantReadWriteLock} used for handling concurrency */ - private final ReentrantReadWriteLock lock; - - /** {@link WriteLock} used when trying to change the map */ - private final WriteLock writeLock; - - /** {@link ReadLock} used when accessing the map */ - private final ReadLock readLock; + /** {@link WriteLock} used when trying to change remove a layer from the map */ + private final Lock writeLock; /** MultiMap containing the {@link TileObject} keys for the Layers */ private final ConcurrentHashMap> layerMap = new ConcurrentHashMap<>(); public LayerMap() { // Lock initialization - lock = new ReentrantReadWriteLock(true); - writeLock = lock.writeLock(); - readLock = lock.readLock(); + writeLock = new ReentrantLock(true); } /** Insertion of a {@link TileObject} key in the map for the associated Layer. */ @@ -618,78 +609,36 @@ public LayerMap() { "UL_UNRELEASED_LOCK_EXCEPTION_PATH" }) public void putTile(String layer, String id) { - // ReadLock is used because we are only accessing the map - readLock.lock(); - Set tileKeys = layerMap.get(layer); - if (tileKeys == null) { - if (LOGGER.isLoggable(Level.FINE)) { - LOGGER.fine("No KeySet for Layer: " + layer); - } - // If the Map is not present, we must add it - // So we do the unlock and try to acquire the writeLock - readLock.unlock(); - writeLock.lock(); - try { - // Check again if the tileKey has not been added already - tileKeys = layerMap.get(layer); - if (tileKeys == null) { - if (LOGGER.isLoggable(Level.FINE)) { - LOGGER.fine("Creating new KeySet for Layer: " + layer); - } - // If no key is present then a new KeySet is created and then added to the - // multimap - tileKeys = new ConcurrentSkipListSet<>(); - layerMap.put(layer, tileKeys); - } - // Downgrade by acquiring read lock before releasing write lock - readLock.lock(); - } finally { - // Release the writeLock - writeLock.unlock(); - } - } - try { - if (LOGGER.isLoggable(Level.FINE)) { - LOGGER.fine("Add the TileObject id to the Map"); - } - // Finally the tile key is added. - tileKeys.add(id); - } finally { - readLock.unlock(); + Set tileKeys = layerMap.computeIfAbsent(layer, l -> new ConcurrentSkipListSet<>()); + + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.fine("Add the TileObject id to the Map"); } + // Finally the tile key is added. + tileKeys.add(id); } /** Removal of a {@link TileObject} key in the map for the associated Layer. */ public void removeTile(String layer, String id) { - // ReadLock is used because we are only accessing the map - readLock.lock(); - try { - // KeySet associated to the image - Set tileKeys = layerMap.get(layer); - if (tileKeys != null) { - if (LOGGER.isLoggable(Level.FINE)) { - LOGGER.fine("Remove TileObject id to the Map"); - } - // Removal of the keys - tileKeys.remove(id); - // If the KeySet is empty then it is removed from the multimap - if (tileKeys.isEmpty()) { - readLock.unlock(); - writeLock.lock(); - try { - if (tileKeys.isEmpty()) { - // Here writeLock is acquired again, but it is reentrant - removeLayer(layer); - } - // Downgrade by acquiring read lock before releasing write lock - readLock.lock(); - } finally { - writeLock.unlock(); + Set tileKeys = layerMap.get(layer); + if (tileKeys != null) { + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.fine("Remove TileObject id to the Map"); + } + // Removal of the keys + tileKeys.remove(id); + // If the KeySet is empty then it is removed from the multimap + if (tileKeys.isEmpty()) { + writeLock.lock(); + try { + tileKeys = layerMap.get(layer); + if (tileKeys != null && tileKeys.isEmpty()) { + removeLayer(layer); } + } finally { + writeLock.unlock(); } } - } finally { - readLock.unlock(); } } diff --git a/geowebcache/core/src/main/resources/geowebcache.xml b/geowebcache/core/src/main/resources/geowebcache.xml index 139259324d..a578c441be 100644 --- a/geowebcache/core/src/main/resources/geowebcache.xml +++ b/geowebcache/core/src/main/resources/geowebcache.xml @@ -9,7 +9,6 @@ GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of protocols and formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth. - WFS WMS WMTS GEOWEBCACHE @@ -148,12 +147,12 @@ - + - topp:states + states image/gif image/jpeg @@ -188,7 +187,8 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + + http://localhost:8080/geoserver/topp/wms @@ -217,9 +217,9 @@ - https://demo.boundlessgeo.com/geoserver/wms + http://localhost:8080/geoserver/wms - nasa:bluemarble + nurc:Arc_Sample @@ -257,9 +257,11 @@ + - https://demo.boundlessgeo.com/geoserver/wms + http://localhost:8080/geoserver/wms + nurc:Img_Sample,topp:states false 0x0066FF diff --git a/geowebcache/core/src/main/resources/geowebcache_empty.xml b/geowebcache/core/src/main/resources/geowebcache_empty.xml index 3abf1df7f8..93a55eb3d7 100644 --- a/geowebcache/core/src/main/resources/geowebcache_empty.xml +++ b/geowebcache/core/src/main/resources/geowebcache_empty.xml @@ -91,7 +91,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -104,7 +104,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -141,7 +141,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false 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 71a5b72288..47b3fea45d 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 @@ -71,6 +71,7 @@ private void putLayerMetadataConcurrently(final int srcStoreKey, final FileBlobS } private void executeStoresConcurrently(int numberOfStores, int numberOfThreads) throws InterruptedException { + ExecutorService service = Executors.newFixedThreadPool(numberOfStores); CountDownLatch latch = new CountDownLatch(numberOfStores); for (int i = 0; i < numberOfStores; i++) { @@ -100,6 +101,7 @@ public void testMetadataWithPointInKey() throws Exception { public void testConcurrentMetadataWithPointInKey() throws InterruptedException { assertThat(store.getLayerMetadata("testLayer", "test.Key"), nullValue()); int numberOfThreads = 2; + 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/blobstore/file/XYZFileBlobStoreComformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/XYZFileBlobStoreComformanceTest.java index d1a8cb2666..5fc8b88234 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/XYZFileBlobStoreComformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/XYZFileBlobStoreComformanceTest.java @@ -57,6 +57,7 @@ public static Collection data() { } @Override + @SuppressWarnings("CatchFail") public void createTestUnit() throws Exception { this.layers = createMock(TileLayerDispatcher.class); GridSet wgs84Grid = new DefaultGridsets(false, false).worldEpsg4326(); 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 d40176c222..e5ab400d24 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/DefaultingConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/DefaultingConfigurationTest.java @@ -60,7 +60,7 @@ public void testSetDefault() { boolean cacheBypass = tl.isCacheBypassAllowed(); int timeout = tl.getBackendTimeout(); assertFalse(cacheBypass); - assertEquals(timeout, 120); + assertEquals(120, timeout); assertNull(tl.getFormatModifiers()); } @@ -68,9 +68,9 @@ public void testSetDefault() { public void initializationTest() { initialize(tl); Set subsets = tl.getGridSubsets(); - assertEquals(subsets.size(), 2); - assertEquals(subsets.toArray()[0], "EPSG:4326"); - assertEquals(subsets.toArray()[1], "EPSG:900913"); + assertEquals(2, subsets.size()); + assertEquals("EPSG:4326", subsets.toArray()[0]); + assertEquals("EPSG:900913", subsets.toArray()[1]); } GeoWebCacheConfiguration getGwcConfig() { diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/GWCConfigIntegrationTestData.java b/geowebcache/core/src/test/java/org/geowebcache/config/GWCConfigIntegrationTestData.java index 3dadcaba62..37cd9bd59f 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/GWCConfigIntegrationTestData.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/GWCConfigIntegrationTestData.java @@ -27,6 +27,7 @@ import org.geowebcache.layer.wms.WMSLayer; /** Test data for {@link GWCConfigIntegrationTest} */ +@SuppressWarnings("MutablePublicArray") public class GWCConfigIntegrationTestData { // Names / ids for config objects @@ -102,7 +103,7 @@ public static void setUpTestData(GWCConfigIntegrationTestSupport testSupport) th WMSLayer wmsLayer = new WMSLayer( LAYER_TOPP_STATES, - new String[] {"http://demo.opengeo.org/geoserver/topp/wms"}, + new String[] {"http://localhost:8080/geoserver/topp/wms"}, null, null, Arrays.asList("image/gif", "image/jpeg", "image/png", "image/png8"), diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBackwardsCompatibilityTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBackwardsCompatibilityTest.java index 6906a59e4a..d77ecac5ba 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBackwardsCompatibilityTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBackwardsCompatibilityTest.java @@ -82,8 +82,8 @@ public void testLoad101() throws Exception { assertNotNull(grid); // The additions in 1.0.1 are allowCacheBypass and backendTimeout - assertEquals(layer.getBackendTimeout().intValue(), 60); - assertEquals(layer2.getBackendTimeout().intValue(), 235); + assertEquals(60, layer.getBackendTimeout().intValue()); + assertEquals(235, layer2.getBackendTimeout().intValue()); assertTrue(layer.isCacheBypassAllowed().booleanValue()); assertFalse(layer2.isCacheBypassAllowed().booleanValue()); } @@ -100,18 +100,18 @@ public void testLoad114() throws Exception { assertNotNull(grid); // The additions in 1.0.1 are allowCacheBypass and backendTimeout - assertEquals(layer.getBackendTimeout().intValue(), 120); - assertEquals(layer2.getBackendTimeout().intValue(), 120); + assertEquals(120, layer.getBackendTimeout().intValue()); + assertEquals(120, layer2.getBackendTimeout().intValue()); assertTrue(layer.isCacheBypassAllowed().booleanValue()); assertTrue(layer2.isCacheBypassAllowed().booleanValue()); FormatModifier fm = layer.getFormatModifier(ImageMime.jpeg); - assertEquals(fm.getBgColor(), "0xDDDDDD"); - assertEquals(fm.getRequestFormat(), ImageMime.png); + assertEquals("0xDDDDDD", fm.getBgColor()); + assertEquals(ImageMime.png, fm.getRequestFormat()); List filters = layer.getRequestFilters(); - assertEquals(filters.get(0).getName(), "testWMSRasterFilter"); - assertEquals(filters.get(1).getName(), "testFileRasterFilter"); + assertEquals("testWMSRasterFilter", filters.get(0).getName()); + assertEquals("testFileRasterFilter", filters.get(1).getName()); } @Test @@ -126,20 +126,20 @@ public void testLoad115() throws Exception { assertNotNull(grid); // The additions in 1.0.1 are allowCacheBypass and backendTimeout - assertEquals(layer.getBackendTimeout().intValue(), 120); - assertEquals(layer2.getBackendTimeout().intValue(), 120); + assertEquals(120, layer.getBackendTimeout().intValue()); + assertEquals(120, layer2.getBackendTimeout().intValue()); assertTrue(layer.isCacheBypassAllowed().booleanValue()); assertTrue(layer2.isCacheBypassAllowed().booleanValue()); FormatModifier fm = layer.getFormatModifier(ImageMime.jpeg); - assertEquals(fm.getBgColor(), "0xDDDDDD"); - assertEquals(fm.getRequestFormat(), ImageMime.png); + assertEquals("0xDDDDDD", fm.getBgColor()); + assertEquals(ImageMime.png, fm.getRequestFormat()); List filters = layer.getRequestFilters(); RequestFilter filter0 = filters.get(0); - assertEquals(filter0.getName(), "testWMSRasterFilter"); + assertEquals("testWMSRasterFilter", filter0.getName()); RequestFilter filter1 = filters.get(1); - assertEquals(filter1.getName(), "testFileRasterFilter"); + assertEquals("testFileRasterFilter", filter1.getName()); } @Test 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 5854a62858..772dca929e 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java @@ -156,14 +156,7 @@ public boolean matches(Object item) { @Override protected Matcher infoEquals(int expected) { - return new CustomMatcher<>("Layer with value" + expected) { - - @Override - public boolean matches(Object item) { - return item instanceof WMSLayer - && ((WMSLayer) item).getWmsLayers().equals(expected); - } - }; + throw new UnsupportedOperationException("unused"); } @Override diff --git a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/MetaTileTest.java b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/MetaTileTest.java index 5cdda94d71..d0fe11d643 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/MetaTileTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/MetaTileTest.java @@ -158,7 +158,7 @@ public void test5MetaTileGutter() throws Exception { int height = Integer.parseInt(wmsParams.get("HEIGHT")); - Assert.assertEquals(height, 256 + 50); + Assert.assertEquals(256 + 50, height); long[] midGridPos = {83, 45, 6}; mt = new WMSMetaTile( @@ -180,7 +180,7 @@ public void test5MetaTileGutter() throws Exception { height = Integer.parseInt(wmsParams.get("HEIGHT")); - Assert.assertEquals(height, 768 + 2 * 50); + Assert.assertEquals(768 + 2 * 50, height); String[] coordStrs = wmsParams.get("BBOX").split(","); @@ -222,7 +222,7 @@ public void test6MetaTileNoGutterWithVector() throws Exception { int height = Integer.parseInt(wmsParams.get("HEIGHT")); - Assert.assertEquals(height, 256); + Assert.assertEquals(256, height); } private WMSLayer createWMSLayer(BoundingBox layerBounds) { 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 31014d7842..1fbee62983 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 @@ -546,6 +546,7 @@ private List getTiles(StorageBroker storageBroker, TileRange tr, f long[] gridLoc = trIter.nextMetaGridLocation(new long[3]); // six concurrent requests max + ExecutorService requests = Executors.newFixedThreadPool(6); ExecutorCompletionService completer = new ExecutorCompletionService<>(requests); @@ -662,7 +663,7 @@ protected void makeRequest( } } - class MockTileSupport { + static class MockTileSupport { final byte[] fakeWMSResponse; final StorageBroker storageBroker = EasyMock.createMock(StorageBroker.class); diff --git a/geowebcache/core/src/test/java/org/geowebcache/mime/XMLMimeTest.java b/geowebcache/core/src/test/java/org/geowebcache/mime/XMLMimeTest.java index 14386153ac..2a16fdf39f 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/mime/XMLMimeTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/mime/XMLMimeTest.java @@ -8,6 +8,7 @@ import org.junit.Test; +@SuppressWarnings("CatchFail") public class XMLMimeTest { @Test diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1100.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1100.xml index ae70ceb3cf..399c2661a8 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1100.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1100.xml @@ -150,7 +150,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -163,7 +163,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -201,7 +201,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1110.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1110.xml index 37c38d7d23..06ba0319e8 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1110.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1110.xml @@ -150,7 +150,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -163,7 +163,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -201,7 +201,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1120.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1120.xml index 376d6e610c..299f3e112e 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1120.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1120.xml @@ -150,7 +150,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -171,7 +171,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -212,7 +212,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1130.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1130.xml index 5b8a36e858..9cb73d0554 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1130.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1130.xml @@ -150,7 +150,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -171,7 +171,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -212,7 +212,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1140.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1140.xml index a79576086d..849cad2e3a 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1140.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1140.xml @@ -170,7 +170,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -199,7 +199,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -240,7 +240,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1150.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1150.xml index 723a59a040..df8c26391e 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1150.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1150.xml @@ -170,7 +170,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -199,7 +199,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -240,7 +240,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1170.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1170.xml index 6d6b0f631a..c71acbaec4 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1170.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1170.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1180.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1180.xml index 2e4cec35f4..c1e15ee669 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1180.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1180.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1190.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1190.xml index 285ee2be22..aa51228008 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1190.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1190.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1200.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1200.xml index 7280e11e50..7fe75629d9 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1200.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1200.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1210.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1210.xml index a1e9f932f4..58bb5cd96e 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1210.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1210.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1220.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1220.xml index de3611055b..c30cce0ae5 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1220.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1220.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1230.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1230.xml index 1fc371de7b..c001f60426 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1230.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1230.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1240.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1240.xml index 4e37f8b7a1..ad56003a24 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1240.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1240.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1250.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1250.xml index 60d5b59452..4e22068c5f 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1250.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1250.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_126.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_126.xml index e1e7fc01dc..a036f45fb8 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_126.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_126.xml @@ -77,7 +77,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1260.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1260.xml index 615c4a6f72..5bf1bcf65b 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1260.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1260.xml @@ -188,7 +188,7 @@ - https://demo.boundlessgeo.com/geoserver/topp/wms + https://localhost:8080/geoserver/topp/wms @@ -217,7 +217,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nasa:bluemarble @@ -258,7 +258,7 @@ - https://demo.boundlessgeo.com/geoserver/wms + https://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_140.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_140.xml index 9b1a69c479..9ba701948c 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_140.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_140.xml @@ -89,7 +89,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -102,7 +102,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -140,7 +140,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_150.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_150.xml index 9ef4182a8f..30638fc9d8 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_150.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_150.xml @@ -89,7 +89,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -102,7 +102,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -140,7 +140,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_151.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_151.xml index c0d5748483..627f58bec1 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_151.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_151.xml @@ -89,7 +89,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -102,7 +102,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -140,7 +140,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_153.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_153.xml index e113f976f9..7649713eb3 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_153.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_153.xml @@ -89,7 +89,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -102,7 +102,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -140,7 +140,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_160.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_160.xml index c0d5748483..627f58bec1 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_160.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_160.xml @@ -89,7 +89,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -102,7 +102,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -140,7 +140,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_161.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_161.xml index c0d5748483..627f58bec1 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_161.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_161.xml @@ -89,7 +89,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -102,7 +102,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -140,7 +140,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_170.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_170.xml index 45d3e2d417..2c6b08bd7d 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_170.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_170.xml @@ -89,7 +89,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -102,7 +102,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -140,7 +140,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_180.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_180.xml index 272e882512..25003ab760 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_180.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_180.xml @@ -133,7 +133,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -146,7 +146,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -184,7 +184,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_190.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_190.xml index 47a766071d..85fb02c1b1 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_190.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_190.xml @@ -133,7 +133,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -146,7 +146,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -184,7 +184,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_4326_override.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_4326_override.xml index dac4e618b2..ef8c780ccc 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_4326_override.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_4326_override.xml @@ -176,7 +176,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -189,7 +189,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -227,7 +227,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false diff --git a/geowebcache/diskquota/bdb/src/main/java/org/geowebcache/diskquota/bdb/BDBQuotaStore.java b/geowebcache/diskquota/bdb/src/main/java/org/geowebcache/diskquota/bdb/BDBQuotaStore.java index 2762b43af0..4cf6c5372e 100644 --- a/geowebcache/diskquota/bdb/src/main/java/org/geowebcache/diskquota/bdb/BDBQuotaStore.java +++ b/geowebcache/diskquota/bdb/src/main/java/org/geowebcache/diskquota/bdb/BDBQuotaStore.java @@ -16,7 +16,6 @@ import static org.geowebcache.diskquota.DiskQuotaMonitor.GWC_DISKQUOTA_DISABLED; import static org.geowebcache.util.FileUtils.listFilesNullSafe; -import com.google.common.base.Objects; import com.sleepycat.je.CursorConfig; import com.sleepycat.je.Environment; import com.sleepycat.je.LockMode; @@ -34,6 +33,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -397,12 +397,12 @@ public void deleteLayer(final String layerName) { @Override public void deleteGridSubset(String layerName, String gridSetId) { - issue(new Deleter(layerName, ts -> Objects.equal(ts.getGridsetId(), gridSetId))); + issue(new Deleter(layerName, ts -> Objects.equals(ts.getGridsetId(), gridSetId))); } @Override public void deleteParameters(String layerName, String parametersId) { - issue(new Deleter(layerName, ts -> Objects.equal(ts.getParametersId(), parametersId))); + issue(new Deleter(layerName, ts -> Objects.equals(ts.getParametersId(), parametersId))); } private class Deleter implements Callable { diff --git a/geowebcache/diskquota/bdb/src/main/java/org/geowebcache/diskquota/bdb/DiskQuotaEntityModel.java b/geowebcache/diskquota/bdb/src/main/java/org/geowebcache/diskquota/bdb/DiskQuotaEntityModel.java index 0c50004996..85b55ceff2 100644 --- a/geowebcache/diskquota/bdb/src/main/java/org/geowebcache/diskquota/bdb/DiskQuotaEntityModel.java +++ b/geowebcache/diskquota/bdb/src/main/java/org/geowebcache/diskquota/bdb/DiskQuotaEntityModel.java @@ -78,7 +78,7 @@ private void registerClassMetadata(ClassMetadata classMetadata) { } @Override - public ClassMetadata getClassMetadata(String className) { + public synchronized ClassMetadata getClassMetadata(String className) { ClassMetadata metadata = super.getClassMetadata(className); if (metadata != null) { return metadata; @@ -88,7 +88,7 @@ public ClassMetadata getClassMetadata(String className) { } @Override - public EntityMetadata getEntityMetadata(String className) { + public synchronized EntityMetadata getEntityMetadata(String className) { EntityMetadata metadata = super.getEntityMetadata(className); if (metadata != null) { return metadata; @@ -98,7 +98,7 @@ public EntityMetadata getEntityMetadata(String className) { } @Override - public Set getKnownClasses() { + public synchronized Set getKnownClasses() { return classes.keySet(); } } 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 7e524cf276..9e5a5aea45 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 @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -32,7 +31,6 @@ import org.geowebcache.config.DefaultGridsets; import org.geowebcache.config.GridSetConfiguration; import org.geowebcache.config.MockConfigurationResourceProvider; -import org.geowebcache.config.TileLayerConfiguration; import org.geowebcache.config.XMLConfiguration; import org.geowebcache.config.XMLConfigurationBackwardsCompatibilityTest; import org.geowebcache.diskquota.bdb.BDBQuotaStore; @@ -112,8 +110,6 @@ public void setUp() throws Exception { e -> e.getValue().stream().map(ParametersUtils::getKvp).collect(Collectors.toSet()))); XMLConfiguration xmlConfig = loadXMLConfig(); context.addBean("xmlConfig", xmlConfig, XMLConfiguration.class.getInterfaces()); - LinkedList configList = new LinkedList<>(); - configList.add(xmlConfig); context.addBean( "DefaultGridsets", new DefaultGridsets(true, true), @@ -311,7 +307,7 @@ public void testDeleteGridset() throws InterruptedException { throw new AssertionError("Unexpected Exception", e); } }) - .collect(Collectors.summingLong(mb -> mb * 1024 * 1024)); + .collect(Collectors.summingLong(mb -> mb * 1024L * 1024L)); assertThat(quotaToDelete, greaterThan(0L)); long quotaToKeep = tilePageCalculator.getTileSetsFor(layerName).stream() .filter(ts -> !ts.getGridsetId().equals(gridSetId)) @@ -327,7 +323,7 @@ public void testDeleteGridset() throws InterruptedException { throw new AssertionError("Unexpected Exception", e); } }) - .collect(Collectors.summingLong(mb -> mb * 1024 * 1024)); + .collect(Collectors.summingLong(mb -> mb * 1024L * 1024L)); assertThat(quotaToKeep, greaterThan(0L)); assertThat(store.getUsedQuotaByLayerName(layerName), bytes(quotaToDelete + quotaToKeep)); @@ -356,7 +352,7 @@ public void testDeleteParameters() throws InterruptedException { throw new AssertionError("Unexpected Exception", e); } }) - .collect(Collectors.summingLong(mb -> mb * 1024 * 1024)); + .collect(Collectors.summingLong(mb -> mb * 1024L * 1024L)); assertThat(quotaToDelete, greaterThan(0L)); long quotaToKeep = tilePageCalculator.getTileSetsFor(layerName).stream() .filter(ts -> !ts.getParametersId().equals(parametersId)) @@ -372,7 +368,7 @@ public void testDeleteParameters() throws InterruptedException { throw new AssertionError("Unexpected Exception", e); } }) - .collect(Collectors.summingLong(mb -> mb * 1024 * 1024)); + .collect(Collectors.summingLong(mb -> mb * 1024L * 1024L)); assertThat(quotaToKeep, greaterThan(0L)); assertThat(store.getUsedQuotaByLayerName(layerName), bytes(quotaToDelete + quotaToKeep)); @@ -445,7 +441,7 @@ public void testGetLeastFrequentlyUsedPage() throws Exception { public void testGetLeastRecentlyUsedPage() throws Exception { MockSystemUtils mockSystemUtils = new MockSystemUtils(); mockSystemUtils.setCurrentTimeMinutes(1000); - mockSystemUtils.setCurrentTimeMillis(mockSystemUtils.currentTimeMinutes() * 60 * 1000); + mockSystemUtils.setCurrentTimeMillis(mockSystemUtils.currentTimeMinutes() * 60L * 1000L); SystemUtils.set(mockSystemUtils); final String layerName = testTileSet.getLayerName(); diff --git a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/LayerCacheInfoBuilder.java b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/LayerCacheInfoBuilder.java index 70e8d97ecd..eae7e672da 100644 --- a/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/LayerCacheInfoBuilder.java +++ b/geowebcache/diskquota/core/src/main/java/org/geowebcache/diskquota/LayerCacheInfoBuilder.java @@ -190,7 +190,7 @@ private final class ZoomLevelVisitor implements FileFilter, Callable quotas = new ArrayList<>(); + LayerQuota lq = new LayerQuota("topp:states", LRU, new Quota(10, StorageUnit.MiB)); - quotas.add(lq); config.addLayerQuota(lq); File configFile = new File(cacheDir, "geowebcache-diskquota.xml"); @@ -170,10 +169,6 @@ public void testSaveConfig() throws ConfigurationException, IOException { } loader.saveConfig(config); Assert.assertTrue(configFile.exists()); - - // loader = new ConfigLoader(storageFinder, contextProvider, tld); - // DiskQuotaConfig loadConfig = loader.loadConfig(); - // assertNotNull(loadConfig); } @Test 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 ad0d27f5b9..6c684e8fb5 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 @@ -80,7 +80,7 @@ private void printPyramid(int zoomStart, int zoomStop, PagePyramid pp) { PageLevelInfo pageInfo = pp.getPageInfo(z); - long levelPages = pageInfo.pagesX * pageInfo.pagesY; + long levelPages = pageInfo.pagesX * (long) pageInfo.pagesY; BigInteger tilesPerPage = pageInfo.tilesPerPage; totalPages += levelPages; @@ -143,10 +143,10 @@ public void testToGridCoverage() { int tilesPerPageX = pyramid.getTilesPerPageX(level); int tilesPerPageY = pyramid.getTilesPerPageY(level); long[] expected = { - coverages[level][0] + tilesPerPageX * pageX, // - coverages[level][1] + tilesPerPageY * pageY, // - coverages[level][0] + tilesPerPageX * pageX + tilesPerPageX - 1, // - coverages[level][0] + tilesPerPageY * pageY + tilesPerPageY - 1, // + coverages[level][0] + (long) tilesPerPageX * pageX, // + coverages[level][1] + (long) tilesPerPageY * pageY, // + coverages[level][0] + (long) tilesPerPageX * pageX + tilesPerPageX - 1, // + coverages[level][0] + (long) tilesPerPageY * pageY + tilesPerPageY - 1, // pageZ }; Assert.assertEquals(asList(expected), asList(gridCoverage[1])); diff --git a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PageStatsTest.java b/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PageStatsTest.java index da812ba7f7..1d7e89ce65 100644 --- a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PageStatsTest.java +++ b/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PageStatsTest.java @@ -62,7 +62,7 @@ public void testAddHitsFullFillFactorNewLastAccessTime() { numHits = 100; stats.addHitsAndAccessTime(numHits, CREATION_TIME_MINUTES + 3, CREATION_TIME_MINUTES); frequencyOfUsePerMinute = stats.getFrequencyOfUsePerMinute(); - Assert.assertEquals(110f / 4f, frequencyOfUsePerMinute, 1e-6f); + Assert.assertEquals(110f / 4f, frequencyOfUsePerMinute, 1e-5f); } @Test diff --git a/geowebcache/diskquota/jdbc/src/main/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreFactory.java b/geowebcache/diskquota/jdbc/src/main/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreFactory.java index b7ac65fe26..44e251cbf5 100644 --- a/geowebcache/diskquota/jdbc/src/main/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreFactory.java +++ b/geowebcache/diskquota/jdbc/src/main/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreFactory.java @@ -198,7 +198,7 @@ protected DataSource getDataSource(JDBCConfiguration config) throws Configuratio bds.setMaxOpenPreparedStatements(cp.getMaxOpenPreparedStatements()); bds.setMinIdle(cp.getMinConnections()); bds.setMaxActive(cp.getMaxConnections()); - bds.setMaxWait(cp.getConnectionTimeout() * 1000); + bds.setMaxWait(cp.getConnectionTimeout() * 1000L); bds.setValidationQuery(cp.getValidationQuery()); ds = bds; 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 bad9e60e0f..05c3559434 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 @@ -10,7 +10,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import com.google.common.base.Objects; import java.io.File; import java.io.IOException; import java.math.BigInteger; @@ -25,6 +24,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.Future; import java.util.stream.Collectors; @@ -462,7 +462,7 @@ public void testDeleteParameters() throws InterruptedException { assertThat( store.getTileSets(), containsInAnyOrder(expectedTileSets.stream() - .filter(ts -> !(Objects.equal(ts.getParametersId(), paramIds[1]) + .filter(ts -> !(Objects.equals(ts.getParametersId(), paramIds[1]) && ts.getLayerName().equals(layerName))) .map(Matchers::equalTo) .collect(Collectors.toSet()))); @@ -634,7 +634,7 @@ public void testPageStatsGathering() throws Exception { assertEquals(sysUtils.currentTimeMinutes(), lastAccessTimeMinutes); float frequencyOfUsePerMinute = stats.getFrequencyOfUsePerMinute(); - assertEquals(100f, frequencyOfUsePerMinute, 1e-6f); + assertEquals(100f, frequencyOfUsePerMinute, 1e-5f); // now 1 minute later... sysUtils.setCurrentTimeMinutes(sysUtils.currentTimeMinutes() + 2); @@ -762,7 +762,7 @@ public void testGetLeastFrequentlyUsedPageSkipEmpty() throws Exception { public void testGetLeastRecentlyUsedPage() throws Exception { MockSystemUtils mockSystemUtils = new MockSystemUtils(); mockSystemUtils.setCurrentTimeMinutes(1000); - mockSystemUtils.setCurrentTimeMillis(mockSystemUtils.currentTimeMinutes() * 60 * 1000); + mockSystemUtils.setCurrentTimeMillis(mockSystemUtils.currentTimeMinutes() * 60L * 1000L); SystemUtils.set(mockSystemUtils); final String layerName = testTileSet.getLayerName(); @@ -777,8 +777,8 @@ public void testGetLeastRecentlyUsedPage() throws Exception { PageStatsPayload payload1 = new PageStatsPayload(page1, testTileSet); PageStatsPayload payload2 = new PageStatsPayload(page2, testTileSet); - payload1.setLastAccessTime(mockSystemUtils.currentTimeMillis() + 1 * 60 * 1000); - payload2.setLastAccessTime(mockSystemUtils.currentTimeMillis() + 2 * 60 * 1000); + payload1.setLastAccessTime(mockSystemUtils.currentTimeMillis() + 1 * 60L * 1000L); + payload2.setLastAccessTime(mockSystemUtils.currentTimeMillis() + 2 * 60L * 1000L); Collection statsUpdates = Arrays.asList(payload1, payload2); store.addHitsAndSetAccesTime(statsUpdates).get(); @@ -786,7 +786,7 @@ public void testGetLeastRecentlyUsedPage() throws Exception { leastRecentlyUsedPage = store.getLeastRecentlyUsedPage(layerNames); assertEquals(page1, leastRecentlyUsedPage); - payload1.setLastAccessTime(mockSystemUtils.currentTimeMillis() + 10 * 60 * 1000); + payload1.setLastAccessTime(mockSystemUtils.currentTimeMillis() + 10 * 60L * 1000L); store.addHitsAndSetAccesTime(statsUpdates).get(); leastRecentlyUsedPage = store.getLeastRecentlyUsedPage(layerNames); @@ -797,7 +797,7 @@ public void testGetLeastRecentlyUsedPage() throws Exception { public void testGetLeastRecentlyUsedPageSkipEmpty() throws Exception { MockSystemUtils mockSystemUtils = new MockSystemUtils(); mockSystemUtils.setCurrentTimeMinutes(1000); - mockSystemUtils.setCurrentTimeMillis(mockSystemUtils.currentTimeMinutes() * 60 * 1000); + mockSystemUtils.setCurrentTimeMillis(mockSystemUtils.currentTimeMinutes() * 60L * 1000L); SystemUtils.set(mockSystemUtils); final String layerName = testTileSet.getLayerName(); diff --git a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OnlineTestRule.java b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OnlineTestRule.java index cf371dfbc1..2e23038c91 100644 --- a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OnlineTestRule.java +++ b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OnlineTestRule.java @@ -68,8 +68,6 @@ public class OnlineTestRule extends ExternalResource { /** * Check whether the fixture is available. This method also loads the configuration if present, and tests the * connection using {@link #isOnline()}. - * - * @return true if fixture is available for use */ void checkAvailable() { configureFixture(); @@ -189,6 +187,7 @@ protected void setUpInternal() throws Exception {} /** Tear down method for test, calls through to {@link #disconnect()} if the test is active. */ @Override + @SuppressWarnings("Finally") protected final void after() { try { tearDownInternal(); diff --git a/geowebcache/diskquota/jdbc/src/test/resources/gwc-test-config.xml b/geowebcache/diskquota/jdbc/src/test/resources/gwc-test-config.xml index 166752990f..43ba0af340 100644 --- a/geowebcache/diskquota/jdbc/src/test/resources/gwc-test-config.xml +++ b/geowebcache/diskquota/jdbc/src/test/resources/gwc-test-config.xml @@ -24,7 +24,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms 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 3a9a9d6947..348f7279f1 100644 --- a/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPollTask.java +++ b/geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSPollTask.java @@ -325,6 +325,7 @@ private void launchSeeding( } } + @SuppressWarnings("ThreadPriorityCheck") protected void stopSeeding(boolean checkLiveCount) { if (this.seedTasks != null) { int liveCount = 0; diff --git a/geowebcache/gmaps/src/test/java/org/geowebcache/service/gmaps/GMapsConverterTest.java b/geowebcache/gmaps/src/test/java/org/geowebcache/service/gmaps/GMapsConverterTest.java index 0540246f6c..5fbe8381bb 100644 --- a/geowebcache/gmaps/src/test/java/org/geowebcache/service/gmaps/GMapsConverterTest.java +++ b/geowebcache/gmaps/src/test/java/org/geowebcache/service/gmaps/GMapsConverterTest.java @@ -90,7 +90,7 @@ public void testGMapsConverter() throws Exception { private static final String TEST_LAYER_NAME = "testLayer"; @Test - public void testConveyorCreation() { + public void testConveyorCreation() throws UnsupportedEncodingException, GeoWebCacheException { StorageBroker sb = null; List filters = new ArrayList<>(); @@ -120,15 +120,11 @@ public void testConveyorCreation() { GMapsConverter converter = new GMapsConverter(sb, tld, gsb); - try { - ConveyorTile conveyorTile = converter.getConveyor(request, response); - Map parameters = conveyorTile.getParameters(); - Assert.assertNotNull(parameters); - // assertTrue(parameters.contains(URLEncoder.encode(CQL_FILTER_PARAMETER_VALUE,"UTF8"))); - Assert.assertEquals( - CQL_FILTER_PARAMETER_VALUE, URLDecoder.decode(parameters.get(CQL_FILTER_PARAMETER_NAME), "UTF8")); - } catch (UnsupportedEncodingException | GeoWebCacheException e) { - Assert.fail(); - } + ConveyorTile conveyorTile = converter.getConveyor(request, response); + Map parameters = conveyorTile.getParameters(); + Assert.assertNotNull(parameters); + // assertTrue(parameters.contains(URLEncoder.encode(CQL_FILTER_PARAMETER_VALUE,"UTF8"))); + Assert.assertEquals( + CQL_FILTER_PARAMETER_VALUE, URLDecoder.decode(parameters.get(CQL_FILTER_PARAMETER_NAME), "UTF8")); } } 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 2806568f2d..53e1d17c8e 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 @@ -206,7 +206,7 @@ public void handleRequest(Conveyor conv) throws GeoWebCacheException { ConveyorKMLTile tile = (ConveyorKMLTile) conv; TileLayer layer; - if (tile.getHint() == HINT_DEBUGGRID) { + if (HINT_DEBUGGRID.equals(tile.getHint())) { layer = KMLDebugGridLayer.getInstance(); // Generate random tile for debugging @@ -223,7 +223,7 @@ public void handleRequest(Conveyor conv) throws GeoWebCacheException { writeTileResponse(tile, false, stats, mimeStr); return; } - } else if (tile.getHint() == HINT_SITEMAP_GLOBAL) { + } else if (HINT_SITEMAP_GLOBAL.equals(tile.getHint())) { layer = null; } else { layer = tld.getTileLayer(tile.getLayerId()); @@ -396,7 +396,7 @@ private void handleOverlay(ConveyorKMLTile tile) throws GeoWebCacheException { TileLayer tileLayer = tile.getLayer(); boolean packageData = false; - if (tile.getWrapperMimeType() == XMLMime.kmz) { + if (XMLMime.kmz.equals(tile.getWrapperMimeType())) { packageData = true; } diff --git a/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMLSiteMap.java b/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMLSiteMap.java index 1c5d72bd14..a2de555924 100644 --- a/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMLSiteMap.java +++ b/geowebcache/kml/src/main/java/org/geowebcache/service/kml/KMLSiteMap.java @@ -52,7 +52,7 @@ public void write() throws GeoWebCacheException, IOException { tile.servletResp.setContentType("application/xml"); tile.servletResp.setStatus(200); - if (tile.getHint() == KMLService.HINT_SITEMAP_LAYER) { + if (KMLService.HINT_SITEMAP_LAYER.equals(tile.getHint())) { writeSiteMap(); } else { writeSiteMapIndex(); diff --git a/geowebcache/mbtiles/src/main/java/org/geowebcache/mbtiles/layer/MBTilesLayer.java b/geowebcache/mbtiles/src/main/java/org/geowebcache/mbtiles/layer/MBTilesLayer.java index 0bdf3952d7..4068c495cf 100644 --- a/geowebcache/mbtiles/src/main/java/org/geowebcache/mbtiles/layer/MBTilesLayer.java +++ b/geowebcache/mbtiles/src/main/java/org/geowebcache/mbtiles/layer/MBTilesLayer.java @@ -73,7 +73,6 @@ public class MBTilesLayer extends AbstractTileLayer implements TileJSONProvider /* * configuration properties */ - private Boolean enabled; private File tilesPath; @@ -100,16 +99,6 @@ public String getBlobStoreId() { return null; } - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - /** Returns the location of the actual tiles set. */ public File getTilesPath() { return tilesPath; diff --git a/geowebcache/mbtiles/src/test/java/org/geowebcache/mbtiles/layer/MBTilesLayerTest.java b/geowebcache/mbtiles/src/test/java/org/geowebcache/mbtiles/layer/MBTilesLayerTest.java index c129ab0c40..993414d076 100644 --- a/geowebcache/mbtiles/src/test/java/org/geowebcache/mbtiles/layer/MBTilesLayerTest.java +++ b/geowebcache/mbtiles/src/test/java/org/geowebcache/mbtiles/layer/MBTilesLayerTest.java @@ -233,6 +233,7 @@ public void testOutsideRange() throws GeoWebCacheException, IOException { } @Test + @SuppressWarnings("MissingFail") public void testEmptyTile() throws GeoWebCacheException, IOException { try { MBTilesLayer testLayer = (MBTilesLayer) config.getLayer("testName").get(); diff --git a/geowebcache/pom.xml b/geowebcache/pom.xml index a5351fa550..b581f6129c 100644 --- a/geowebcache/pom.xml +++ b/geowebcache/pom.xml @@ -69,7 +69,7 @@ false sort ${spotless.apply.skip} - 9.4.55.v20240627 + 10.0.25 2.31.0 9+181-r4173-1 @@ -326,14 +326,9 @@ - - org.codehaus.mojo - cobertura-maven-plugin - 2.0 - maven-failsafe-plugin - 3.3.1 + 3.5.3 @@ -354,13 +349,105 @@ ${skipITs} + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.4 + + + + maven-jar-plugin + 2.4 + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.5.0 + + + + maven-compiler-plugin + 3.14.0 + + + + maven-source-plugin + 2.2.1 + + + + maven-surefire-plugin + 3.5.3 + + + + pl.project13.maven + git-commit-id-plugin + 4.9.10 + + + + maven-assembly-plugin + 2.2 + + + + com.diffplug.spotless + spotless-maven-plugin + 2.43.0 + + + + com.github.ekryd.sortpom + sortpom-maven-plugin + 2.15.0 + + + + org.commonjava.maven.plugins + directory-maven-plugin + 0.3.1 + + + + maven-war-plugin + 3.4.0 + + + + org.eclipse.jetty + jetty-maven-plugin + 10.0.25 + + + + maven-javadoc-plugin + 3.11.2 + + + + maven-pmd-plugin + 3.22.0 + + + + com.github.spotbugs + spotbugs-maven-plugin + 4.8.2.0 + + + + maven-checkstyle-plugin + 3.6.0 + org.codehaus.mojo buildnumber-maven-plugin - 1.4 validate @@ -381,7 +468,6 @@ maven-jar-plugin - 2.4 package @@ -408,12 +494,43 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce + + + enforce + + + + + [3.8,4.0) + You must use Maven 3.8 or higher to build this project. + + + [17,) + + + + + + maven-compiler-plugin - 3.13.0 - 11 - 11 + 17 UTF-8 true @@ -421,7 +538,6 @@ maven-source-plugin - 2.2.1 attach-sources @@ -437,7 +553,6 @@ maven-surefire-plugin - 2.22.1 1 false @@ -454,7 +569,6 @@ pl.project13.maven git-commit-id-plugin - 4.9.10 @@ -472,7 +586,6 @@ maven-assembly-plugin - 2.2 maven-javadoc-plugin - 11 + 17 + + true + false + all - 256M - ISO-8859-1 - -keywords + + true + + ${javadoc.maxHeapSize} + + UTF-8 + + -keywords + true + todo @@ -595,8 +706,8 @@ - http://docs.oracle.com/javase/7/docs/api/ - http://docs.geotools.org/stable/javadocs/ + https://docs.oracle.com/en/java/javase/17/docs/api/ + https://docs.geotools.org/stable/javadocs/ @@ -615,7 +726,6 @@ maven-pmd-plugin - 3.22.0 @@ -675,12 +785,45 @@ maven-compiler-plugin - 3.8.0 false -XDcompilePolicy=simple - -Xplugin:ErrorProne -XepExcludedPaths:${project.build.directory}/generated-sources/.* -Xep:SelfAssertion:OFF ${errorProneFlags} + --should-stop=ifError=FLOW + -Xplugin:ErrorProne -XepExcludedPaths:${project.build.directory}/generated-sources/.* \ + -Xep:SelfAssertion:OFF \ + -Xep:MissingSummary:OFF \ + -Xep:DefaultCharset:OFF \ + -Xep:DoubleCheckedLocking:OFF \ + -Xep:EmptyBlockTag:OFF \ + -Xep:EmptyCatch:OFF \ + -Xep:EqualsGetClass:OFF \ + -Xep:Finalize:OFF \ + -Xep:FutureReturnValueIgnored:OFF \ + -Xep:InconsistentCapitalization:OFF \ + -Xep:InconsistentHashCode:OFF \ + -Xep:InlineMeInliner:OFF \ + -Xep:InlineMeSuggester:OFF \ + -Xep:InvalidBlockTag:OFF \ + -Xep:InvalidLink:OFF \ + -Xep:InvalidParam:OFF \ + -Xep:JavaTimeDefaultTimeZone:OFF \ + -Xep:JavaUtilDate:OFF \ + -Xep:JdkObsolete:OFF \ + -Xep:LongDoubleConversion:OFF \ + -Xep:MixedMutabilityReturnType:OFF \ + -Xep:NonApiType:OFF \ + -Xep:NotJavadoc:OFF \ + -Xep:ObjectEqualsForPrimitives:OFF \ + -Xep:OperatorPrecedence:OFF \ + -Xep:StringCaseLocaleUsage:OFF \ + -Xep:StringSplitter:OFF \ + -Xep:SynchronizeOnNonFinalField:OFF \ + -Xep:UnnecessaryParentheses:OFF \ + -Xep:UnnecessaryStringBuilder:OFF \ + -Xep:UnrecognisedJavadocTag:OFF \ + -Xep:UnusedVariable:OFF \ + ${errorProneFlags} -Xlint:${lint} -Werror @@ -709,7 +852,6 @@ com.github.spotbugs spotbugs-maven-plugin - 4.8.2.0 @@ -741,7 +883,6 @@ maven-checkstyle-plugin - 3.1.1 diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/exception/RestException.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/exception/RestException.java index 3a4db37112..208ed7d0ec 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/exception/RestException.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/exception/RestException.java @@ -21,6 +21,7 @@ * An exception with an associated {@link HttpStatus}. Used to wrap other exceptions so they can be caught and * appropriately handled by an {@link org.springframework.web.bind.annotation.ExceptionHandler} */ +@SuppressWarnings("OverrideThrowableToString") public class RestException extends RuntimeException { /** serialVersionUID */ private static final long serialVersionUID = 5762645820684796082L; diff --git a/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3Ops.java b/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3Ops.java index f12394510b..49198d1006 100644 --- a/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3Ops.java +++ b/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3Ops.java @@ -109,6 +109,7 @@ public void shutDown() { deleteExecutorService.shutdownNow(); } + @SuppressWarnings("Finally") private void issuePendingBulkDeletes() throws StorageException { final String pendingDeletesKey = keyBuilder.pendingDeletes(); Lock lock; diff --git a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConformanceTest.java b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConformanceTest.java index 27265f5c1d..0e499e29f3 100644 --- a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConformanceTest.java +++ b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConformanceTest.java @@ -44,6 +44,7 @@ public class S3BlobStoreConformanceTest extends AbstractBlobStoreTest>> getParametersMapping(String la } } - protected void persistParameterMap(TileObject stObj) { + void persistParameterMap(TileObject stObj) { if (Objects.nonNull(stObj.getParametersId())) { putLayerMetadata( stObj.getLayerName(), diff --git a/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/Utils.java b/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/Utils.java index e717c4271b..01dbab92b6 100644 --- a/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/Utils.java +++ b/geowebcache/sqlite/src/main/java/org/geowebcache/sqlite/Utils.java @@ -13,6 +13,7 @@ */ package org.geowebcache.sqlite; +import com.google.errorprone.annotations.FormatMethod; import java.io.File; import java.util.HashMap; import java.util.Map; @@ -76,18 +77,21 @@ static Map tuplesToMap(Tuple... tuples) { return map; } + @FormatMethod static void check(boolean condition, String message, Object... arguments) { if (!condition) { throw exception(message, arguments); } } + @FormatMethod static RuntimeException exception(String message, Object... arguments) { String finalMessage = String.format(message, arguments); LOGGER.severe(finalMessage); return new RuntimeException(finalMessage); } + @FormatMethod static RuntimeException exception(Exception exception, String message, Object... arguments) { String finalMessage = String.format(message, arguments); LOGGER.severe(finalMessage); 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 6a8105a598..7b441b7a06 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java @@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; +import com.google.errorprone.annotations.FormatMethod; import java.io.File; import java.sql.Connection; import java.sql.PreparedStatement; @@ -213,6 +214,7 @@ public void extract(ResultSet resultSet) throws Exception { }.result; } + @FormatMethod private static void execute(Connection connection, String sql, Object... arguments) { String finalSql = String.format(sql, arguments); try (PreparedStatement statement = connection.prepareStatement(finalSql)) { @@ -226,6 +228,7 @@ private abstract static class ExecuteQuery { public abstract void extract(ResultSet resultSet) throws Exception; + @FormatMethod public ExecuteQuery(Connection connection, String query, Object... arguments) { String finalQuery = String.format(query, arguments); try (PreparedStatement statement = connection.prepareStatement(finalQuery)) { 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 aad5012973..8e9faf74e7 100644 --- a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java +++ b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java @@ -78,6 +78,7 @@ import org.springframework.test.util.ReflectionTestUtils; /** Unit testing for the Swift Blobstore class */ +@SuppressWarnings("DirectInvocationOnMock") public class SwiftBlobStoreTest { private String TEST_KEY = "test/key"; @@ -267,7 +268,7 @@ public void testPutWhenBlobIsAnInvalidMimeType() { @Test @SuppressWarnings("PMD.CloseResource") - public void get() { + public void get() throws StorageException { String thePayloadData = "Test Content"; Date lastModified = new Date(); ByteSourcePayload testByteSourcePayload = new ByteSourcePayload(new ByteSource() { @@ -281,28 +282,24 @@ public InputStream openStream() { when(swiftObject.getLastModified()).thenReturn(lastModified); when(swiftObject.getPayload()).thenReturn(testByteSourcePayload); - try { - when(objectApi.get("sample/key")).thenReturn(swiftObject); - boolean result = this.swiftBlobStore.get(sampleTileObject); + when(objectApi.get("sample/key")).thenReturn(swiftObject); + boolean result = this.swiftBlobStore.get(sampleTileObject); - verify(keyBuilder, times(1)).forTile(sampleTileObject); - verify(objectApi, times(1)).get("sample/key"); - verify(swiftObject, times(1)).getPayload(); + verify(keyBuilder, times(1)).forTile(sampleTileObject); + verify(objectApi, times(1)).get("sample/key"); + verify(swiftObject, times(1)).getPayload(); - ByteArrayResource expectedByteArray = new ByteArrayResource(thePayloadData.getBytes()); - ByteArrayResource actualByteArray = (ByteArrayResource) sampleTileObject.getBlob(); + ByteArrayResource expectedByteArray = new ByteArrayResource(thePayloadData.getBytes()); + ByteArrayResource actualByteArray = (ByteArrayResource) sampleTileObject.getBlob(); - assertEquals(thePayloadData.length(), sampleTileObject.getBlobSize()); - assertArrayEquals(expectedByteArray.getContents(), actualByteArray.getContents()); - assertEquals(lastModified.getTime(), sampleTileObject.getCreated()); - assertTrue(result); + assertEquals(thePayloadData.length(), sampleTileObject.getBlobSize()); + assertArrayEquals(expectedByteArray.getContents(), actualByteArray.getContents()); + assertEquals(lastModified.getTime(), sampleTileObject.getCreated()); + assertTrue(result); - when(objectApi.get("sample/key")).thenReturn(null); - result = this.swiftBlobStore.get(sampleTileObject); - assertFalse(result); - } catch (StorageException e) { - fail("A storage exception was not expected to be thrown"); - } + when(objectApi.get("sample/key")).thenReturn(null); + result = this.swiftBlobStore.get(sampleTileObject); + assertFalse(result); } @Test diff --git a/geowebcache/tms/src/main/java/org/geowebcache/service/tms/TMSDocumentFactory.java b/geowebcache/tms/src/main/java/org/geowebcache/service/tms/TMSDocumentFactory.java index 2dbc8caa71..508b62cb98 100644 --- a/geowebcache/tms/src/main/java/org/geowebcache/service/tms/TMSDocumentFactory.java +++ b/geowebcache/tms/src/main/java/org/geowebcache/service/tms/TMSDocumentFactory.java @@ -232,9 +232,9 @@ protected String getTileMapDoc( } protected String profileForGridSet(GridSet gridSet) { - if (gridSet == gsb.getWorldEpsg4326()) { + if (gsb.getWorldEpsg4326().equals(gridSet)) { return "global-geodetic"; - } else if (gridSet == gsb.getWorldEpsg3857()) { + } else if (gsb.getWorldEpsg3857().equals(gridSet)) { return "global-mercator"; } else { return "local"; diff --git a/geowebcache/tms/src/test/java/org/geowebcache/service/tms/TMSServiceTest.java b/geowebcache/tms/src/test/java/org/geowebcache/service/tms/TMSServiceTest.java index 50b0917721..317d109aa3 100644 --- a/geowebcache/tms/src/test/java/org/geowebcache/service/tms/TMSServiceTest.java +++ b/geowebcache/tms/src/test/java/org/geowebcache/service/tms/TMSServiceTest.java @@ -178,6 +178,7 @@ protected void tileMapsForLayer( } } + @SuppressWarnings("DirectInvocationOnMock") private static TileLayer mockTileLayer( TileLayerDispatcher tld, GridSetBroker gridsetBroker, @@ -240,9 +241,6 @@ private static TileLayer mockTileLayer( @Test public void testTileMapServiceDocument() throws Exception { - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); - service = new TMSService(sb, tld, gridsetBroker, mock(RuntimeStats.class)); HttpServletRequest req = mock(HttpServletRequest.class); diff --git a/geowebcache/web/pom.xml b/geowebcache/web/pom.xml index 63ffddbac3..6858dc694e 100644 --- a/geowebcache/web/pom.xml +++ b/geowebcache/web/pom.xml @@ -157,7 +157,6 @@ maven-war-plugin - 3.2.3 install @@ -175,18 +174,21 @@ org.eclipse.jetty jetty-maven-plugin - 9.4.14.v20181114 /geowebcache + + + 8081 + log4j2.configurationFile src/test/resources/log4j2-test.xml - 10 + 10 9966 foo 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 79d6e7b045..5346f7d640 100644 --- a/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java +++ b/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java @@ -394,9 +394,9 @@ public void testGetLayers() throws Exception { assertThat( doc, hasXPath( - "/layers/layer[name/text()='topp:states']/atom:link/@href", + "/layers/layer[name/text()='states']/atom:link/@href", equalTo(jetty.getUri() - .resolve("/geowebcache/rest/layers/topp:states.xml") + .resolve("/geowebcache/rest/layers/states.xml") .toString()))); assertThat( doc, @@ -557,10 +557,7 @@ public void testGetLayer() throws Exception { admin.getClient(), equalTo(200), doc -> { assertThat(doc, hasXPath("/wmsLayer/name", equalTo("img states"))); assertThat( - doc, - hasXPath( - "/wmsLayer/wmsUrl/string", - equalTo("https://demo.boundlessgeo.com/geoserver/wms?"))); + doc, hasXPath("/wmsLayer/wmsUrl/string", equalTo("http://localhost:8080/geoserver/wms?"))); assertThat(doc, hasXPath("/wmsLayer/wmsLayers", equalTo("nurc:Img_Sample,topp:states"))); }); } @@ -572,7 +569,7 @@ public void testLayerNoAuth() throws Exception { doGetXML( "rest/layers/img%20states.xml", client, equalTo(401), doc -> { - assertThat(doc, not(hasXPath("//wmsUrl", containsString("demo.opengeo.org")))); + assertThat(doc, not(hasXPath("//wmsUrl", containsString("localhost:8080")))); assertThat(doc, not(hasXPath("//wmsLayer", containsString("nurc")))); assertThat(doc, not(hasXPath("//wmsLayer", containsString("Img_Sample")))); assertThat(doc, not(hasXPath("//wmsLayer", containsString("topp")))); @@ -613,7 +610,7 @@ public void testAddLayer() throws Exception { doGetXML( "rest/layers/img%20states.xml", notAUser.getClient(), equalTo(401), doc -> { - assertThat(doc, not(hasXPath("//wmsUrl", containsString("demo.opengeo.org")))); + assertThat(doc, not(hasXPath("//wmsUrl", containsString("localhost:8080")))); assertThat(doc, not(hasXPath("//wmsLayer", containsString("nurc")))); assertThat(doc, not(hasXPath("//wmsLayer", containsString("Img_Sample")))); assertThat(doc, not(hasXPath("//wmsLayer", containsString("topp")))); @@ -1026,7 +1023,7 @@ public void testSeedPost() throws Exception { ""; try (CloseableHttpResponse response = - handlePost(URI.create("/geowebcache/rest/seed/topp:states.xml"), admin.getClient(), seedLayer)) { + handlePost(URI.create("/geowebcache/rest/seed/states.xml"), admin.getClient(), seedLayer)) { assertEquals(200, response.getStatusLine().getStatusCode()); } } @@ -1034,7 +1031,7 @@ public void testSeedPost() throws Exception { @Test public void testSeedGet() throws Exception { try (CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed/topp:states"), admin.getClient())) { + handleGet(URI.create("/geowebcache/rest/seed/states"), admin.getClient())) { assertEquals(200, response.getStatusLine().getStatusCode()); } } @@ -1049,7 +1046,7 @@ public void testSeedGetNoLayer() throws Exception { @Test public void testSeedGetSeedForm() throws Exception { try (CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed/topp:states"), admin.getClient())) { + handleGet(URI.create("/geowebcache/rest/seed/states"), admin.getClient())) { assertEquals(200, response.getStatusLine().getStatusCode()); } } @@ -1064,7 +1061,7 @@ public void testSeedGetJson() throws Exception { @Test public void testSeedGetLayerJson() throws Exception { try (CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed/topp:states.json"), admin.getClient())) { + handleGet(URI.create("/geowebcache/rest/seed/states.json"), admin.getClient())) { assertEquals(200, response.getStatusLine().getStatusCode()); } } @@ -1072,7 +1069,7 @@ public void testSeedGetLayerJson() throws Exception { @Test public void testSeedGetLayerXml() throws Exception { try (CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed/topp:states.xml"), admin.getClient())) { + handleGet(URI.create("/geowebcache/rest/seed/states.xml"), admin.getClient())) { assertEquals(200, response.getStatusLine().getStatusCode()); } } @@ -1090,7 +1087,7 @@ public void testKillAll() throws Exception { public void testLayerKillAll() throws Exception { String killCommand = "kill_all=all"; try (CloseableHttpResponse response = - handlePost(URI.create("/geowebcache/rest/seed/topp:states"), admin.getClient(), killCommand)) { + handlePost(URI.create("/geowebcache/rest/seed/states"), admin.getClient(), killCommand)) { assertEquals(200, response.getStatusLine().getStatusCode()); } } diff --git a/geowebcache/web/src/test/java/org/geowebcache/jetty/Start.java b/geowebcache/web/src/test/java/org/geowebcache/jetty/Start.java index 41c3736659..7bbaa3b830 100644 --- a/geowebcache/web/src/test/java/org/geowebcache/jetty/Start.java +++ b/geowebcache/web/src/test/java/org/geowebcache/jetty/Start.java @@ -42,7 +42,7 @@ public static void main(String[] args) { HttpConfiguration httpConfiguration = new HttpConfiguration(); ServerConnector http = new ServerConnector(jettyServer, new HttpConnectionFactory(httpConfiguration)); - http.setPort(Integer.getInteger("jetty.port", 8080)); + http.setPort(Integer.getInteger("jetty.http.port", 8081)); http.setAcceptQueueSize(100); http.setIdleTimeout(1000 * 60 * 60); diff --git a/geowebcache/wms/src/main/java/org/geowebcache/io/codec/ImageEncoderImpl.java b/geowebcache/wms/src/main/java/org/geowebcache/io/codec/ImageEncoderImpl.java index 1f114dc255..63464ec60f 100644 --- a/geowebcache/wms/src/main/java/org/geowebcache/io/codec/ImageEncoderImpl.java +++ b/geowebcache/wms/src/main/java/org/geowebcache/io/codec/ImageEncoderImpl.java @@ -104,7 +104,7 @@ public ImageWriteParam prepareParameters( @Override public RenderedImage prepareImage(RenderedImage image, MimeType type) { - boolean isPNG8 = type == ImageMime.png8; + boolean isPNG8 = ImageMime.png8.equals(type); if (isPNG8) { return applyPalette(image); } @@ -150,10 +150,11 @@ public RenderedImage prepareImage(RenderedImage image, MimeType type) { TIFF("image/tiff"), BMP("image/bmp"); - private String[] formatNames; + @SuppressWarnings("ImmutableEnumChecker") // instance is immutable + private final List formatNames; WriteHelper(String... formatNames) { - this.formatNames = formatNames; + this.formatNames = List.of(formatNames); } public ImageWriteParam prepareParams(Map inputParams, ImageWriter writer) { 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 fed28b92a5..e9f8709c7c 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 @@ -155,9 +155,10 @@ public enum HintsLevel { DEFAULT(1, "default"), SPEED(2, "speed"); - private RenderingHints hints; + @SuppressWarnings("ImmutableEnumChecker") // RenderingHints is mutable + private final RenderingHints hints; - private String mode; + private final String mode; HintsLevel(int numHint, String mode) { this.mode = mode; @@ -213,6 +214,8 @@ public enum HintsLevel { RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF)); hints.add(new RenderingHints(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE)); break; + default: + hints = null; } } 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 1459053eb2..cdb9c46ae9 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 @@ -20,10 +20,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import com.google.common.base.Objects; import java.util.Collections; import java.util.LinkedList; import java.util.List; +import java.util.Objects; import org.easymock.EasyMock; import org.geotools.data.ows.OperationType; import org.geotools.ows.wms.CRSEnvelope; @@ -148,7 +148,7 @@ protected Matcher infoEquals(int expected) { @Override public boolean matches(Object item) { return item instanceof GridSet - && Objects.equal(((GridSet) item).getDescription(), Integer.toString(expected)); + && Objects.equals(((GridSet) item).getDescription(), Integer.toString(expected)); } }; } diff --git a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSServiceTest.java b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSServiceTest.java index 773199d32e..183062542c 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSServiceTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSServiceTest.java @@ -147,6 +147,7 @@ protected void testMultipleCrsMatchingGridSubsets(final String srs, final String tileRequest.getTileIndex()); } + @SuppressWarnings("DirectInvocationOnMock") private TileLayer mockTileLayer(String layerName, List gridSetNames) throws Exception { TileLayer tileLayer = mock(TileLayer.class); diff --git a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSTileFuserTest.java b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSTileFuserTest.java index d57b1e62f1..bad3f50e15 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSTileFuserTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSTileFuserTest.java @@ -64,6 +64,7 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; +@SuppressWarnings("FloatCast") public class WMSTileFuserTest { GridSetBroker gridSetBroker = new GridSetBroker(Collections.singletonList(new DefaultGridsets(false, false))); diff --git a/geowebcache/wmts/src/main/java/org/geowebcache/service/wmts/WMTSService.java b/geowebcache/wmts/src/main/java/org/geowebcache/service/wmts/WMTSService.java index 8d4c2f6fef..a2af618a75 100644 --- a/geowebcache/wmts/src/main/java/org/geowebcache/service/wmts/WMTSService.java +++ b/geowebcache/wmts/src/main/java/org/geowebcache/service/wmts/WMTSService.java @@ -93,9 +93,9 @@ enum RestRequest { // "/{layer}/{style}/tilejson/{tileformat}" TILEJSON_STYLE(buildRestPattern(4, true), RequestType.TILEJSON, true); - Pattern pattern; - RequestType type; - boolean hasStyle; + final Pattern pattern; + final RequestType type; + final boolean hasStyle; RestRequest(String pattern, RequestType type, boolean hasStyle) { this.pattern = Pattern.compile(pattern); @@ -144,7 +144,7 @@ public Map toKVP(HttpServletRequest request) { } else { values.put("tileformat", matcher.group(++i)); } - if (request.getParameter("format") instanceof String) { + if (request.getParameter("format") != null) { if (isFeatureInfo) { values.put("infoformat", request.getParameter("format")); } else { diff --git a/geowebcache/wmts/src/main/java/org/geowebcache/service/wmts/WMTSUtils.java b/geowebcache/wmts/src/main/java/org/geowebcache/service/wmts/WMTSUtils.java index f1626736c4..8b130791d8 100644 --- a/geowebcache/wmts/src/main/java/org/geowebcache/service/wmts/WMTSUtils.java +++ b/geowebcache/wmts/src/main/java/org/geowebcache/service/wmts/WMTSUtils.java @@ -25,11 +25,11 @@ final class WMTSUtils { private WMTSUtils() {} - protected static List getLayerFormats(TileLayer layer) throws IOException { + static List getLayerFormats(TileLayer layer) throws IOException { return layer.getMimeTypes().stream().map(MimeType::getFormat).collect(Collectors.toList()); } - protected static List getLayerFormatsExtensions(TileLayer layer) throws IOException { + static List getLayerFormatsExtensions(TileLayer layer) throws IOException { return layer.getMimeTypes().stream().map(MimeType::getFileExtension).collect(Collectors.toList()); } 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 215fa53483..f30ba4feb0 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 @@ -98,6 +98,7 @@ import org.springframework.web.context.WebApplicationContext; import org.w3c.dom.Document; +@SuppressWarnings("DirectInvocationOnMock") public class WMTSServiceTest { private WMTSService service; @@ -290,9 +291,6 @@ private TileLayer mockTileLayerWithJSONSupport(String layerName, List gr @Test public void testGetCap() throws Exception { - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); - service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Map kvp = new CaseInsensitiveMap<>(); @@ -548,8 +546,6 @@ public ServiceInformation getServiceInformation() { }); extensions.add(new WMTSExtensionImpl()); // mock execution context - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); extensions.forEach(service::addExtension); Map kvp = new CaseInsensitiveMap<>(); @@ -618,8 +614,6 @@ public ServiceInformation getServiceInformation() { @Test public void testGetCapServiceInfo() throws Exception { TileLayerDispatcher tldx = mockTileLayerDispatcher(); - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tldx, null, mock(RuntimeStats.class)); @@ -682,9 +676,6 @@ public void testGetCapServiceInfo() throws Exception { @Test public void testGetCapOneWGS84BBox() throws Exception { - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); - service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Map kvp = new CaseInsensitiveMap<>(); @@ -749,9 +740,6 @@ public void testGetCapOneWGS84BBox() throws Exception { @Test public void testGetCapUnboundedStyleFilter() throws Exception { - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); - service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Map kvp = new CaseInsensitiveMap<>(); @@ -810,9 +798,6 @@ public void testGetCapUnboundedStyleFilter() throws Exception { @Test public void testGetCapEmptyStyleFilter() throws Exception { - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); - service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Map kvp = new CaseInsensitiveMap<>(); @@ -871,9 +856,6 @@ public void testGetCapEmptyStyleFilter() throws Exception { @Test public void testGetCapMultipleStyles() throws Exception { - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); - service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Map kvp = new CaseInsensitiveMap<>(); @@ -975,9 +957,6 @@ private static XpathEngine buildWMTSXPath() { @Test public void testGetCapWithMultipleDimensions() throws Exception { - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); - service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Map kvp = new CaseInsensitiveMap<>(); @@ -1048,9 +1027,6 @@ public void testGetCapWithMultipleDimensions() throws Exception { @Test public void testGetTileWithStyle() throws Exception { - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); - service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Map kvp = new CaseInsensitiveMap<>(); @@ -1112,8 +1088,6 @@ public void testGetTileWithStyle() throws Exception { @Test public void testDispatchCustomOperations() throws Exception { // instantiating all the necessary machinery to perform the request - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Map kvp = new CaseInsensitiveMap<>(); kvp.put("service", new String[] {"WMTS"}); @@ -1369,9 +1343,6 @@ public void testGetFeatureInfoSecure() throws Exception { @Test public void testGetCapWithTileJSONDifferentUrls() throws Exception { - GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); - when(gwcd.getServletPrefix()).thenReturn(null); - service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Map kvp = new CaseInsensitiveMap<>(); diff --git a/geowebcache/wmts/src/test/resources/org/geowebcache/service/wmts/geowebcache_190.xml b/geowebcache/wmts/src/test/resources/org/geowebcache/service/wmts/geowebcache_190.xml index 6cc3d6e15f..c5114ecfb9 100644 --- a/geowebcache/wmts/src/test/resources/org/geowebcache/service/wmts/geowebcache_190.xml +++ b/geowebcache/wmts/src/test/resources/org/geowebcache/service/wmts/geowebcache_190.xml @@ -127,7 +127,7 @@ - http://demo.opengeo.org/geoserver/topp/wms + http://localhost:8080/geoserver/topp/wms @@ -139,7 +139,7 @@ image/png8 - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample @@ -176,7 +176,7 @@ - http://demo.opengeo.org/geoserver/wms + http://localhost:8080/geoserver/wms nurc:Img_Sample,topp:states false