0
雖然試圖發佈jenkins插件maven報告了一些findbugs錯誤,我無法弄清楚如何解決。Findbugs`NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE`
[INFO] Possible null pointer dereference in com.datapipe.jenkins.vault.VaultBuildWrapper$DescriptorImpl.doFillAuthTokenCredentialIdItems() due to return value of called method [com.datapipe.jenkins.vault.VaultBuildWrapper$DescriptorImpl, com.datapipe.jenkins.vault.VaultBuildWrapper$DescriptorImpl] Dereferenced at VaultBuildWrapper.java:[line 326]Known null at VaultBuildWrapper.java:[line 326] NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
[INFO] Possible null pointer dereference in com.datapipe.jenkins.vault.VaultBuildWrapper$DescriptorImpl.doFillAuthTokenCredentialIdItems() due to return value of called method [com.datapipe.jenkins.vault.VaultBuildWrapper$DescriptorImpl, com.datapipe.jenkins.vault.VaultBuildWrapper$DescriptorImpl] Method invoked at VaultBuildWrapper.java:[line 329]Known null at VaultBuildWrapper.java:[line 329] NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
問題屬於以下函數中的行:
public ListBoxModel doFillAuthTokenCredentialIdItems(){
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
return new ListBoxModel();
}
AbstractIdCredentialsListBoxModel model = new StandardListBoxModel().includeEmptyValue().includeAs(ACL.SYSTEM, Jenkins.getInstance(), VaultTokenCredential.class);
return model;
}
我曾嘗試加入以下空校驗無濟於事:提前
public ListBoxModel doFillAuthTokenCredentialIdItems(){
Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
return new ListBoxModel();
}
if (!jenkins.hasPermission(Jenkins.ADMINISTER)) {
return new ListBoxModel();
}
AbstractIdCredentialsListBoxModel model = new StandardListBoxModel().includeEmptyValue().includeAs(ACL.SYSTEM, jenkins, VaultTokenCredential.class);
return model;
}
感謝