Skip to content

Commit 6f1358c

Browse files
committed
Fixed a reverse logic check in a validation (apache#3086)
1 parent 283dcff commit 6f1358c

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
@@ -293,11 +293,10 @@ public void evaluate() throws Throwable {
293293
private void runTest(final LoggerContextRule rule, final Statement statement) {
294294
try {
295295
rule.apply(
296-
statement,
297-
Description.createTestDescription(
298-
getClass(),
299-
Thread.currentThread().getStackTrace()[1].getMethodName()))
300-
.evaluate();
296+
statement,
297+
Description.createTestDescription(getClass(),
298+
Thread.currentThread().getStackTrace()[1].getMethodName()))
299+
.evaluate();
301300
} catch (final Throwable e) {
302301
Throwables.rethrow(e);
303302
}

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

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

6767
super(builder);
6868

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

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

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

0 commit comments

Comments
 (0)