GeezerVison is showing github.com — Errorprone static analysis tool integration and fixes of reported iss… · NetApp/cloudstack@5b49d6a
File treeExpand file treeCollapse file tree Open diff view settings agent/src/main/java/com/cloud/agent/mockvm main/java/org/apache/cloudstack/api/command/admin/backup test/java/com/cloud/network
agent/resource/virtualnetwork/facade
org/apache/cloudstack/agent/directdownload
test/java/com/cloud/resource
org/apache/cloudstack/engine/orchestration
test/java/com/cloud/agent/manager
snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot src/main/java/org/apache/cloudstack/storage/endpoint
db/src/main/java/com/cloud/utils/db ipc/src/main/java/org/apache/cloudstack/framework/serializer spring/module/src/test/java/org/apache/cloudstack/spring/module/factory
ca/root-ca/src/main/java/org/apache/cloudstack/ca/provider test/java/com/cloud/hypervisor/hyperv/test
main/java/com/cloud/hypervisor/kvm test/java/com/cloud/hypervisor/kvm
ovm3/src/test/java/com/cloud/hypervisor/ovm3/objects vmware/src/test/java/com/cloud/hypervisor/vmware main/java/com/cloud/hypervisor test/java/com/cloud/hypervisor/xenserver/resource
brocade-vcs/src/test/java/com/cloud/network/guru cisco-vnmc/src/test/java/com/cloud/network nicira-nvp/src/test/java/com/cloud/network nsx/src/main/java/org/apache/cloudstack/agent/api tungsten/src/test/java/org/apache/cloudstack/network/tungsten/api/command
outofbandmanagement-drivers/redfish/src/main/java/org/apache/cloudstack/outofbandmanagement/driver/redfish nexenta/src/main/java/org/apache/cloudstack/storage/datastore/util storpool/src/main/java/org/apache/cloudstack/storage
user-authenticators/ldap/src main/java/org/apache/cloudstack/ldap test/java/org/apache/cloudstack/ldap
org/apache/cloudstack/network/router/deployment
services/console-proxy/rdpconsole/src vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/linters/codespell.txt +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -188,6 +188,7 @@ environmnet | 188 | 188 | equivalant | 189 | 189 | erro | 190 | 190 | erronous | | 191 | +errorprone | 191 | 192 | everthing | 192 | 193 | everytime | 193 | 194 | excetion | |
Collapse file Copy file name to clipboardExpand all lines: agent/src/main/java/com/cloud/agent/mockvm/MockVmMgr.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -249,7 +249,7 @@ public void freeVncPort(int port) { | 249 | 249 | public MockVm createVmFromSpec(VirtualMachineTO vmSpec) { | 250 | 250 | String vmName = vmSpec.getName(); | 251 | 251 | long ramSize = vmSpec.getMinRam(); | 252 | | - int utilizationPercent = randSeed.nextInt() % 100; | | 252 | + int utilizationPercent = randSeed.nextInt(100); | 253 | 253 | MockVm vm = null; | 254 | 254 |
| 255 | 255 | synchronized (this) { | |
Collapse file Copy file name to clipboardExpand all lines: api/src/main/java/org/apache/cloudstack/api/command/admin/backup/UpdateBackupOfferingCmd.java +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -83,8 +83,8 @@ public Boolean getAllowUserDrivenBackups() { | 83 | 83 | public void execute() { | 84 | 84 | try { | 85 | 85 | if (StringUtils.isAllEmpty(getName(), getDescription()) && getAllowUserDrivenBackups() == null) { | 86 | | - throw new InvalidParameterValueException(String.format("Can't update Backup Offering [id: %s] because there are no parameters to be updated, at least one of the", | 87 | | - "following should be informed: name, description or allowUserDrivenBackups.", id)); | | 86 | + throw new InvalidParameterValueException(String.format("Can't update Backup Offering [id: %s] because there are no parameters to be updated," + | | 87 | + " at least one of the following should be passed: name, description or allowUserDrivenBackups.", id)); | 88 | 88 | } | 89 | 89 |
| 90 | 90 | BackupOffering result = backupManager.updateBackupOffering(this); | |
Collapse file Copy file name to clipboardExpand all lines: api/src/test/java/com/cloud/network/IsolationMethodTest.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 25 | 25 | public class IsolationMethodTest { | 26 | 26 | @After | 27 | 27 | public void cleanTheRegistry() { | 28 | | - PhysicalNetwork.IsolationMethod.registeredIsolationMethods.removeAll(PhysicalNetwork.IsolationMethod.registeredIsolationMethods); | | 28 | + PhysicalNetwork.IsolationMethod.registeredIsolationMethods.clear(); | 29 | 29 | } | 30 | 30 |
| 31 | 31 | @Test | |
Collapse file Copy file name to clipboardExpand all lines: core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -106,7 +106,7 @@ public abstract class AbstractConfigItemFacade { | 106 | 106 |
| 107 | 107 | public static AbstractConfigItemFacade getInstance(final Class<? extends NetworkElementCommand> key) { | 108 | 108 | if (!flyweight.containsKey(key)) { | 109 | | - throw new CloudRuntimeException("Unable to process the configuration for " + key.getClass().getName()); | | 109 | + throw new CloudRuntimeException("Unable to process the configuration for " + key.getName()); | 110 | 110 | } | 111 | 111 |
| 112 | 112 | final AbstractConfigItemFacade instance = flyweight.get(key); | |
Collapse file Copy file name to clipboardExpand all lines: core/src/main/java/com/cloud/network/HAProxyConfigurator.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -514,7 +514,7 @@ private List<String> getRulesForPool(final LoadBalancerTO lbTO, final boolean ke | 514 | 514 | } | 515 | 515 | dstSubRule.add(sb.toString()); | 516 | 516 | if (stickinessSubRule != null) { | 517 | | - sb.append(" cookie ").append(dest.getDestIp().replace(".", "_")).append('-').append(dest.getDestPort()).toString(); | | 517 | + sb.append(" cookie ").append(dest.getDestIp().replace(".", "_")).append('-').append(dest.getDestPort()); | 518 | 518 | dstWithCookieSubRule.add(sb.toString()); | 519 | 519 | } | 520 | 520 | destsAvailable = true; | |
Collapse file Copy file name to clipboardExpand all lines: core/src/main/java/com/cloud/resource/RequestWrapper.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -86,7 +86,7 @@ protected CommandWrapper<Command, Answer, ServerResource> retrieveCommands(final | 86 | 86 |
| 87 | 87 | keepCommandClass = commandClass2; | 88 | 88 | } catch (final ClassCastException e) { | 89 | | - throw new CommandNotSupported("No key found for '" + keepCommandClass.getClass() + "' in the Map!"); | | 89 | + throw new CommandNotSupported("No key found for '" + keepCommandClass + "' in the Map!"); | 90 | 90 | } catch (final NullPointerException e) { | 91 | 91 | // Will now traverse all the resource hierarchy. Returning null | 92 | 92 | // is not a problem. | |
Collapse file Copy file name to clipboardExpand all lines: core/src/main/java/org/apache/cloudstack/agent/directdownload/DirectDownloadCommand.java -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,7 +53,6 @@ protected DirectDownloadCommand (final String url, final Long templateId, final | 53 | 53 | final Integer soTimeout, final Integer connectionRequestTimeout, final boolean followRedirects) { | 54 | 54 | this.url = url; | 55 | 55 | this.templateId = templateId; | 56 | | - this.destData = destData; | 57 | 56 | this.destPool = destPool; | 58 | 57 | this.checksum = checksum; | 59 | 58 | this.headers = headers; | |
Collapse file Copy file name to clipboardExpand all lines: core/src/test/java/com/cloud/resource/ServerResourceBaseTest.java +11-12Lines changed: 11 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -182,36 +182,36 @@ public void tryToAutoDiscoverResourcePrivateNetworkInterfaceTestReturnNic() thro | 182 | 182 | @Test | 183 | 183 | public void defineResourceNetworkInterfacesTestUseXenbr0WhenPrivateNetworkInterfaceNotConfigured() { | 184 | 184 | Map<String, Object> params = createParamsMap(null, "cloudbr1", "cloudbr2", "cloudbr3"); | 185 | | - try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) { | 186 | | - Mockito.when(NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4); | | 185 | + try (MockedStatic<NetUtils> mockedNetUtils = Mockito.mockStatic(NetUtils.class)) { | | 186 | + mockedNetUtils.when(() -> NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4); | 187 | 187 |
| 188 | 188 | serverResourceBaseSpy.defineResourceNetworkInterfaces(params); | 189 | 189 |
| 190 | | - verifyAndAssertNetworkInterfaces("xenbr0", "cloudbr1", "cloudbr2", "cloudbr3"); | | 190 | + verifyAndAssertNetworkInterfaces(mockedNetUtils, "xenbr0", "cloudbr1", "cloudbr2", "cloudbr3"); | 191 | 191 | } | 192 | 192 | } | 193 | 193 |
| 194 | 194 | @Test | 195 | 195 | public void defineResourceNetworkInterfacesTestUseXenbr1WhenPublicNetworkInterfaceNotConfigured() { | 196 | 196 | Map<String, Object> params = createParamsMap("cloudbr0", null, "cloudbr2", "cloudbr3"); | 197 | | - try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) { | 198 | | - Mockito.when(NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4); | | 197 | + try (MockedStatic<NetUtils> mockedNetUtils = Mockito.mockStatic(NetUtils.class)) { | | 198 | + mockedNetUtils.when(() -> NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4); | 199 | 199 |
| 200 | 200 | serverResourceBaseSpy.defineResourceNetworkInterfaces(params); | 201 | 201 |
| 202 | | - verifyAndAssertNetworkInterfaces("cloudbr0", "xenbr1", "cloudbr2", "cloudbr3"); | | 202 | + verifyAndAssertNetworkInterfaces(mockedNetUtils, "cloudbr0", "xenbr1", "cloudbr2", "cloudbr3"); | 203 | 203 | } | 204 | 204 | } | 205 | 205 |
| 206 | 206 | @Test | 207 | 207 | public void defineResourceNetworkInterfacesTestUseConfiguredNetworkInterfaces() { | 208 | 208 | Map<String, Object> params = createParamsMap("cloudbr0", "cloudbr1", "cloudbr2", "cloudbr3"); | 209 | | - try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) { | 210 | | - Mockito.when(NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4); | | 209 | + try (MockedStatic<NetUtils> mockedNetUtils = Mockito.mockStatic(NetUtils.class)) { | | 210 | + mockedNetUtils.when(() -> NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4); | 211 | 211 |
| 212 | 212 | serverResourceBaseSpy.defineResourceNetworkInterfaces(params); | 213 | 213 |
| 214 | | - verifyAndAssertNetworkInterfaces("cloudbr0", "cloudbr1", "cloudbr2", "cloudbr3"); | | 214 | + verifyAndAssertNetworkInterfaces(mockedNetUtils, "cloudbr0", "cloudbr1", "cloudbr2", "cloudbr3"); | 215 | 215 | } | 216 | 216 | } | 217 | 217 |
| @@ -224,9 +224,8 @@ private Map<String, Object> createParamsMap(String... params) { | 224 | 224 | return result; | 225 | 225 | } | 226 | 226 |
| 227 | | - private void verifyAndAssertNetworkInterfaces(String... expectedResults) { | 228 | | - Mockito.verify(NetUtils.class, Mockito.times(4)); | 229 | | - NetUtils.getNetworkInterface(keyCaptor.capture()); | | 227 | + private void verifyAndAssertNetworkInterfaces(MockedStatic<NetUtils> mockedNetUtils, String... expectedResults) { | | 228 | + mockedNetUtils.verify(() -> NetUtils.getNetworkInterface(keyCaptor.capture()), Mockito.times(4)); | 230 | 229 | List<String> keys = keyCaptor.getAllValues(); | 231 | 230 |
| 232 | 231 | for (int i = 0; i < expectedResults.length; i++) { | |
Collapse file Copy file name to clipboardExpand all lines: engine/orchestration/src/main/java/com/cloud/agent/manager/AgentAttache.java +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 24 | 24 | import java.util.LinkedList; | 25 | 25 | import java.util.List; | 26 | 26 | import java.util.Map; | | 27 | +import java.util.Objects; | 27 | 28 | import java.util.Random; | 28 | 29 | import java.util.Set; | 29 | 30 | import java.util.concurrent.ConcurrentHashMap; | @@ -351,7 +352,8 @@ public boolean equals(final Object obj) { | 351 | 352 | return false; | 352 | 353 | } | 353 | 354 | AgentAttache that = (AgentAttache)obj; | 354 | | - return _id == that._id; | | 355 | + return Objects.equals(_uuid, that._uuid) && | | 356 | + Objects.equals(_name, that._name); | 355 | 357 | } | 356 | 358 |
| 357 | 359 | public void send(final Request req, final Listener listener) throws AgentUnavailableException { | @@ -497,6 +499,11 @@ public void process(final Answer[] answers) { | 497 | 499 | */ | 498 | 500 | protected abstract boolean isClosed(); | 499 | 501 |
| | 502 | + @Override | | 503 | + public int hashCode() { | | 504 | + return Objects.hash(_uuid, _name); | | 505 | + } | | 506 | + | 500 | 507 | protected class Alarm extends ManagedContextRunnable { | 501 | 508 | long _seq; | 502 | 509 |
| |
|