Skip to content

Commit

Permalink
Fix SpringEnvironmentAwareGeoToolsHttpClientFactory registration
Browse files Browse the repository at this point in the history
Fix SpringEnvironmentAwareGeoToolsHttpClientFactory registration
as the default `HTTPClient` factory using the `Class` object as value
instead of the qualified class name when doing
`Hints.putSystemDefault( Hints.HTTP_CLIENT_FACTORY, <factory>)`
in `GeoToolsStaticContextInitializer`.

It doesn't work with the class name after changes upstream.
  • Loading branch information
groldan committed May 3, 2024
1 parent 9f1cdad commit d11c75d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ public void initialize(ConfigurableApplicationContext applicationContext) {
}
System.setProperty("org.geotools.referencing.forceXY", "true");

Boolean useEnvAwareHttpClient =
boolean useEnvAwareHttpClient =
applicationContext
.getEnvironment()
.getProperty(
"geotools.httpclient.proxy.enabled", Boolean.class, Boolean.TRUE);
if (useEnvAwareHttpClient) {
// factoryName matches the one in
// src/main/resources/META-INF/services/org.geotools.http.HTTPClientFactory
String factoryName =
SpringEnvironmentAwareGeoToolsHttpClientFactory.class.getCanonicalName();
Hints.putSystemDefault(Hints.HTTP_CLIENT_FACTORY, factoryName);
Hints.putSystemDefault(
Hints.HTTP_CLIENT_FACTORY,
SpringEnvironmentAwareGeoToolsHttpClientFactory.class);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ void testInitializerSetsForceXYSystemProperty() {

@Test
void testInitializerSetsHttpClientFactorySystemProperty() {
final String expected =
SpringEnvironmentAwareGeoToolsHttpClientFactory.class.getCanonicalName();
final var expected = SpringEnvironmentAwareGeoToolsHttpClientFactory.class;

assertNull(Hints.getSystemDefault(Hints.HTTP_CLIENT_FACTORY));
runner.run(
Expand Down

0 comments on commit d11c75d

Please sign in to comment.