Skip to content

Commit e030d85

Browse files
committed
Add additional test case to verify SystemErrToLogging works with a try-catch nested in a switch
1 parent d7fb6d0 commit e030d85

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/test/java/org/openrewrite/java/logging/SystemErrToLoggingTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,48 @@ void m(int cnt) {
282282
}
283283
}
284284
"""
285+
),
286+
//language=java
287+
java(
288+
"""
289+
class Test {
290+
org.slf4j.Logger logger = null;
291+
292+
void method(int cnt, String name) {
293+
switch (cnt) {
294+
case 1:
295+
try {
296+
yield "bla";
297+
} catch (Exception e) {
298+
System.err.println("This is a message for " + name + " with a $ dollar sign");
299+
yield "bla";
300+
}
301+
break;
302+
default:
303+
break;
304+
}
305+
}
306+
}
307+
""",
308+
"""
309+
class Test {
310+
org.slf4j.Logger logger = null;
311+
312+
void method(int cnt, String name) {
313+
switch (cnt) {
314+
case 1:
315+
try {
316+
yield "bla";
317+
} catch (Exception e) {
318+
logger.error("This is a message for {} with a $ dollar sign", name);
319+
yield "bla";
320+
}
321+
break;
322+
default:
323+
break;
324+
}
325+
}
326+
}"""
285327
)
286328
);
287329
}

0 commit comments

Comments
 (0)