github-vet / github-vet/rangeloop-pointer-findings
aerogear-attic/managed-services-broker: tests/test_suites/broker_operations.go; 37 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [aerogear-attic/managed-services-broker](https://www.github.com/aerogear-attic/managed-services-broker) at [tests/test_suites/broker_operations.go](https://github.com/aerogear-attic/managed-services-broker/blob/1ecdce281faab9f5154e0824060c311726d4e379/tests/test_suites/broker_operations.go#L19-L55)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable svc used in defer or goroutine at line 42
[Click here to see the code in its original context.](https://github.com/aerogear-attic/managed-services-broker/blob/1ecdce281faab9f5154e0824060c311726d4e379/tests/test_suites/broker_operations.go#L19-L55)
Click here to show the 37 line(s) of Go which triggered the analyzer.
```go
for _, svc := range svcs {
// Test CreateServiceInstance
res, csiRes, err := sbc.CreateServiceInstance(TEST_NAMESPACE, svc.Name, svc.ID, svc.Plans[0].ID, async);if err != nil {
t.Fatal(fmt.Sprintf("Unexpected error creating %s", svc.Name), err.Description)
}
if res.StatusCode != http.StatusAccepted {
t.Fatal(fmt.Sprintf("Unexpected http status code when creating %s asynchronously", svc.Name), res.StatusCode, err.Description)
}
// Service Brokers MAY return an identifier representing the operation.
// If not returned set to default as it can not be an empty string.
operation := csiRes.Operation
if operation == "" {
operation = DEFAULT_OPERATION
}
// Poll for successful completion of CreateServiceInstance using LastOperation
wg := sync.WaitGroup{}
wg.Add(1)
go func(){
defer wg.Done()
hasFinished := false
for hasFinished == false {
_, loRes, _ := sbc.GetServiceInstanceLastOperation(svc.Name, svc.ID, svc.Plans[0].ID, operation);
time.Sleep(time.Second * 1)
// Ignore errors/error states as GetServiceInstanceLastOperation can return errors/error states as operations are initialising.
// Continue polling until the Service Broker returns a valid response or the test timeout fails.
hasFinished = loRes != nil && loRes.State == brokerClient.StateSucceeded
}
}()
wg.Wait()
// Test RemoveServiceInstance
_, _, err = sbc.DeleteServiceInstance(svc.Name, svc.ID, svc.Plans[0].ID, async);if err != nil {
t.Fatal(fmt.Sprintf("An error has occured deleting a service instance for %s", svc.Name), err.Description)
}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 1ecdce281faab9f5154e0824060c311726d4e379
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.