Skip to content

Commit

Permalink
Switch swallow to ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
akang31 committed Feb 14, 2025
1 parent 706e85e commit e29ebc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected interface PropertyValueGetter<T> {
*/
T invoke(Object[] args);

default T invokeSwallowErrors(Object[] args) {
default T invokeIgnoreErrors(Object[] args) {
return invoke(args);
}
}
Expand Down Expand Up @@ -501,10 +501,10 @@ public T invoke(Object[] args) {

@SuppressWarnings({"unchecked"})
@Override
public T invokeSwallowErrors(Object[] args) {
public T invokeIgnoreErrors(Object[] args) {
T value;
if (prop instanceof DefaultPropertyFactory.ErrorSwallowingProperty) {
value = ((DefaultPropertyFactory.ErrorSwallowingProperty<T>) prop).getSwallowErrors();
if (prop instanceof DefaultPropertyFactory.ErrorIgnoringProperty) {
value = ((DefaultPropertyFactory.ErrorIgnoringProperty<T>) prop).getIgnoreErrors();
} else {
value = prop.get();
}
Expand Down Expand Up @@ -630,7 +630,7 @@ private String toNameAndValue(Map.Entry<Method, PropertyValueGetter<?>> entry) {
try {
// This call should fail for parameterized properties, because the PropertyValueGetter has a non-empty
// argument list. Fortunately, the implementation there cooperates with us and returns a null instead :-)
propertyValue = entry.getValue().invokeSwallowErrors(null);
propertyValue = entry.getValue().invokeIgnoreErrors(null);
} catch (Exception e) {
// Just in case
propertyValue = e.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ private <T> Property<T> getFromSupplier(KeyAndType<T> keyAndType, Supplier<T> su
return (Property<T>) properties.computeIfAbsent(keyAndType, (ignore) -> new PropertyImpl<>(keyAndType, supplier));
}

interface ErrorSwallowingProperty<T> {
T getSwallowErrors();
interface ErrorIgnoringProperty<T> {
T getIgnoreErrors();
}

/**
* Implementation of the Property interface. This class looks at the factory's masterVersion on each read to
* determine if the cached parsed values is stale.
*/
private final class PropertyImpl<T> implements Property<T>, ErrorSwallowingProperty<T> {
private final class PropertyImpl<T> implements Property<T>, ErrorIgnoringProperty<T> {

private final KeyAndType<T> keyAndType;
private final Supplier<T> supplier;
Expand Down Expand Up @@ -177,11 +177,11 @@ public T get() {
}

@Override
public T getSwallowErrors() {
public T getIgnoreErrors() {
return internalGet(true);
}

private T internalGet(boolean swallowErrors) {
private T internalGet(boolean ignoreErrors) {
int currentMasterVersion = masterVersion.get();
CachedValue<T> currentCachedValue = this.cachedValue;

Expand All @@ -205,7 +205,7 @@ private T internalGet(boolean swallowErrors) {
newValue = new CachedValue<>(supplier.get(), currentMasterVersion);

} catch (RuntimeException e) {
if (!swallowErrors) {
if (!ignoreErrors) {
// Oh, no, something went wrong while trying to get the new value. Log the error and return null.
// Upstream users may return that null unchanged or substitute it by a defaultValue.
// We leave the cache unchanged, which means the next caller will try again.
Expand Down

0 comments on commit e29ebc9

Please sign in to comment.