public static DynamicClassLoader getClassLoader(final PName tenantId, final String jarPath) { DynamicClassLoader cl = tenantIdSpecificCls.get(tenantId); Path parent = null; if (cl != null) return cl; if(jarPath != null && !jarPath.isEmpty()) { cl = pathSpecificCls.get(jarPath); if (cl != null) return cl; parent = getPathForParent(jarPath); } // Parse the DYNAMIC_JARS_DIR_KEY value as a Path if it's present in the configuration Path allowedDynamicJarsPath = config.get(DYNAMIC_JARS_DIR_KEY) != null ? new Path(config.get(DYNAMIC_JARS_DIR_KEY)) : null; // The case jarPath is not provided, or it is provided and the jar is inside hbase.dynamic.jars.dir if (jarPath == null || jarPath.isEmpty() || (allowedDynamicJarsPath != null && parent != null && parent.equals(allowedDynamicJarsPath))) { cl = tenantIdSpecificCls.get(tenantId); if (cl == null) { cl = new DynamicClassLoader(config, UDFExpression.class.getClassLoader()); } // Cache class loader as a weak value, will be GC'ed when no reference left DynamicClassLoader prev = tenantIdSpecificCls.putIfAbsent(tenantId, cl); if (prev != null) { cl = prev; } return cl; } else { //The case jarPath is provided as not part of DYNAMIC_JARS_DIR_KEY //As per PHOENIX-4231, DYNAMIC_JARS_DIR_KEY is the only place where loading a udf jar is allowed throw new SecurityException("Loading jars from " + jarPath + " is not allowed. The only location that is allowed is "+ config.get(DYNAMIC_JARS_DIR_KEY)); } }
public static DynamicClassLoader getClassLoader(final PName tenantId, final String jarPath) { DynamicClassLoader cl = tenantIdSpecificCls.get(tenantId); Path parent = null; if (cl != null) return cl; if(jarPath != null && !jarPath.isEmpty()) { cl = pathSpecificCls.get(jarPath); if (cl != null) return cl; parent = getPathForParent(jarPath); } // Parse the DYNAMIC_JARS_DIR_KEY value as a Path if it's present in the configuration Path allowedDynamicJarsPath = config.get(DYNAMIC_JARS_DIR_KEY) != null ? new Path(config.get(DYNAMIC_JARS_DIR_KEY)) : null; // The case jarPath is not provided, or it is provided and the jar is inside hbase.dynamic.jars.dir if (jarPath == null || jarPath.isEmpty() || (allowedDynamicJarsPath != null && parent != null && parent.equals(allowedDynamicJarsPath))) { cl = tenantIdSpecificCls.get(tenantId); if (cl == null) { cl = new DynamicClassLoader(config, UDFExpression.class.getClassLoader()); } // Cache class loader as a weak value, will be GC'ed when no reference left DynamicClassLoader prev = tenantIdSpecificCls.putIfAbsent(tenantId, cl); if (prev != null) { cl = prev; } return cl; } else { //The case jarPath is provided as not part of DYNAMIC_JARS_DIR_KEY //As per PHOENIX-4231, DYNAMIC_JARS_DIR_KEY is the only place where loading a udf jar is allowed throw new SecurityException("Loading jars from " + jarPath + " is not allowed. The only location that is allowed is "+ config.get(DYNAMIC_JARS_DIR_KEY)); } }
public static DynamicClassLoader getClassLoader(final PName tenantId, final String jarPath) { DynamicClassLoader cl = tenantIdSpecificCls.get(tenantId); Path parent = null; if (cl != null) return cl; if(jarPath != null && !jarPath.isEmpty()) { cl = pathSpecificCls.get(jarPath); if (cl != null) return cl; parent = getPathForParent(jarPath); } // Parse the DYNAMIC_JARS_DIR_KEY value as a Path if it's present in the configuration Path allowedDynamicJarsPath = config.get(DYNAMIC_JARS_DIR_KEY) != null ? new Path(config.get(DYNAMIC_JARS_DIR_KEY)) : null; // The case jarPath is not provided, or it is provided and the jar is inside hbase.dynamic.jars.dir if (jarPath == null || jarPath.isEmpty() || (allowedDynamicJarsPath != null && parent != null && parent.equals(allowedDynamicJarsPath))) { cl = tenantIdSpecificCls.get(tenantId); if (cl == null) { cl = new DynamicClassLoader(config, UDFExpression.class.getClassLoader()); } // Cache class loader as a weak value, will be GC'ed when no reference left DynamicClassLoader prev = tenantIdSpecificCls.putIfAbsent(tenantId, cl); if (prev != null) { cl = prev; } return cl; } else { //The case jarPath is provided as not part of DYNAMIC_JARS_DIR_KEY //As per PHOENIX-4231, DYNAMIC_JARS_DIR_KEY is the only place where loading a udf jar is allowed throw new SecurityException("Loading jars from " + jarPath + " is not allowed. The only location that is allowed is "+ config.get(DYNAMIC_JARS_DIR_KEY)); } }