Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for azure appconfiguration enforcing final fields #5007

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 @@ -83,7 +83,7 @@ public final class ConfigurationClientBuilder {
private HttpClient httpClient;
private HttpLogDetailLevel httpLogDetailLevel;
private HttpPipeline pipeline;
private RetryPolicy retryPolicy;
private final RetryPolicy retryPolicy;
private Configuration configuration;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ private static class CredentialInformation {
private static final String ID = "id=";
private static final String SECRET = "secret=";

private URL baseUri;
private String id;
private byte[] secret;
private final URL baseUri;
private final String id;
private final byte[] secret;

URL baseUri() {
return baseUri;
Expand All @@ -175,24 +175,32 @@ byte[] secret() {
throw new IllegalArgumentException("invalid connection string segment count");
}

URL baseUri = null;
String id = null;
byte[] secret = null;

for (String arg : args) {
String segment = arg.trim();
String lowerCase = segment.toLowerCase(Locale.US);

if (lowerCase.startsWith(ENDPOINT)) {
try {
this.baseUri = new URL(segment.substring(ENDPOINT.length()));
baseUri = new URL(segment.substring(ENDPOINT.length()));
} catch (MalformedURLException ex) {
throw new IllegalArgumentException(ex);
}
} else if (lowerCase.startsWith(ID)) {
this.id = segment.substring(ID.length());
id = segment.substring(ID.length());
} else if (lowerCase.startsWith(SECRET)) {
String secretBase64 = segment.substring(SECRET.length());
this.secret = Base64.getDecoder().decode(secretBase64);
secret = Base64.getDecoder().decode(secretBase64);
}
}

this.baseUri = baseUri;
this.id = id;
this.secret = secret;

if (this.baseUri == null || this.id == null || this.secret == null) {
throw new IllegalArgumentException("Could not parse 'connectionString'."
+ " Expected format: 'endpoint={endpoint};id={id};secret={secret}'. Actual:" + connectionString);
Expand Down