Skip to content

Commit

Permalink
Merge pull request #589 from groldan/sonarcloud_qa
Browse files Browse the repository at this point in the history
Sonarcloud qa suggested fixes
  • Loading branch information
groldan authored Jan 9, 2025
2 parents 0dc4500 + 9bb24fc commit e4536d2
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void setUpDataDir(DynamicPropertyRegistry registry) throws IOException {
}

@BeforeEach
void before() throws Exception {
void before() {
restTemplate = restTemplate.withBasicAuth("admin", "geoserver");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.nio.file.Path;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
Expand All @@ -26,7 +25,7 @@ class WcsApplicationTest {
static @TempDir Path datadir;

@DynamicPropertySource
static void setUpDataDir(DynamicPropertyRegistry registry) throws IOException {
static void setUpDataDir(DynamicPropertyRegistry registry) {
registry.add("geoserver.backend.data-directory.location", datadir::toAbsolutePath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.geoserver.cloud.wfs.app;

import java.io.IOException;
import java.nio.file.Path;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -20,7 +19,7 @@ class WfsApplicationDataDirectoryIT extends WfsApplicationTest {
static @TempDir Path datadir;

@DynamicPropertySource
static void setUpDataDir(DynamicPropertyRegistry registry) throws IOException {
static void setUpDataDir(DynamicPropertyRegistry registry) {
registry.add("geoserver.backend.data-directory.location", datadir::toAbsolutePath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.geoserver.cloud.wms.app;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -29,7 +28,7 @@ class WmsApplicationDataDirectoryTest extends WmsApplicationTest {
static @TempDir Path datadir;

@DynamicPropertySource
static void setUpDataDir(DynamicPropertyRegistry registry) throws IOException {
static void setUpDataDir(DynamicPropertyRegistry registry) {
var gwcdir = datadir.resolve("gwc");
registry.add("geoserver.backend.data-directory.location", datadir::toAbsolutePath);
registry.add("gwc.cache-directory", gwcdir::toAbsolutePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.geoserver.cloud.wps;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;
import org.junit.jupiter.api.Test;
Expand All @@ -25,7 +24,7 @@ class WpsApplicationTest {
static @TempDir Path datadir;

@DynamicPropertySource
static void setUpDataDir(DynamicPropertyRegistry registry) throws IOException {
static void setUpDataDir(DynamicPropertyRegistry registry) {
var gwcdir = datadir.resolve("gwc");
registry.add("geoserver.backend.data-directory.location", datadir::toAbsolutePath);
registry.add("gwc.cache-directory", gwcdir::toAbsolutePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.geoserver.cloud.autoconfigure.catalog.backend.datadir;

import java.io.IOException;
import java.nio.file.Path;
import org.geoserver.cloud.config.catalog.backend.datadirectory.DataDirectoryBackendConfiguration;
import org.geoserver.cloud.config.catalog.backend.datadirectory.DataDirectoryUpdateSequence;
Expand Down Expand Up @@ -35,7 +34,7 @@ class DataDirectoryUpdateSequenceTest implements UpdateSequenceConformanceTest {
static @TempDir Path datadir;

@DynamicPropertySource
static void setUpDataDir(DynamicPropertyRegistry registry) throws IOException {
static void setUpDataDir(DynamicPropertyRegistry registry) {
registry.add("geoserver.backend.data-directory.location", datadir::toAbsolutePath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@
@ConditionalOnClass(GWCConverter.class)
@ComponentScan(
basePackages = "org.geowebcache.rest",
// exclude org.geowebcache.controller.SeedController from component scan, provide an alternative that works with
// spring cloud below
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = SeedController.class))
public class RESTConfigConfiguration {

/**
* Replacement for {@link SeedController#doPost(javax.servlet.http.HttpServletRequest, java.io.InputStream, String, java.util.Map)}
* working wit spring-boot's stricter path pattern matching
*/
@Bean
org.geoserver.cloud.gwc.config.services.SeedController seedController() {
return new org.geoserver.cloud.gwc.config.services.SeedController();
org.geoserver.cloud.gwc.config.services.SeedControllerOverride seedController() {
return new org.geoserver.cloud.gwc.config.services.SeedControllerOverride();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Component
@RestController
@RequestMapping(path = "${gwc.context.suffix:}/rest")
public class SeedController extends org.geowebcache.rest.controller.SeedController {
public class SeedControllerOverride extends org.geowebcache.rest.controller.SeedController {

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ Level getLogLevel(String uri) {
}

private boolean matches(String url, List<Pattern> patterns) {
return (patterns == null || patterns.isEmpty())
? false
: patterns.stream().anyMatch(pattern -> pattern.matcher(url).matches());
return patterns != null
&& !patterns.isEmpty()
&& patterns.stream().anyMatch(pattern -> pattern.matcher(url).matches());
}
}

0 comments on commit e4536d2

Please sign in to comment.