Skip to content

Commit

Permalink
fix: make sure that app resources are properly deleted before we make…
Browse files Browse the repository at this point in the history
… the first request

fixes #5163
  • Loading branch information
machi1990 committed Nov 4, 2019
1 parent 5d426cb commit 0b33537
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/devmode/src/main/java/io/quarkus/dev/DevModeMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void start() throws Exception {

runtimeUpdatesProcessor = setupRuntimeCompilation(context);
if (runtimeUpdatesProcessor != null) {
runtimeUpdatesProcessor.checkForFileChange();
runtimeUpdatesProcessor.checkForChangedClasses();
}
//TODO: we can't handle an exception on startup with hot replacement, as Undertow might not have started
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private String getFileExtension(File file) {
return name.substring(lastIndexOf);
}

private Set<String> checkForFileChange() {
Set<String> checkForFileChange() {
Set<String> ret = new HashSet<>();
for (DevModeContext.ModuleInfo module : context.getModules()) {
final Set<Path> moduleResources = correspondingResources.computeIfAbsent(module.getName(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.quarkus.resteasy.test.files;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusDevModeTest;
import io.restassured.RestAssured;

public class StaticResourceDeletionBeforeFirstRequestTest {

public static final String META_INF_RESOURCES_STATIC_RESOURCE_TXT = "META-INF/resources/static-resource.txt";

@RegisterExtension
static final QuarkusDevModeTest test = new QuarkusDevModeTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addAsResource(new StringAsset("static resource content"), META_INF_RESOURCES_STATIC_RESOURCE_TXT));

@Test
public void shouldReturn404HttpStatusCode() {
test.deleteResourceFile(META_INF_RESOURCES_STATIC_RESOURCE_TXT); // delete the resource
RestAssured.when().get("/static-resource.txt").then().statusCode(404);
}
}

0 comments on commit 0b33537

Please sign in to comment.