Search in sources :

Example 1 with KettleVFS

use of org.pentaho.di.core.vfs.KettleVFS in project pentaho-kettle by pentaho.

the class KettleEnvironmentIT method resetKettleEnvironmentInitializationFlag.

private void resetKettleEnvironmentInitializationFlag() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException {
    Field f = KettleEnvironment.class.getDeclaredField("initialized");
    f.setAccessible(true);
    f.set(null, new AtomicReference<SettableFuture<Boolean>>(null));
    Constructor<KettleVFS> constructor;
    constructor = KettleVFS.class.getDeclaredConstructor();
    constructor.setAccessible(true);
    KettleVFS KVFS = constructor.newInstance();
    f = KVFS.getClass().getDeclaredField("kettleVFS");
    f.setAccessible(true);
    Field modifiersField = Field.class.getDeclaredField("modifiers");
    modifiersField.setAccessible(true);
    modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL | Modifier.VOLATILE);
    f.set(null, KVFS);
    f = KVFS.getClass().getDeclaredField("defaultVariableSpace");
    f.setAccessible(true);
    modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
    Variables var = new Variables();
    var.initializeVariablesFrom(null);
    f.set(null, var);
}
Also used : SettableFuture(com.google.common.util.concurrent.SettableFuture) Variables(org.pentaho.di.core.variables.Variables) Field(java.lang.reflect.Field) KettleVFS(org.pentaho.di.core.vfs.KettleVFS)

Aggregations

SettableFuture (com.google.common.util.concurrent.SettableFuture)1 Field (java.lang.reflect.Field)1 Variables (org.pentaho.di.core.variables.Variables)1 KettleVFS (org.pentaho.di.core.vfs.KettleVFS)1