Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected void before() throws Throwable {
}

@Override
@SuppressWarnings("PMD.UseTryWithResources") // client is a field, not created here
protected void after() {
if (!isConfigured()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public long getSize() {

/** @see org.geowebcache.io.Resource#transferTo(java.nio.channels.WritableByteChannel) */
@Override
@SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.EmptyControlStatement"})
@SuppressWarnings("PMD.EmptyControlStatement")
public long transferTo(WritableByteChannel channel) throws IOException {
if (length > 0) {
ByteBuffer buffer = ByteBuffer.wrap(data, offset, length);
Expand All @@ -103,7 +103,7 @@ public long transferTo(WritableByteChannel channel) throws IOException {

/** @see org.geowebcache.io.Resource#transferFrom(java.nio.channels.ReadableByteChannel) */
@Override
@SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.EmptyControlStatement"})
@SuppressWarnings("PMD.EmptyControlStatement")
public long transferFrom(ReadableByteChannel channel) throws IOException {
if (channel instanceof FileChannel) {
FileChannel fc = (FileChannel) channel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public long getSize() {
}

@Override
@SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.EmptyControlStatement"})
@SuppressWarnings("PMD.EmptyControlStatement")
public long transferTo(WritableByteChannel target) throws IOException {
// FileLock lock = in.lock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public static String[][] selectedStringArraysFromMap(Map<String, String[]> map,
*
* @return map subset containing (URL decoded) values for {@code keys}, with keys normalized to upper case
*/
@SuppressWarnings("unchecked")
public static Map<String, String> selectedStringsFromMap(Map<String, ?> map, String encoding, String... keys) {

map = new CaseInsensitiveMap<>(map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ public void testAddsTypedExtensions() throws Throwable {
rule.apply(
new Statement() {

@SuppressWarnings("unchecked")
@Override
public void evaluate() throws Throwable {
String bean1 = "THISISTHEBEAN";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void createTestUnit() throws Exception {

private void putLayerMetadataConcurrently(final int srcStoreKey, final FileBlobStore srcStore, int numberOfThreads)
throws InterruptedException {
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService service = Executors.newFixedThreadPool(numberOfThreads);
CountDownLatch latch = new CountDownLatch(numberOfThreads);
for (int i = 0; i < numberOfThreads; i++) {
Expand All @@ -72,7 +71,6 @@ private void putLayerMetadataConcurrently(final int srcStoreKey, final FileBlobS
}

private void executeStoresConcurrently(int numberOfStores, int numberOfThreads) throws InterruptedException {
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService service = Executors.newFixedThreadPool(numberOfStores);
CountDownLatch latch = new CountDownLatch(numberOfStores);
for (int i = 0; i < numberOfStores; i++) {
Expand Down Expand Up @@ -102,7 +100,6 @@ public void testMetadataWithPointInKey() throws Exception {
public void testConcurrentMetadataWithPointInKey() throws InterruptedException {
assertThat(store.getLayerMetadata("testLayer", "test.Key"), nullValue());
int numberOfThreads = 2;
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService service = Executors.newFixedThreadPool(numberOfThreads);
CountDownLatch latch = new CountDownLatch(numberOfThreads);
for (int i = 0; i < numberOfThreads; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@ public void testExceptionInAddListenerDoesntBlockOtherListeners() throws Excepti
EasyMock.verify(listener2);
}

@SuppressWarnings("unchecked")
@Test
public void testExceptionInAddListenerRecordsSuppressedExceptions() throws Exception {
BlobStoreConfigurationListener listener1 =
Expand Down Expand Up @@ -578,7 +577,6 @@ public void testExceptionInModifyListenerDoesntBlockOtherListeners() throws Exce
EasyMock.verify(listener2);
}

@SuppressWarnings("unchecked")
@Test
public void testExceptionInModifyListenerRecordsSuppressedExceptions() throws Exception {
BlobStoreConfigurationListener listener1 =
Expand Down Expand Up @@ -683,7 +681,6 @@ public void testExceptionInRenameListenerDoesntBlockOtherListeners() throws Exce
EasyMock.verify(listener2);
}

@SuppressWarnings("unchecked")
@Test
public void testExceptionInRenameListenerRecordsSuppressedExceptions() throws Exception {
BlobStoreConfigurationListener listener1 =
Expand Down Expand Up @@ -788,7 +785,6 @@ public void testExceptionInRemoveListenerDoesntBlockOtherListeners() throws Exce
EasyMock.verify(listener2);
}

@SuppressWarnings("unchecked")
@Test
public void testExceptionInRemoveListenerRecordsSuppressedExceptions() throws Exception {
BlobStoreConfigurationListener listener1 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void testGetExisting() throws Exception {
assertThat(retrieved, isPresent());
}

@SuppressWarnings({"unchecked", "PMD.UnnecessaryCast"})
@SuppressWarnings("unchecked")
@Test
public void testCantModifyReturnedCollection() throws Exception {
I info = getGoodInfo("test", 1);
Expand Down Expand Up @@ -322,7 +322,6 @@ public void testConcurrentAdds() throws Exception {
defaultCount + 10,
getInfoNames(config).size());
// get a thread pool
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService pool =
Executors.newFixedThreadPool(16, (Runnable r) -> new Thread(r, "Info Concurrency Test for ADD"));
// create a bunch of concurrent adds
Expand Down Expand Up @@ -364,7 +363,6 @@ public void testConcurrentDeletes() throws Exception {
defaultCount + 100,
getInfoNames(config).size());
// get a thread pool
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService pool =
Executors.newFixedThreadPool(16, (Runnable r) -> new Thread(r, "Info Concurrency Test for DELETE"));
// create a bunch of concurrent deletes
Expand Down Expand Up @@ -404,7 +402,6 @@ public void testConcurrentModifies() throws Exception {
defaultCount + 100,
getInfoNames(config).size());
// get a thread pool
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService pool =
Executors.newFixedThreadPool(16, (Runnable r) -> new Thread(r, "Info Concurrency Test for MODIFY"));
// create a bunch of concurrent modifies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public void testExceptionDoesntPreventOthers() throws Exception {
control.verify();
}

@SuppressWarnings("unchecked")
@Test
public void testSuppressedExceptionsRecorded() throws Exception {
ListenerCollection<Runnable> collection = new ListenerCollection<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ private List<ConveyorTile> getTiles(StorageBroker storageBroker, TileRange tr, f
long[] gridLoc = trIter.nextMetaGridLocation(new long[3]);

// six concurrent requests max
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService requests = Executors.newFixedThreadPool(6);
ExecutorCompletionService<ConveyorTile> completer = new ExecutorCompletionService<>(requests);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public void tearDown() throws Exception {}

/** For a metatiled seed request over a given zoom level, make sure the correct wms calls are issued */
@Test
@SuppressWarnings("serial")
public void testSeedWMSRequests() throws Exception {
WMSLayer tl = createWMSLayer("image/png");

Expand Down Expand Up @@ -243,7 +242,6 @@ protected void makeRequest(

/** Make sure when seeding a given zoom level, the correct tiles are sent to the {@link StorageBroker} */
@Test
@SuppressWarnings("serial")
public void testSeedStoredTiles() throws Exception {

WMSLayer tl = createWMSLayer("image/png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

public class TruncateBboxRequestTest {

@SuppressWarnings("unchecked")
protected SeedRequest seedRequest(
String layerName,
String gridSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ public void testMetadataWithPercentInValue() throws Exception {
assertThat(store.getLayerMetadata("testLayer", "testKey"), equalTo("test%Value"));
}

@SuppressWarnings("unchecked")
@Test
public void testParameterList() throws Exception {
Map<String, String> params1 = Collections.singletonMap("testKey", "testValue1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ private long traverseTileRangeIter(
final int[] metaTilingFactors)
throws Exception {

@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
final ExecutorService executorService = Executors.newFixedThreadPool(nThreads);

final TileRange tileRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public GeoRSSReader createReader(final URL url, final String username, final Str
contentEncoding = "UTF-8";
}

@SuppressWarnings("PMD.CloseResource") // The stream will be kept open to get new events
Reader reader =
new BufferedReader(new InputStreamReader(response.getEntity().getContent(), contentEncoding));
if (log.isLoggable(Level.FINE)) {
Expand Down
10 changes: 8 additions & 2 deletions geowebcache/pmd-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ under the License.
-->
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Default Maven PMD Plugin Ruleset" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
GeoTools ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_rulesets.html
GeoWebCache ruleset. See https://pmd.github.io/pmd/pmd_userdocs_making_rulesets.html
</description>
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
<rule ref="category/java/bestpractices.xml/CheckResultSet"/>
<!--rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /-->
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
<rule ref="category/java/bestpractices.xml/UnusedPrivateField">
<properties>
<!-- The rule ignores fields that are annotated, but we want to check those annotated only with @SuppressWarnings -->
<property name="reportForAnnotations" value="java.lang.SuppressWarnings" />
</properties>
</rule>
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
<rule ref="category/java/bestpractices.xml/SystemPrintln"/>
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach" />
Expand All @@ -45,6 +50,7 @@ GeoTools ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_ru
<rule ref="category/java/bestpractices.xml/UseStandardCharsets" />
<rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty" />
<rule ref="category/java/bestpractices.xml/UnnecessaryWarningSuppression" />

<rule ref="category/java/codestyle.xml/EmptyControlStatement"/>
<rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/>
Expand Down
2 changes: 1 addition & 1 deletion geowebcache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<errorProneFlags></errorProneFlags>
<errorProne.version>2.31.0</errorProne.version>
<javac.version>9+181-r4173-1</javac.version>
<pmd.version>7.13.0</pmd.version>
<pmd.version>7.14.0</pmd.version>
<checkstyle.skip>false</checkstyle.skip>
<qa>false</qa>
<lint>deprecation,unchecked</lint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public void testRenameOperation() throws Exception {
}

@Test
@SuppressWarnings("unchecked") // TODO: remove when upgrading to Hamcrest 2
// TODO: remove when upgrading to Hamcrest 2
public void testOpeningDatabaseFileWithMbtilesMetadata() throws Exception {
// create and instantiate mbtiles metadata
File mbtilesMetadataDirectory = buildRootFile("mbtiles-metadata");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ private void genericMultiThreadsTest(int threadsNumber, int workersNumber, long
throws Exception {
SqliteConnectionManager connectionManager = new SqliteConnectionManager(poolSize, 10);
connectionManagersToClean.add(connectionManager);
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService executor = Executors.newFixedThreadPool(threadsNumber);
Random random = new Random();
List<Future<Tuple<File, String>>> results = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ private static void rawSqlitle(File rootDirectory, File seedFile, long[][] tiles
}
FileUtils.copyFile(seedFile, databaseFile);
// submitting the select tasks
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService executor = Executors.newFixedThreadPool(WORKERS);
long startTime = System.currentTimeMillis();
try (Connection connection = DriverManager.getConnection("jdbc:sqlite:" + seedFile.getPath())) {
Expand Down Expand Up @@ -119,7 +118,6 @@ private static void pooledSqlitle(File rootDirectory, File seedFile, long[][] ti
}
FileUtils.copyFile(seedFile, databaseFile);
// submitting the select tasks
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService executor = Executors.newFixedThreadPool(WORKERS);
SqliteConnectionManager connectionManager = new SqliteConnectionManager(10, 2000);
long startTime = System.currentTimeMillis();
Expand Down Expand Up @@ -165,7 +163,6 @@ private static void mbtilesStore(File rootDirectory, File seedFile, long[][] til
}
FileUtils.copyFile(seedFile, databaseFile);
// submitting the select tasks
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService executor = Executors.newFixedThreadPool(WORKERS);
long startTime = System.currentTimeMillis();
// mbtiles store configuration
Expand Down Expand Up @@ -219,7 +216,6 @@ private static void fileStore(File seedDirectory, long[][] tiles) throws Excepti
LOGGER.info(String.format("Start reading from directory'%s'.", seedDirectory));
}
// submitting the read tasks
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ExecutorService executor = Executors.newFixedThreadPool(WORKERS);
long startTime = System.currentTimeMillis();
// instantiate the file blobstore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ public void deleteByParametersId() {
@Ignore // unreliable test timing
public void deleteWhenUploadExists() throws Exception {
BlockingQueue<Runnable> taskQueue = spy(new LinkedBlockingQueue<>(1000));
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
ThreadPoolExecutor executor = spy(new ThreadPoolExecutor(
1, 1, 60L, TimeUnit.SECONDS, taskQueue, new ThreadPoolExecutor.CallerRunsPolicy()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ client, equalTo(401), doc -> {
* Check that the given request gives a 401 Forbidden when not authenticated, and otherwise has a response matching
* the given matcher
*/
@SuppressWarnings({"PMD.CloseResource", "PMD.UnusedLocalVariable"})
@SuppressWarnings("PMD.UnusedLocalVariable")
protected void testSecured(HttpUriRequest request, Matcher<Integer> authenticatedStatus) throws Exception {
{
CloseableHttpClient client = admin.getClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ protected Collection<String> getDefaultProxyRequestWhitelist() {
}
}

@SuppressWarnings("PMD.UnnecessaryCast")
protected Collection<String> getProxyRequestWhitelist() {
return Optional.ofNullable(GeoWebCacheExtensions.getProperty(GEOWEBCACHE_WMS_PROXY_REQUEST_WHITELIST))
.map(list -> list.split(";"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ WebMapServer getWMS() {
}

@Test
@SuppressWarnings("unchecked") // to be removed once we upgrade to Hamcrest 2, @SafeVarArgs
// to be removed once we upgrade to Hamcrest 2, @SafeVarArgs
public void testDelegateInitializingLayers() throws Exception {
GridSetBroker broker = new GridSetBroker(Collections.singletonList(new DefaultGridsets(false, false)));
String url = "http://test/wms";
Expand Down
Loading
Loading