Skip to content

Commit 4e96d7b

Browse files
1 parent 5ca86c6 commit 4e96d7b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/org/openrewrite/java/logging/SystemErrToLogging.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private List<Statement> collapseNextThrowablePrintStackTrace(List<Statement> sta
103103
} else if (stat instanceof J.MethodInvocation) {
104104
J.MethodInvocation m = (J.MethodInvocation) stat;
105105
if (systemErrPrint.matches((Expression) stat)) {
106-
if (m.getSelect() != null && m.getSelect() instanceof J.FieldAccess) {
106+
if (m.getSelect() instanceof J.FieldAccess) {
107107
JavaType.Variable field = ((J.FieldAccess) m.getSelect()).getName().getFieldType();
108108
if (field != null && "err".equals(field.getName()) && TypeUtils.isOfClassType(field.getOwner(), "java.lang.System")) {
109109
Expression exceptionPrintStackTrace = null;
@@ -132,7 +132,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
132132
J.MethodInvocation m = super.visitMethodInvocation(method, ctx);
133133
if (systemErrPrint.matches((Expression) method)) {
134134
if (getCursor().getParentOrThrow().getValue() instanceof J.Lambda) {
135-
if (m.getSelect() != null && m.getSelect() instanceof J.FieldAccess) {
135+
if (m.getSelect() instanceof J.FieldAccess) {
136136
JavaType.Variable field = ((J.FieldAccess) m.getSelect()).getName().getFieldType();
137137
if (field != null && "err".equals(field.getName()) && TypeUtils.isOfClassType(field.getOwner(), "java.lang.System")) {
138138
Cursor printCursor = new Cursor(getCursor().getParent(), m);

src/main/java/org/openrewrite/java/logging/SystemOutToLogging.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
8282
J.MethodInvocation m = super.visitMethodInvocation(method, ctx);
8383
Cursor cursor = updateCursor(m);
8484
if (systemOutPrint.matches((Expression) method)) {
85-
if (m.getSelect() != null && m.getSelect() instanceof J.FieldAccess) {
85+
if (m.getSelect() instanceof J.FieldAccess) {
8686
JavaType.Variable field = ((J.FieldAccess) m.getSelect()).getName().getFieldType();
8787
if (field != null && "out".equals(field.getName()) && TypeUtils.isOfClassType(field.getOwner(), "java.lang.System")) {
8888
return logInsteadOfPrint(cursor, ctx);

0 commit comments

Comments
 (0)