Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failing testcases for safe-logging check when using Runnables/Suppliers/etc #2984

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,51 @@ void testDiamondTypeSafetyInheritance() {
.doTest();
}

@Test
public void testInterfaceDefaultMethodReturningRunnable() {
helper().addSourceLines(
"Test.java",
"import com.palantir.logsafe.*;",
"interface Test {",
" default Runnable f(@Unsafe Object value) {",
" // BUG: Diagnostic contains: Dangerous argument value: arg is 'UNSAFE'",
" return () -> fun(value);",
" }",
" void fun(@Safe Object value);",
"}")
.doTest();
}

@Test
public void testStaticMethodReturningRunnable() {
helper().addSourceLines(
"Test.java",
"import com.palantir.logsafe.*;",
"class Test {",
" static Runnable f(@Unsafe Object value) {",
" // BUG: Diagnostic contains: Dangerous argument value: arg is 'UNSAFE'",
" return () -> fun(value);",
" }",
" private static void fun(@Safe Object value) {}",
"}")
.doTest();
}

@Test
public void testStaticMethodContainingRunnable() {
helper().addSourceLines(
"Test.java",
"import com.palantir.logsafe.*;",
"class Test {",
" static void f(@Unsafe Object value) {",
" // BUG: Diagnostic contains: Dangerous argument value: arg is 'UNSAFE'",
" Runnable ignored = () -> fun(value);",
" }",
" private static void fun(@Safe Object value) {}",
"}")
.doTest();
}

private CompilationTestHelper helper() {
return CompilationTestHelper.newInstance(IllegalSafeLoggingArgument.class, getClass());
}
Expand Down