Skip to content

Commit

Permalink
Resolve TritonDataCenter#247. Handle potentially-NPE-inducing configu…
Browse files Browse the repository at this point in the history
…ration params that have documented defaults
  • Loading branch information
tjcelaya committed Aug 17, 2017
1 parent 0f31eaa commit 52896da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.http.HttpEntity;
Expand Down Expand Up @@ -205,7 +206,7 @@ public MantaClient(final ConfigContext config) {
final KeyPair keyPair = keyPairFactory.createKeyPair();

final Signer.Builder builder = new Signer.Builder(keyPair);
if (config.disableNativeSignatures()) {
if (ObjectUtils.firstNonNull(config.disableNativeSignatures(), false)) {
builder.providerCode("stdlib");
}
final ThreadLocalSigner signer = new ThreadLocalSigner(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public byte[] getEncryptionPrivateKeyBytes() {
public void overwriteWithContext(final ConfigContext context) {
/* If a default context is being used to overwrite after this
* context has been initialized, then we want to be careful to not
* overwrite values that have already been set with defaults. */
* overwrite values that have already been set by non-default contexts. */
boolean isDefaultContext = context instanceof DefaultsConfigContext;

if (isDefaultContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.management.DynamicMBean;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.io.Closeable;
import java.io.IOException;
import java.lang.management.ManagementFactory;
Expand All @@ -78,6 +74,10 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import javax.management.DynamicMBean;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;

/**
* Factory class that creates instances of
Expand Down Expand Up @@ -160,15 +160,10 @@ public MantaConnectionFactory(final ConfigContext config,

// Setup configurator helper

final boolean useNativeCodeToSign;

useNativeCodeToSign = config.disableNativeSignatures() == null
|| !config.disableNativeSignatures();

final HttpSignatureAuthScheme authScheme;

// If we have auth disabled, then we don't assign any signer classes
if (config.noAuth()) {
if (ObjectUtils.firstNonNull(config.noAuth(), false)) {
this.signatureConfigurator = null;
authScheme = null;
this.signerThreadLocalRef = new WeakReference<>(null);
Expand Down

0 comments on commit 52896da

Please sign in to comment.