-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12624 from gsmet/1.8.3-backports-1
1.8.3 backports 1
- Loading branch information
Showing
36 changed files
with
638 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...sions/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/InputStreamResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.quarkus.resteasy.test; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Timer; | ||
import java.util.TimerTask; | ||
import java.util.concurrent.LinkedBlockingDeque; | ||
|
||
import javax.annotation.PreDestroy; | ||
import javax.enterprise.event.Observes; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
|
||
import io.vertx.core.Handler; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
@Path("/in") | ||
public class InputStreamResource { | ||
|
||
Timer timer = new Timer(); | ||
|
||
public static final LinkedBlockingDeque<Throwable> THROWABLES = new LinkedBlockingDeque<>(); | ||
|
||
@PreDestroy | ||
void stop() { | ||
timer.cancel(); | ||
} | ||
|
||
@POST | ||
public String read(InputStream inputStream) throws IOException { | ||
try { | ||
byte[] buf = new byte[1024]; | ||
int r; | ||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
while ((r = inputStream.read(buf)) > 0) { | ||
out.write(buf, 0, r); | ||
} | ||
return new String(out.toByteArray(), StandardCharsets.UTF_8); | ||
} catch (IOException e) { | ||
THROWABLES.add(e); | ||
throw e; | ||
} | ||
} | ||
|
||
public void delayFilter(@Observes Router router) { | ||
router.route().order(Integer.MIN_VALUE).handler(new Handler<RoutingContext>() { | ||
@Override | ||
public void handle(RoutingContext event) { | ||
timer.schedule(new TimerTask() { | ||
@Override | ||
public void run() { | ||
event.next(); | ||
} | ||
}, 1000); | ||
} | ||
}); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...sions/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/VertxIOHangTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.quarkus.resteasy.test; | ||
|
||
import java.io.IOException; | ||
import java.net.Socket; | ||
import java.net.URI; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import io.restassured.RestAssured; | ||
|
||
public class VertxIOHangTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(InputStreamResource.class)); | ||
|
||
@TestHTTPResource | ||
URI uri; | ||
|
||
@Test | ||
public void testDelayFilter() { | ||
// makes sure that everything works as normal | ||
RestAssured.given().body("hello world").post("/in").then().body(Matchers.is("hello world")); | ||
} | ||
|
||
@Test | ||
public void testDelayFilterConnectionKilled() throws Exception { | ||
// makes sure that everything works as normal | ||
try (Socket s = new Socket(uri.getHost(), uri.getPort())) { | ||
s.getOutputStream().write( | ||
"POST /in HTTP/1.1\r\nHost:localhost\r\nContent-Length: 100\r\n\r\n".getBytes(StandardCharsets.UTF_8)); | ||
s.getOutputStream().flush(); | ||
} | ||
Throwable exception = InputStreamResource.THROWABLES.poll(3, TimeUnit.SECONDS); | ||
Assertions.assertTrue(exception instanceof IOException); | ||
} | ||
} |
Oops, something went wrong.