Skip to content

Commit

Permalink
fix(web): Better merging of /applications/{app}?expand=false respon…
Browse files Browse the repository at this point in the history
…ses (#839)

Addresses an issue where the attributes of `cachedApplication` were
overriding the most recent values from `front50`.
  • Loading branch information
ajordens committed Jun 28, 2019
1 parent 5a5ae06 commit ddfae6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ class ApplicationService {
} catch (ExecutionException ee) {
throw ee.cause
}
if (expand == false) {
if (!expand) {
def cachedApplication = allApplicationsCache.get().find { name.equalsIgnoreCase(it.name as String) }
if (cachedApplication) {
applications.add(cachedApplication)
// ensure that `cachedApplication` attributes are overridden by any previously fetched metadata from front50
applications.add(0, cachedApplication)
}
}
List<Map> mergedApps = mergeApps(applications, serviceConfiguration.getService('front50'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,23 @@ class ApplicationServiceSpec extends Specification {
service.front50Service = front50
service.clouddriverService = clouddriver
service.executorService = Executors.newFixedThreadPool(1)
service.allApplicationsCache.set([
[name: name, email: "cached@email.com"]
])

when:
def app = service.getApplication(name, false)


then:
0 * clouddriver.getApplication(name)
1 * front50.getApplication(name) >> null
1 * front50.getApplication(name) >> {
return [
name: name,
email: "updated@email.com"
]
}

app.attributes.email == "updated@email.com"
}
}

0 comments on commit ddfae6e

Please sign in to comment.