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

fix(iot-dev): fix bug where client options was overridden #1749

Merged
merged 4 commits into from
Oct 18, 2023
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 @@ -13,7 +13,7 @@
/**
* Options that allow configuration of the device client instance during initialization.
*/
@Builder
@Builder(toBuilder = true)
public final class ClientOptions
{
private static final int DEFAULT_HTTPS_CONNECT_TIMEOUT_MILLISECONDS = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,15 @@ public static ModuleClient createFromEnvironment(UnixDomainSocketChannel unixDom
sslContext = new IotHubSSLContext().getSSLContext();
}

if (clientOptions == null || clientOptions.getSslContext() == null)
if (clientOptions != null && clientOptions.getSslContext() == null)
{
// only override the SSLContext if the user didn't set it
// Clone the existing client options, but with the new SSLContext
timtay-microsoft marked this conversation as resolved.
Show resolved Hide resolved
clientOptions = clientOptions.toBuilder().sslContext(sslContext)
.build();
}
else if (clientOptions == null)
{
// only override the client options completely if the user didn't provide any
clientOptions = ClientOptions.builder().sslContext(sslContext).build();
}
else
Expand Down
Loading