Skip to content

Commit 537c1fd

Browse files
fix: reduce noisy missing static resource logs from error to warn
Agent-Logs-Url: https://github.com/conorheffron/ironoc/sessions/f3624572-d35f-48a1-96fe-8153c30c577f Co-authored-by: conorheffron <8218626+conorheffron@users.noreply.github.com>
1 parent 832a61b commit 537c1fd

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/main/java/net/ironoc/portfolio/resolver/PushStateResourceResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private Resource resolve(String requestPath, List<? extends Resource> locations)
6060
if (staticResource.isPresent()) {
6161
return staticResource.get();
6262
} else {
63-
error("The request path {} does not exist.", requestPath);
63+
warn("The request path {} does not exist.", requestPath);
6464
return null;
6565
}
6666
}

src/test/java/net/ironoc/portfolio/resolver/PushStateResourceResolverTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import static org.hamcrest.Matchers.notNullValue;
1717
import static org.hamcrest.Matchers.nullValue;
1818
import static org.mockito.ArgumentMatchers.anyString;
19+
import static org.mockito.Mockito.never;
20+
import static org.mockito.Mockito.spy;
1921
import static org.mockito.Mockito.verify;
2022
import static org.mockito.Mockito.when;
2123

@@ -117,4 +119,22 @@ public void test_resolveUrlPath_api_ignoredPath_success() {
117119
// then
118120
assertThat(result, is(nullValue()));
119121
}
122+
123+
@Test
124+
public void test_resolveResource_missingHandledPath_warns_notErrors() throws IOException {
125+
// given
126+
PushStateResourceResolver pushStateResourceResolverSpy =
127+
spy(new PushStateResourceResolver(handledExtensions, ignorePaths));
128+
when(resourceMock.createRelative(anyString())).thenReturn(resourceMock);
129+
when(resourceMock.exists()).thenReturn(false);
130+
131+
// when
132+
Resource result = pushStateResourceResolverSpy.resolveResource(httpServletRequestMock,
133+
"home.js", List.of(resourceMock), resourceResolverChainMock);
134+
135+
// then
136+
assertThat(result, is(nullValue()));
137+
verify(pushStateResourceResolverSpy).warn("The request path {} does not exist.", "home.js");
138+
verify(pushStateResourceResolverSpy, never()).error("The request path {} does not exist.", "home.js");
139+
}
120140
}

0 commit comments

Comments
 (0)