Skip to content

Commit aff317e

Browse files
committed
Fixed a reverse logic check in a validation (apache#3086)
1 parent 4d60384 commit aff317e

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,10 @@ private AppenderRef getAppenderRef(final List<AppenderRef> appenderRefList, fina
246246
private void runTest(final LoggerContextRule rule, final Statement statement) {
247247
try {
248248
rule.apply(
249-
statement,
250-
Description.createTestDescription(
251-
getClass(),
252-
Thread.currentThread().getStackTrace()[1].getMethodName()))
253-
.evaluate();
249+
statement,
250+
Description.createTestDescription(getClass(),
251+
Thread.currentThread().getStackTrace()[1].getMethodName()))
252+
.evaluate();
254253
} catch (final Throwable e) {
255254
Throwables.rethrow(e);
256255
}

log4j-core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private RegexFilter(final Builder builder) {
6565

6666
super(builder);
6767

68-
if (Strings.isNotBlank(builder.regex)) {
68+
if (Strings.isBlank(builder.regex)) {
6969
throw new IllegalArgumentException("The 'regex' attribute must not be null or empty.");
7070
}
7171

@@ -316,8 +316,8 @@ public Builder setUseRawMsg(final boolean useRawMsg) {
316316
public @Nullable RegexFilter build() {
317317

318318
// validate the "regex" attribute
319-
if (this.regex == null) {
320-
LOGGER.error("Unable to create RegexFilter: The 'regex' attribute must be provided.");
319+
if (Strings.isEmpty(this.regex)) {
320+
LOGGER.error("Unable to create RegexFilter: The 'regex' attribute be set to a non-empty String.");
321321
return null;
322322
}
323323

0 commit comments

Comments
 (0)