Skip to content

Commit

Permalink
Merge branch '2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmarion committed Jul 23, 2024
2 parents bab64ca + e97f588 commit 49e1b5c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ public T derive() {
if (rc == null || rc.count != uc) {
T newObj = converter.apply(AccumuloConfiguration.this);

if (newObj == null) {
// The converter should not return a null value and the Deriver
// should not store and return a null value.
throw new IllegalStateException("Deriver returned a null value");
}

// very important to record the update count that was obtained before recomputing.
RefCount<T> nrc = new RefCount<>(uc, newObj);

Expand Down Expand Up @@ -507,6 +513,7 @@ public interface Deriver<T> {
* this function will be kept and called by the returned deriver.
* @return The returned supplier will automatically re-derive the object any time this
* configuration changes. When configuration is not changing, the same object is returned.
* @throws IllegalStateException When a null return value is returned by the converter.
*
*/
public <T> Deriver<T> newDeriver(Function<AccumuloConfiguration,T> converter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ public static <T> T getClassInstance(String context, String clazzName, Class<T>
log.error("Failed to load class {} in classloader context {}", clazzName, context, e);
}

if (instance == null && defaultInstance != null) {
log.info("Using default class {}", defaultInstance.getClass().getName());
if (instance == null) {
log.info("Using default class ({})",
defaultInstance == null ? null : defaultInstance.getClass().getName());
instance = defaultInstance;
}
return instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Objects;
import java.util.function.Predicate;

import org.apache.accumulo.core.classloader.ClassLoaderUtil;
Expand Down Expand Up @@ -1609,6 +1610,9 @@ public static boolean isClassProperty(String key) {
*/
public static <T> T createTableInstanceFromPropertyName(AccumuloConfiguration conf,
Property property, Class<T> base, T defaultInstance) {
Objects.requireNonNull(conf, "configuration cannot be null");
Objects.requireNonNull(property, "property cannot be null");
Objects.requireNonNull(base, "base class cannot be null");
String clazzName = conf.get(property);
String context = ClassLoaderUtil.tableContext(conf);
return ConfigurationTypeHelper.getClassInstance(context, clazzName, base, defaultInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.stream.Collectors;

import org.apache.accumulo.core.classloader.ClassLoaderUtil;
Expand Down Expand Up @@ -145,6 +146,8 @@ private static ScanDispatcher createScanDispatcher(AccumuloConfiguration conf,
ServerContext context, TableId tableId) {
ScanDispatcher newDispatcher = Property.createTableInstanceFromPropertyName(conf,
Property.TABLE_SCAN_DISPATCHER, ScanDispatcher.class, null);
Objects.requireNonNull(newDispatcher, "Class specified in property "
+ Property.TABLE_SCAN_DISPATCHER.getKey() + " was not returned.");

Map<String,String> opts =
conf.getAllPropertiesWithPrefixStripped(Property.TABLE_SCAN_DISPATCHER_OPTS);
Expand Down Expand Up @@ -177,14 +180,8 @@ private static CompactionDispatcher createCompactionDispatcher(AccumuloConfigura

CompactionDispatcher newDispatcher = Property.createTableInstanceFromPropertyName(conf,
Property.TABLE_COMPACTION_DISPATCHER, CompactionDispatcher.class, null);

if (newDispatcher == null) {
// return early to prevent NPE
log.error(
"Null returned for compaction dispatcher for table: {}. Did not return default value, check server log.",
tableId);
return null;
}
Objects.requireNonNull(newDispatcher, "Class specified in property "
+ Property.TABLE_COMPACTION_DISPATCHER.getKey() + " was not returned.");

Map<String,String> opts =
conf.getAllPropertiesWithPrefixStripped(Property.TABLE_COMPACTION_DISPATCHER_OPTS);
Expand Down

0 comments on commit 49e1b5c

Please sign in to comment.