Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in caching decorator #1260

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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