我收到此编译器警告: 对上面的代码使用未经检查或不安全的操作
resource "aws_iam_policy" "policy" {
name = "my-role"
description = "My policy"
policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1590217939128",
"Action": "s3:*",
"Effect": "Allow",
"Resource": "arn:aws:s3:::wwe"
},
{
"Sid": "Stmt1590217939125",
"Action": "s3:*",
"Effect": "Allow",
"Resource": "arn:aws:s3:::wwe/*"
},
{
"Sid": "Stmt1577967806846",
"Action": [
"secretsmanager:DescribeSecret",
"secretsmanager:GetRandomPassword",
"secretsmanager:GetResourcePolicy",
"secretsmanager:GetSecretValue",
"secretsmanager:ListSecretVersionIds",
"secretsmanager:ListSecrets"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "test-attach" {
role = "${aws_iam_role.role.name}"
policy_arn = "${aws_iam_policy.policy.arn}"
}
但我不知道为什么,我尝试使用-Xlint params运行更多信息。
代码有效,但警告仍然存在。
希望可以为您提供帮助
整个任务:
new InsertAllTask(essenceDao).execute(essenceList)
InsertTask:
public static class DeleteAllTask extends AsyncTask<Void, Void, Void> {
private final EssenceDao essenceDao;
private final List<Essence> essenceList;
DeleteAllTask(EssenceDao essenceDao, List<Essence> list) {
this.essenceDao = essenceDao;
this.essenceList = list;
}
@Override
protected Void doInBackground(Void... voids) {
essenceDao.deleteAllEssence();
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
if (essenceList != null) {
// Insert new list
new InsertAllTask(essenceDao).execute(essenceList);
}
}
}
答案 0 :(得分:0)
由于您要在不修复警告源的情况下禁止显示警告(-Xlint)
,因此可以将此注释添加到包含不安全代码的方法中:
@SuppressWarnings({"unused", "rawtypes"})
上面的代码:
public class TestUnsafe {
public static void main(String[] args) {
List myList = new ArrayList();
}
}
在尝试编译时显示以下警告:
javac TestUnsafe.java -Xlint
TestUnsafe.java:7: warning: [rawtypes] found raw type: List
List myList = new ArrayList();
^
missing type arguments for generic class List<E>
where E is a type-variable:
E extends Object declared in interface List
TestUnsafe.java:7: warning: [rawtypes] found raw type: ArrayList
List myList = new ArrayList();
^
missing type arguments for generic class ArrayList<E>
where E is a type-variable:
E extends Object declared in class ArrayList
2 warnings
但是,使用几个注释:
public class TestUnsafe {
@SuppressWarnings({"unused", "rawtypes"})
public static void main(String[] args) {
List myList = new ArrayList();
}
}
javac TestUnsafe.java -Xlint
返回一个空的编译日志。
为我们提供一个最小的可复制示例,以查找正确的注释或对其进行修复!