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 @@ -22,7 +22,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -123,8 +123,8 @@ protected Matcher<TileLayer> infoEquals(TileLayer expected) {

@Override
public boolean matches(Object item) {
return item instanceof ArcGISCacheLayer
&& ((ArcGISCacheLayer) item).getBackendTimeout().equals(expected.getBackendTimeout());
return item instanceof ArcGISCacheLayer agiscl
&& agiscl.getBackendTimeout().equals(expected.getBackendTimeout());
}
};
}
Expand All @@ -135,8 +135,8 @@ protected Matcher<TileLayer> infoEquals(int expected) {

@Override
public boolean matches(Object item) {
return item instanceof ArcGISCacheLayer
&& ((ArcGISCacheLayer) item).getBackendTimeout().equals(expected);
return item instanceof ArcGISCacheLayer agiscl
&& agiscl.getBackendTimeout().equals(expected);
}
};
}
Expand All @@ -158,7 +158,7 @@ protected void makeConfigFile() throws Exception {
configFile = temp.newFile("geowebcache.xml");

URL source = XMLConfigurationLayerConformanceWithArcGisLayersTest.class.getResource("geowebcache.xml");
try (Stream<String> lines = Files.lines(Paths.get(source.toURI()))) {
try (Stream<String> lines = Files.lines(Path.of(source.toURI()))) {
List<String> replaced = lines.map(line -> {
String tilingSchemePath =
resourceAsFile("/compactcache/Conf.xml").getAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ public String getLocation() {
String container = this.getContainer();
String prefix = this.getPrefix();
if (prefix == null) {
return String.format("container: %s", container);
return "container: %s".formatted(container);
} else {
return String.format("container: %s prefix: %s", container, prefix);
return "container: %s prefix: %s".formatted(container, prefix);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;

import java.io.Serial;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
Expand All @@ -30,6 +31,7 @@

/** Plain old java object representing the configuration for an Azure blob store. */
public class AzureBlobStoreInfo extends BlobStoreInfo {
@Serial
private static final long serialVersionUID = -8068069256598987874L;

/**
Expand Down Expand Up @@ -229,9 +231,9 @@ public String getLocation() {
String container = this.getContainer();
String prefix = this.getPrefix();
if (prefix == null) {
return String.format("container: %s", container);
return "container: %s".formatted(container);
} else {
return String.format("container: %s prefix: %s", container, prefix);
return "container: %s prefix: %s".formatted(container, prefix);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ String getServiceURL(AzureBlobStoreData configuration) {
// default to account name based location
String proto = configuration.isUseHTTPS() ? "https" : "http";
String account = configuration.getAccountName();
serviceURL = String.format("%s://%s.blob.core.windows.net", proto, account);
serviceURL = "%s://%s.blob.core.windows.net".formatted(proto, account);
}
return serviceURL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ public Long deleteParallel(List<String> keys) throws StorageException {

public boolean scheduleAsyncDelete(final String prefix) throws StorageException {
final long timestamp = currentTimeSeconds();
String msg = String.format(
"Issuing bulk delete on '%s/%s' for objects older than %d",
client.getContainerName(), prefix, timestamp);
String msg = "Issuing bulk delete on '%s/%s' for objects older than %d"
.formatted(client.getContainerName(), prefix, timestamp);
log.info(msg);

try {
Expand Down Expand Up @@ -159,9 +158,8 @@ public void issuePendingBulkDeletes() throws StorageException {
final String prefix = e.getKey().toString();
final long timestamp = Long.parseLong(e.getValue().toString());
if (log.isLoggable(Level.INFO))
log.info(String.format(
"Restarting pending bulk delete on '%s/%s':%d",
client.getContainerName(), prefix, timestamp));
log.info("Restarting pending bulk delete on '%s/%s':%d"
.formatted(client.getContainerName(), prefix, timestamp));
if (!asyncDelete(prefix, timestamp)) {
deletesToClear.add(prefix);
}
Expand Down Expand Up @@ -219,8 +217,8 @@ public Long call() throws Exception {
try {
checkInterrupted();
if (log.isLoggable(Level.INFO))
log.info(String.format(
"Running bulk delete on '%s/%s':%d", client.getContainerName(), prefix, timestamp));
log.info("Running bulk delete on '%s/%s':%d"
.formatted(client.getContainerName(), prefix, timestamp));

BlobContainerClient container = client.getContainer();

Expand All @@ -238,24 +236,21 @@ public Long call() throws Exception {
}
}
} catch (InterruptedException | IllegalStateException e) {
log.info(String.format(
"Azure bulk delete aborted for '%s/%s'. Will resume on next startup.",
client.getContainerName(), prefix));
log.info("Azure bulk delete aborted for '%s/%s'. Will resume on next startup."
.formatted(client.getContainerName(), prefix));
throw e;
} catch (RuntimeException e) {
log.log(
Level.WARNING,
String.format(
"Unknown error performing bulk Azure blobs delete of '%s/%s'",
client.getContainerName(), prefix),
"Unknown error performing bulk Azure blobs delete of '%s/%s'"
.formatted(client.getContainerName(), prefix),
e);
throw e;
}

if (log.isLoggable(Level.INFO))
log.info(String.format(
"Finished bulk delete on '%s/%s':%d. %d objects deleted",
client.getContainerName(), prefix, timestamp, count));
log.info("Finished bulk delete on '%s/%s':%d. %d objects deleted"
.formatted(client.getContainerName(), prefix, timestamp, count));

clearPendingBulkDelete(prefix, timestamp);
return count;
Expand Down Expand Up @@ -286,9 +281,8 @@ private void clearPendingBulkDelete(final String prefix, final long timestamp) t
if (timestamp >= storedTimestamp) {
client.putProperties(pendingDeletesKey, deletes);
} else if (log.isLoggable(Level.INFO)) {
log.info(String.format(
"bulk delete finished but there's a newer one ongoing for container '%s/%s'",
client.getContainerName(), prefix));
log.info("bulk delete finished but there's a newer one ongoing for container '%s/%s'"
.formatted(client.getContainerName(), prefix));
}
} catch (StorageException e) {
throw new UncheckedIOException(e);
Expand Down Expand Up @@ -329,9 +323,8 @@ public Long call() throws Exception {
try {
checkInterrupted();
if (log.isLoggable(Level.FINER)) {
log.finer(String.format(
"Running delete delete on list of items on '%s':%s ... (only the first 100 items listed)",
client.getContainerName(), keys.subList(0, Math.min(keys.size(), 100))));
log.finer("Running delete delete on list of items on '%s':%s ... (only the first 100 items listed)"
.formatted(client.getContainerName(), keys.subList(0, Math.min(keys.size(), 100))));
}

BlobContainerClient container = client.getContainer();
Expand All @@ -348,8 +341,7 @@ public Long call() throws Exception {
}

if (log.isLoggable(Level.INFO))
log.info(String.format(
"Finished bulk delete on %s, %d objects deleted", client.getContainerName(), count));
log.info("Finished bulk delete on %s, %d objects deleted".formatted(client.getContainerName(), count));
return count;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ private void seed(
int max = (int) Math.pow(2, z);
for (int x = 0; x < max; x++) {
for (int y = 0; y < max; y++) {
log.fine(String.format("seeding %d,%d,%d", x, y, z));
log.fine("seeding %d,%d,%d".formatted(x, y, z));
put(x, y, z, gridset, formatExtension, parameters);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package org.geowebcache.testcontainers.azure;

import static java.lang.String.format;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

Expand Down Expand Up @@ -145,7 +144,7 @@ public int getBlobsPort() {
}

public String getBlobServiceUrl() {
return format("http://localhost:%d/%s", getBlobsPort(), getAccountName());
return "http://localhost:%d/%s".formatted(getBlobsPort(), getAccountName());
}

public AzureBlobStoreData getConfiguration(String container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.geowebcache;

import java.io.IOException;
import java.io.Serial;

/**
* An IOException that means a {@link ServiceStrategy#getDestination(javax.servlet.http.HttpServletResponse)
Expand All @@ -28,6 +29,7 @@
*/
public final class ClientStreamAbortedException extends IOException {

@Serial
private static final long serialVersionUID = -812677957232110980L;

public ClientStreamAbortedException() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private boolean isClientStreamAbortedException(Throwable t) {
while (current != null
&& !(current instanceof ClientStreamAbortedException)
&& !(current instanceof HttpErrorCodeException)) {
if (current instanceof SAXException) current = ((SAXException) current).getException();
if (current instanceof SAXException exception) current = exception.getException();
else current = current.getCause();
}
if (current instanceof ClientStreamAbortedException) {
Expand Down Expand Up @@ -393,8 +393,8 @@ private void handleServiceRequest(String serviceStr, HttpServletRequest request,
if (!layer.isEnabled()) {
throw new OWSException(400, "InvalidParameterValue", "LAYERS", "Layer '" + layerName + "' is disabled");
}
if (conv instanceof ConveyorTile) {
((ConveyorTile) conv).setTileLayer(layer);
if (conv instanceof ConveyorTile tile) {
tile.setTileLayer(layer);
}
} else {
layer = null;
Expand Down Expand Up @@ -513,17 +513,17 @@ private void appendStorageLocations(StringBuilder str) {
str.append("<table class=\"stats\">\n");
str.append("<tbody>");
XMLConfiguration config;
if (mainConfiguration instanceof XMLConfiguration) {
config = (XMLConfiguration) mainConfiguration;
if (mainConfiguration instanceof XMLConfiguration configuration) {
config = configuration;
} else {
config = GeoWebCacheExtensions.bean(XMLConfiguration.class);
}
String configLoc;
String localStorageLoc;
// TODO: Disk Quota location
Map<String, String> blobStoreLocations = new HashMap<>();
if (storageBroker instanceof DefaultStorageBroker) {
BlobStore bStore = ((DefaultStorageBroker) storageBroker).getBlobStore();
if (storageBroker instanceof DefaultStorageBroker broker) {
BlobStore bStore = broker.getBlobStore();
if (bStore instanceof CompositeBlobStore) {
for (BlobStoreInfo bsConfig : blobStoreAggregator.getBlobStores()) {
blobStoreLocations.put(bsConfig.getName(), bsConfig.getLocation());
Expand Down Expand Up @@ -584,8 +584,8 @@ private void appendInternalCacheStats(StringBuilder strGlobal) {
LOG.fine("Searching for the blobstore used");
}
// Getting the BlobStore if present
if (storageBroker instanceof DefaultStorageBroker) {
blobStore = ((DefaultStorageBroker) storageBroker).getBlobStore();
if (storageBroker instanceof DefaultStorageBroker broker) {
blobStore = broker.getBlobStore();
}

// If it is not present, or it is not a memory blobstore, nothing is done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ protected String resolveStringValue(String strVal) throws BeansException {
*/
@SuppressWarnings("unchecked")
public <T> T resolveValue(T value) {
if (value instanceof String) {
return (T) resolveStringValue((String) value);
if (value instanceof String string) {
return (T) resolveStringValue(string);
}

return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
*/
package org.geowebcache;

import java.io.Serial;

public class GeoWebCacheException extends Exception {
/** */
@Serial
private static final long serialVersionUID = 5837933971679774371L;

public GeoWebCacheException(String msg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ public static void reinitialize(ApplicationContext context) {
try {
bean.deinitialize();
} catch (Exception e) {
if (bean instanceof BaseConfiguration) {
if (bean instanceof BaseConfiguration configuration) {
LOGGER.log(
Level.SEVERE,
"Error while preparing configuration to reinitialize "
+ ((BaseConfiguration) bean).getIdentifier()
+ configuration.getIdentifier()
+ " from "
+ ((BaseConfiguration) bean).getLocation(),
+ configuration.getLocation(),
e);
} else {
LOGGER.log(Level.SEVERE, "Error while preparing bean to reinitialize " + bean.toString(), e);
Expand All @@ -228,13 +228,13 @@ public static void reinitialize(ApplicationContext context) {
try {
bean.reinitialize();
} catch (Exception e) {
if (bean instanceof BaseConfiguration) {
if (bean instanceof BaseConfiguration configuration) {
LOGGER.log(
Level.SEVERE,
"Error while reinitializing configuration "
+ ((BaseConfiguration) bean).getIdentifier()
+ configuration.getIdentifier()
+ " from "
+ ((BaseConfiguration) bean).getLocation(),
+ configuration.getLocation(),
e);
} else {
LOGGER.log(Level.SEVERE, "Error while reinitializing bean " + bean.toString(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
*/
package org.geowebcache;

import java.io.Serial;
import java.util.Objects;

public class UncheckedGeoWebCacheException extends RuntimeException {

/** serialVersionUID */
@Serial
private static final long serialVersionUID = -7981050129260733945L;

public UncheckedGeoWebCacheException(GeoWebCacheException cause) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package org.geowebcache.config;

import java.io.Serial;
import java.io.Serializable;
import org.geowebcache.layer.TileLayerDispatcher;
import org.geowebcache.locks.LockProvider;
Expand All @@ -38,6 +39,7 @@
*/
public abstract class BlobStoreInfo implements Serializable, Cloneable, Info {

@Serial
private static final long serialVersionUID = 1L;

private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package org.geowebcache.config;

import java.io.Serial;
import org.geowebcache.GeoWebCacheException;

/**
Expand All @@ -21,6 +22,7 @@
*/
public class ConfigurationException extends GeoWebCacheException {

@Serial
private static final long serialVersionUID = 1613753249919539845L;

public ConfigurationException(String msg) {
Expand Down
Loading
Loading