Skip to content

Commit

Permalink
Fix bug in caching decorator (#1260)
Browse files Browse the repository at this point in the history
* Fix bug in caching decorator

* Change back to debug from warning, overflowing the logs
  • Loading branch information
JPercival authored Oct 25, 2023
1 parent 4aa69cd commit f64e237
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
14 changes: 13 additions & 1 deletion Src/java/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"java.configuration.updateBuildConfiguration": "automatic",
"java.debug.settings.onBuildFailureProceed": true,
"java.compile.nullAnalysis.mode": "automatic",
"java.jdt.ls.vmargs": "-noverify -Xmx8G -XX:+UseG1GC -XX:+UseStringDeduplication",
"cSpell.words": [
Expand All @@ -12,5 +13,16 @@
"testng",
"trackback"
],
"java.debug.settings.onBuildFailureProceed": true
"cSpell.enabledLanguageIds": [
"java",
"json",
"xml",
"markdown",
"cql"
],
"cSpell.ignorePaths": [
".git",
"**/*.gradle",
"**/test/resources/**"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Class<?> resolveType(Object value) {
.computeIfAbsent(pn, p -> new ConcurrentHashMap<>());

var result = packageTypeResolutions
.computeIfAbsent(valueClass, t -> Optional.ofNullable(this.innerResolver.resolveType(t)));
.computeIfAbsent(valueClass, t -> Optional.ofNullable(this.innerResolver.resolveType(value)));

if (result.isPresent()) {
return result.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.ArgumentMatchers.isA;

import java.util.Date;

Expand Down Expand Up @@ -51,6 +52,21 @@ public void context_path_resolved_only_once() {
verify(m, times(1)).getContextPath("Patient", "Patient");
}

@Test
public void type_resolved_only_once() {
var m = mock(ModelResolver.class);
when(m.getPackageName()).thenReturn("test.package");
when(m.resolveType(isA(Integer.class))).thenReturn((Class)Integer.class);
when(m.resolveType(isA(Class.class))).thenThrow(new RuntimeException("Can't get a class of a class"));

var cache = new CachingModelResolverDecorator(m);
cache.resolveType(5);
var result = cache.resolveType(5);

assertEquals(Integer.class, result);
verify(m, times(1)).resolveType(5);
}

@Test
void testResolveIdString() {
final String object = "object";
Expand Down
2 changes: 1 addition & 1 deletion Src/java/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.caching=true
org.gradle.parallel=true

group=info.cqframework
version=3.3.0
version=3.3.1
specification.version=1.5.2
hapi.version=6.8.3
fhir-core.version=6.0.22.2
Expand Down

0 comments on commit f64e237

Please sign in to comment.