Skip to content

Commit 05c6c9a

Browse files
committed
Guard logging calls
1 parent 7c05b1c commit 05c6c9a

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/changes/changes.xml

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
<action dev="ggregory" type="fix" due-to="step-security-bot, Gary Gregory">
8989
[StepSecurity] ci: Harden GitHub Actions #180.
9090
</action>
91+
<action dev="ggregory" type="fix" due-to="PMD, Gary Gregory">
92+
Guard logging calls.
93+
</action>
9194
<!-- UPDATE -->
9295
<action dev="henrib" type="update" due-to="dependabot">
9396
Bump github actions.

src/main/java/org/apache/commons/jexl3/internal/Engine.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,17 @@ private void processPragmaNamespace(final Map<String, Object> ns, final String k
517517
final String nsclass = value.toString();
518518
final Class<?> clazz = uberspect.getClassByName(nsclass);
519519
if (clazz == null) {
520-
logger.warn(key + ": unable to find class " + nsclass);
520+
if (logger.isWarnEnabled()) {
521+
logger.warn(key + ": unable to find class " + nsclass);
522+
}
521523
} else {
522524
ns.put(namespaceName, clazz);
523525
}
524526
}
525527
} else {
526-
logger.warn(key + ": ambiguous declaration " + value);
528+
if (logger.isWarnEnabled()) {
529+
logger.warn(key + ": ambiguous declaration " + value);
530+
}
527531
}
528532
}
529533

@@ -543,11 +547,15 @@ private void processPragmaModule(final Map<String, Object> ns, final String key,
543547
// jexl.module.***
544548
final String module = key.substring(PRAGMA_MODULE.length());
545549
if (module.isEmpty()) {
546-
logger.warn(module + ": invalid module declaration");
550+
if (logger.isWarnEnabled()) {
551+
logger.warn(module + ": invalid module declaration");
552+
}
547553
} else {
548554
withValueSet(value, o -> {
549555
if (!(o instanceof CharSequence)) {
550-
logger.warn(module + ": unable to define module from " + value);
556+
if (logger.isWarnEnabled()) {
557+
logger.warn(module + ": unable to define module from " + value);
558+
}
551559
} else {
552560
final String moduleSrc = o.toString();
553561
final Object functor;

0 commit comments

Comments
 (0)