Last active
May 25, 2017 04:38
-
-
Save tjcelaya/df63bfe932afff07de4f501d6daff241 to your computer and use it in GitHub Desktop.
ConfigContexts Lacking defaults for `noAuth` and `disableNativeSignatures`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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