Skip to content

Commit

Permalink
Prevent logger.traceEntry(null)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 12, 2023
1 parent 88b96ad commit a69a8b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
}
List<Expression> modifiedArgs = new ArrayList<>();
List<JavaType> modifiedTypes = new ArrayList<>();
modifiedArgs.add(buildNullString());
modifiedTypes.add(Primitive.String);
if (originalArgCount > 2) {
JavaType varargType = JavaType.buildType("java.lang.Object[]");
if (2 < originalArgCount) {
modifiedArgs.add(buildNullString());
modifiedTypes.add(Primitive.String);
modifiedArgs.add(originalArgs.get(2));
modifiedTypes.add(varargType);
modifiedTypes.add(JavaType.buildType("java.lang.Object[]"));
}
Method mt = m.getMethodType().withParameterTypes(modifiedTypes);
JavaType.FullyQualified dt = mt.getDeclaringType().withFullyQualifiedName("org.apache.logging.log4j.Logger");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void method(Logger logger) {
class Test {
void method(Logger logger) {
logger.traceEntry(null);
logger.traceEntry();
logger.traceEntry(null, "param");
logger.traceEntry(null, new Object[]{"param1", "param2"});
}
Expand Down

0 comments on commit a69a8b8

Please sign in to comment.