Merge pull request #742 from mposolda/master
Simplify method signature in JsonSerialization
This commit is contained in:
commit
87f826c850
3 changed files with 9 additions and 6 deletions
|
@ -47,11 +47,15 @@ public class JsonSerialization {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T readValue(InputStream bytes, Class<T> type) throws IOException {
|
public static <T> T readValue(InputStream bytes, Class<T> type) throws IOException {
|
||||||
return mapper.readValue(bytes, type);
|
return readValue(bytes, type, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T readValueAndReplaceSysProperties(InputStream bytes, Class<T> type) throws IOException {
|
public static <T> T readValue(InputStream bytes, Class<T> type, boolean replaceSystemProperties) throws IOException {
|
||||||
return sysPropertiesAwareMapper.readValue(bytes, type);
|
if (replaceSystemProperties) {
|
||||||
|
return sysPropertiesAwareMapper.readValue(bytes, type);
|
||||||
|
} else {
|
||||||
|
return mapper.readValue(bytes, type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class JsonParserTest {
|
||||||
|
|
||||||
InputStream is = getClass().getClassLoader().getResourceAsStream("keycloak.json");
|
InputStream is = getClass().getClassLoader().getResourceAsStream("keycloak.json");
|
||||||
|
|
||||||
AdapterConfig config = JsonSerialization.readValueAndReplaceSysProperties(is, AdapterConfig.class);
|
AdapterConfig config = JsonSerialization.readValue(is, AdapterConfig.class, true);
|
||||||
Assert.assertEquals("http://foo:8080/auth", config.getAuthServerUrl());
|
Assert.assertEquals("http://foo:8080/auth", config.getAuthServerUrl());
|
||||||
Assert.assertEquals("external", config.getSslRequired());
|
Assert.assertEquals("external", config.getSslRequired());
|
||||||
Assert.assertEquals("angular-product${non.existing}", config.getResource());
|
Assert.assertEquals("angular-product${non.existing}", config.getResource());
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.keycloak.enums.RelativeUrlsUsed;
|
||||||
import org.keycloak.representations.adapters.config.AdapterConfig;
|
import org.keycloak.representations.adapters.config.AdapterConfig;
|
||||||
import org.keycloak.util.JsonSerialization;
|
import org.keycloak.util.JsonSerialization;
|
||||||
import org.keycloak.util.KeycloakUriBuilder;
|
import org.keycloak.util.KeycloakUriBuilder;
|
||||||
import org.keycloak.util.UriUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -25,7 +24,7 @@ public class ServletOAuthClientBuilder {
|
||||||
|
|
||||||
public static AdapterConfig getAdapterConfig(InputStream is) {
|
public static AdapterConfig getAdapterConfig(InputStream is) {
|
||||||
try {
|
try {
|
||||||
return JsonSerialization.readValueAndReplaceSysProperties(is, AdapterConfig.class);
|
return JsonSerialization.readValue(is, AdapterConfig.class, true);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue