Skip to content

Commit

Permalink
Revert "Add new method isEnabled to ConfigSourceInterceptor (#1311)" (#…
Browse files Browse the repository at this point in the history
…1316)

This reverts commit fc77388.
  • Loading branch information
radcortez authored Feb 15, 2025
1 parent 2bff603 commit 1b4cd3e
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ public abstract class AbstractMappingConfigSourceInterceptor implements ConfigSo
private static final long serialVersionUID = -3181156290079915301L;

private final Function<String, String> mapping;
private final boolean enabled;

public AbstractMappingConfigSourceInterceptor(final Function<String, String> mapping) {
this(mapping, true);
this.mapping = mapping != null ? mapping : Function.identity();
}

public AbstractMappingConfigSourceInterceptor(final Map<String, String> mappings) {
Expand All @@ -20,12 +19,7 @@ public AbstractMappingConfigSourceInterceptor(final Map<String, String> mappings
public String apply(final String name) {
return mappings.getOrDefault(name, name);
}
}, !mappings.isEmpty());
}

AbstractMappingConfigSourceInterceptor(final Function<String, String> mapping, boolean enabled) {
this.mapping = mapping != null ? mapping : Function.identity();
this.enabled = enabled;
});
}

@Override
Expand Down Expand Up @@ -56,11 +50,6 @@ public String next() {
};
}

@Override
public boolean isEnabled() {
return enabled;
}

protected Function<String, String> getMapping() {
return mapping;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ default Iterator<String> iterateNames(ConfigSourceInterceptorContext context) {
return context.iterateNames();
}

/**
* If the interceptor is enabled or disabled. If the interceptor is disabled, it will be removed from the final
* interceptor chain. The interceptor is still used and evaluated during the intermediate steps when assembling
* the configuration. For instance, an interceptor marked as disabled is still evaluated when calling the chain in
* {@link ConfigSourceFactory}, since late configuration may reenable or disable the current interceptor.
*
* @return <code>true</code> if the interceptor is enabld or <code>false</code> otherwise
*/
default boolean isEnabled() {
return true;
}

ConfigSourceInterceptor EMPTY = new ConfigSourceInterceptor() {
private static final long serialVersionUID = 5749001327530543433L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,4 @@ public Iterator<String> iterateNames() {
}
return handler;
}

@Override
public boolean isEnabled() {
return enabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,4 @@ public ConfigValue getValue(final ConfigSourceInterceptorContext context, final
}
return secret;
}

@Override
public boolean isEnabled() {
return enabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,4 @@ public Iterator<String> iterateNames(final ConfigSourceInterceptorContext contex
}
return context.iterateNames();
}

@Override
public boolean isEnabled() {
return !secrets.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -894,16 +894,12 @@ private static class ConfigSources implements Serializable {
current = new SmallRyeConfigSourceInterceptorContext(new SmallRyeConfigSources(sourcesWithPriorities, true),
current, chain);
for (ConfigSourceInterceptor interceptor : negativeInterceptors) {
if (interceptor.isEnabled()) {
current = new SmallRyeConfigSourceInterceptorContext(interceptor, current, chain);
}
current = new SmallRyeConfigSourceInterceptorContext(interceptor, current, chain);
}
current = new SmallRyeConfigSourceInterceptorContext(new SmallRyeConfigSources(sourcesWithPriorities, false),
current, chain);
for (ConfigSourceInterceptor interceptor : positiveInterceptors) {
if (interceptor.isEnabled()) {
current = new SmallRyeConfigSourceInterceptorContext(interceptor, current, chain);
}
current = new SmallRyeConfigSourceInterceptorContext(interceptor, current, chain);
}

this.profiles = profiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public OptionalInt getPriority() {
return OptionalInt.of(Priorities.LIBRARY + 200 - 1);
}

private static class MultipleProfileProperty implements Comparable<MultipleProfileProperty> {
class MultipleProfileProperty implements Comparable<MultipleProfileProperty> {
private final String name;
private final String relocateName;
private final List<String> profiles;
Expand Down

0 comments on commit 1b4cd3e

Please sign in to comment.