Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.security.AccessController;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand All @@ -55,7 +55,6 @@
import org.apache.parquet.avro.AvroReadSupport;
import org.apache.parquet.cli.json.AvroJsonReader;
import org.apache.parquet.cli.util.Formats;
import org.apache.parquet.cli.util.GetClassLoader;
import org.apache.parquet.cli.util.Schemas;
import org.apache.parquet.cli.util.SeekableFSDataInputStream;
import org.apache.parquet.crypto.DecryptionKeyRetriever;
Expand Down Expand Up @@ -313,7 +312,7 @@ private Configuration createDefaultConf() {
* @throws MalformedURLException if a jar or path is invalid
*/
protected static ClassLoader loaderFor(List<String> jars, List<String> paths) throws MalformedURLException {
return AccessController.doPrivileged(new GetClassLoader(urls(jars, paths)));
return newClassLoader(urls(jars, paths));
}

/**
Expand All @@ -324,7 +323,7 @@ protected static ClassLoader loaderFor(List<String> jars, List<String> paths) th
* @throws MalformedURLException if a URL is invalid
*/
protected static ClassLoader loaderForJars(List<String> jars) throws MalformedURLException {
return AccessController.doPrivileged(new GetClassLoader(urls(jars, null)));
return newClassLoader(urls(jars, null));
}

/**
Expand All @@ -335,7 +334,12 @@ protected static ClassLoader loaderForJars(List<String> jars) throws MalformedUR
* @throws MalformedURLException if a path is invalid
*/
protected static ClassLoader loaderForPaths(List<String> paths) throws MalformedURLException {
return AccessController.doPrivileged(new GetClassLoader(urls(null, paths)));
return newClassLoader(urls(null, paths));
}

private static ClassLoader newClassLoader(List<URL> urls) {
return new URLClassLoader(
urls.toArray(new URL[0]), Thread.currentThread().getContextClassLoader());
}

private static List<URL> urls(List<String> jars, List<String> dirs) throws MalformedURLException {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
import static org.apache.parquet.Exceptions.throwIfInstance;

import java.lang.reflect.Constructor;
import java.lang.reflect.InaccessibleObjectException;
import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.Map;
import org.apache.parquet.Preconditions;
Expand Down Expand Up @@ -184,9 +183,9 @@ public <T> Builder hiddenImpl(Class<T> targetClass, Class<?>... types) {

try {
Constructor<T> hidden = targetClass.getDeclaredConstructor(types);
AccessController.doPrivileged(new MakeAccessible(hidden));
hidden.setAccessible(true);
ctor = new Ctor<T>(hidden, targetClass);
} catch (NoSuchMethodException | SecurityException e) {
} catch (NoSuchMethodException | SecurityException | InaccessibleObjectException e) {
// unusable or not the right implementation
problems.put(methodName(targetClass, types), e);
}
Expand All @@ -211,20 +210,6 @@ public <C> Ctor<C> build() {
}
}

private static class MakeAccessible implements PrivilegedAction<Void> {
private Constructor<?> hidden;

public MakeAccessible(Constructor<?> hidden) {
this.hidden = hidden;
}

@Override
public Void run() {
hidden.setAccessible(true);
return null;
}
}

private static String formatProblems(Map<String, Throwable> problems) {
StringBuilder sb = new StringBuilder();
boolean first = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@

import static org.apache.parquet.Exceptions.throwIfInstance;

import java.lang.reflect.InaccessibleObjectException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import org.apache.parquet.Preconditions;
import org.slf4j.Logger;
Expand Down Expand Up @@ -389,9 +388,9 @@ public Builder hiddenImpl(Class<?> targetClass, String methodName, Class<?>... a

try {
Method hidden = targetClass.getDeclaredMethod(methodName, argClasses);
AccessController.doPrivileged(new MakeAccessible(hidden));
hidden.setAccessible(true);
this.method = new UnboundMethod(hidden, name);
} catch (SecurityException | NoSuchMethodException e) {
} catch (SecurityException | InaccessibleObjectException | NoSuchMethodException e) {
// unusable or not the right implementation
LOG.debug("failed to load method {} from class {}", methodName, targetClass, e);
}
Expand Down Expand Up @@ -494,18 +493,4 @@ public StaticMethod buildStatic() {
return build().asStatic();
}
}

private static class MakeAccessible implements PrivilegedAction<Void> {
private Method hidden;

public MakeAccessible(Method hidden) {
this.hidden = hidden;
}

@Override
public Void run() {
hidden.setAccessible(true);
return null;
}
}
}
Loading