Skip to content

Instantly share code, notes, and snippets.

@tjcelaya
Last active May 25, 2017 04:38
Show Gist options
  • Save tjcelaya/df63bfe932afff07de4f501d6daff241 to your computer and use it in GitHub Desktop.
Save tjcelaya/df63bfe932afff07de4f501d6daff241 to your computer and use it in GitHub Desktop.
ConfigContexts Lacking defaults for `noAuth` and `disableNativeSignatures`
package co.tjcelaya.sandbox;
import com.joyent.manta.config.*;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class App {
public static void main(String[] args)
throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
System.out.println("\n >>>> app boot\n");
// cc = new ConfigContext();
// bccc = new BaseChainedConfigContex
ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
classes.add(MapConfigContext.class);
classes.add(EnvVarConfigContext.class);
classes.add(StandardConfigContext.class);
classes.add(ChainedConfigContext.class);
classes.add(DefaultsConfigContext.class);
classes.add(SystemSettingsConfigContext.class);
for (Class klazz : classes) {
ConfigContext cc;
if (klazz == MapConfigContext.class) {
cc = (ConfigContext) (klazz.getConstructor(Map.class))
.newInstance(new HashMap<String, String>());
} else if (klazz == ChainedConfigContext.class) {
cc = (ConfigContext) (klazz.getDeclaredConstructor(ConfigContext[].class))
.newInstance((Object) new ConfigContext[] {});
} else {
cc = (ConfigContext) klazz.newInstance();
}
try {
if (cc.noAuth()) {}
System.out.println("noAuth " + klazz.getSimpleName() + " ok");
} catch (NullPointerException npe) {
System.out.println("noAuth " + klazz.getSimpleName() + " throws");
}
try {
if (cc.disableNativeSignatures()) {}
System.out.println("disableNativeSignatures " + klazz.getSimpleName() + " ok");
} catch (NullPointerException npe) {
System.out.println("disableNativeSignatures " + klazz.getSimpleName() + " throws");
}
}
System.out.println("\n <<<< app terminate\n");
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment