Skip to content

Commit

Permalink
fix: fix resource loading for embedded spring boot apps (#9743)
Browse files Browse the repository at this point in the history
Loading from classpath resource should not start with '/' when Spring Boot is used.
  • Loading branch information
caalador authored and Denis committed Mar 16, 2021
1 parent da2aba4 commit 93c466f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ private String getClientEngineUrl(BootstrapContext context) {
String clientEngine = getClientEngine(resourceProvider);
boolean resolveNow = !productionMode || clientEngine == null;
if (resolveNow
&& resourceProvider.getClientResource("/META-INF/resources/"
&& resourceProvider.getClientResource("META-INF/resources/"
+ CLIENT_ENGINE_NOCACHE_FILE) != null) {
return context.getUriResolver().resolveVaadinUri(
"context://" + CLIENT_ENGINE_NOCACHE_FILE);
Expand All @@ -998,7 +998,7 @@ private String getClientEngineUrl(BootstrapContext context) {
private String getClientEngine(ResourceProvider resourceProvider) {
// read client engine file name
try (InputStream prop = resourceProvider
.getClientResourceAsStream("/META-INF/resources/"
.getClientResourceAsStream("META-INF/resources/"
+ ApplicationConstants.CLIENT_ENGINE_PATH
+ "/compile.properties")) {
// null when running SDM or tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void setup() throws Exception {
ResourceProvider resourceProvider = service.getContext()
.getAttribute(Lookup.class).lookup(ResourceProvider.class);
InputStream stream = resourceProvider.getClientResourceAsStream(
"/META-INF/resources/" + ApplicationConstants.CLIENT_ENGINE_PATH
"META-INF/resources/" + ApplicationConstants.CLIENT_ENGINE_PATH
+ "/compile.properties");
Properties properties = new Properties();
properties.load(stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public MockServletServiceSessionSetup(boolean sessionAvailable)
.thenReturn(resourceProvider);

Mockito.when(resourceProvider.getClientResourceAsStream(
"/META-INF/resources/" + ApplicationConstants.CLIENT_ENGINE_PATH
"META-INF/resources/" + ApplicationConstants.CLIENT_ENGINE_PATH
+ "/compile.properties"))
.thenAnswer(invocation -> new ByteArrayInputStream(
"jsFile=foo".getBytes(StandardCharsets.UTF_8)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private void initLookup(VaadinServletService service) throws IOException {
+ STATISTICS_JSON_DEFAULT));

Mockito.when(provider.getClientResourceAsStream(
"/META-INF/resources/" + ApplicationConstants.CLIENT_ENGINE_PATH
"META-INF/resources/" + ApplicationConstants.CLIENT_ENGINE_PATH
+ "/compile.properties"))
.thenAnswer(invocation -> new ByteArrayInputStream(
"jsFile=foo".getBytes(StandardCharsets.UTF_8)));
Expand Down

0 comments on commit 93c466f

Please sign in to comment.