Skip to content

Commit

Permalink
adding null checks for classloaders (#1898)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfecher committed Jun 17, 2022
1 parent 06a40fb commit 998f3e4
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum Centroid implements ParameterEnum {
"A factory class that implements org.locationtech.geowave.analytics.tools.AnalyticItemWrapperFactory",
true, true),
ZOOM_LEVEL(Integer.class, "czl", "Zoom Level Number", true, true);

private final ParameterHelper helper;

private Centroid(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum Global implements ParameterEnum<Object> {
PARENT_BATCH_ID(String.class, "pb", "Batch ID", true),
CRS_ID(String.class, "crs", "CRS ID", true),
BATCH_ID(String.class, "b", "Batch ID", true);

private final ParameterHelper<Object> helper;

private Global(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum Output implements ParameterEnum<Object> {
DATA_NAMESPACE_URI(String.class, "ons",
"Output namespace for objects that will be written to GeoWave", false, true),
HDFS_OUTPUT_PATH(Path.class, "oop", "Output HDFS File Path", false, true);

private final ParameterHelper<Object> helper;

private Output(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public void testStore() throws Exception {
enum MyLocalBoolEnum implements ParameterEnum {
BOOLEAN_ARG1(Boolean.class, "mi", "test id", false),
BOOLEAN_ARG2(Boolean.class, "rd", "test id", false);

private final ParameterHelper<Object> helper;

MyLocalBoolEnum(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ private static boolean isUnbounded(final CoordinateSystemAxis csa) {

public static enum Bias {
TEMPORAL, BALANCED, SPATIAL;

// converter that will be used later
public static Bias fromString(final String code) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,28 @@ public final Set<ClassLoader> getClassLoaders() {
final Set<ClassLoader> loaders = new HashSet<>();

try {
loaders.add(SPIServiceRegistry.class.getClassLoader());
final ClassLoader cl = SPIServiceRegistry.class.getClassLoader();
if (cl != null) {
loaders.add(cl);
}
} catch (final SecurityException ex) {
LOGGER.warn("Unable to get the class loader", ex);
exceptions.add("SPIServiceRegistry's class loader : " + ex.getLocalizedMessage());
}
try {
loaders.add(ClassLoader.getSystemClassLoader());
final ClassLoader cl = ClassLoader.getSystemClassLoader();
if (cl != null) {
loaders.add(cl);
}
} catch (final SecurityException ex) {
LOGGER.warn("Unable to get the system class loader", ex);
exceptions.add("System class loader : " + ex.getLocalizedMessage());
}
try {
loaders.add(Thread.currentThread().getContextClassLoader());
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl != null) {
loaders.add(cl);
}
} catch (final SecurityException ex) {
LOGGER.warn("Unable to get the context class loader", ex);
exceptions.add("Thread's class loader : " + ex.getLocalizedMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected static enum ConfigParameter {
EQUALIZE_HISTOGRAM("equalizeHistogramOverride"),
AUTHORIZATION_PROVIDER("authorizationProvider"),
AUTHORIZATION_URL("authorizationUrl");

private String configName;

private ConfigParameter(final String configName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public T handleError(final Response response, final String errorMessage) throws
throw new ForbiddenException(errorMessage);
case 404:
throw new TargetNotFoundException(errorMessage);
// GeoServer responses for 500 codes are poorly formatted so
// don't return that response
// GeoServer responses for 500 codes are poorly formatted so
// don't return that response
case 500:
throw new Exception("Internal Server Error\n GeoServer Response Code = 500");
default:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.8.1</version>
<version>2.11.0</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static enum Environment {
KAFKA(KafkaTestEnvironment.getInstance()),
SERVICES(ServicesTestEnvironment.getInstance()),
SPARK(SparkTestEnvironment.getInstance());

private final TestEnvironment testEnvironment;

private Environment(final TestEnvironment testEnvironment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static enum GeoWaveStoreType {
REDIS(RedisStoreTestEnvironment.getInstance()),
ROCKSDB(RocksDBStoreTestEnvironment.getInstance()),
FILESYSTEM(FileSystemStoreTestEnvironment.getInstance());

private final StoreTestEnvironment testEnvironment;

private GeoWaveStoreType(final StoreTestEnvironment testEnvironment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class GeoWaveCustomIndexIT {

private static enum TestEnum {
A(i -> (i % 2) == 0), B(i -> (i % 3) == 0), C(i -> (i % 5) == 0), NOT_A(i -> (i + 1) % 2 == 0);

private final IntPredicate ingestLogic;

private TestEnum(final IntPredicate ingestLogic) {
Expand Down

0 comments on commit 998f3e4

Please sign in to comment.