-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying to reproduce spring-projects/spring-framework#32730
- Loading branch information
0 parents
commit 8eedbd8
Showing
6 changed files
with
154 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.3.0</version> | ||
</parent> | ||
<groupId>com.example</groupId> | ||
<artifactId>spring-framework-32730</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>spring-framework-32730</name> | ||
<description>spring-framework-32730</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-jersey</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-actuator</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micrometer</groupId> | ||
<artifactId>micrometer-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.2.5</version> | ||
<configuration> | ||
<argLine>-Xmx23m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${project.build.testOutputDirectory}/dump.hprof -XX:+ExitOnOutOfMemoryError</argLine> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/example/springframework32730/SpringFramework32730Application.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,13 @@ | ||
package com.example.springframework32730; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringFramework32730Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringFramework32730Application.class, args); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/example/springframework32730/TestApplication.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,15 @@ | ||
package com.example.springframework32730; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import jakarta.ws.rs.ApplicationPath; | ||
import org.glassfish.jersey.server.ResourceConfig; | ||
import org.springframework.stereotype.Component; | ||
|
||
@ApplicationPath("/") | ||
@Component | ||
public class TestApplication extends ResourceConfig { | ||
@PostConstruct | ||
void register() { | ||
register(TestResource.class); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/example/springframework32730/TestResource.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,29 @@ | ||
package com.example.springframework32730; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.QueryParam; | ||
import jakarta.ws.rs.WebApplicationException; | ||
import jakarta.ws.rs.container.AsyncResponse; | ||
import jakarta.ws.rs.container.Suspended; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
@Path("/test") | ||
public class TestResource { | ||
@GET | ||
public void get(@Suspended AsyncResponse response, @QueryParam("async") Boolean async, @QueryParam("error") Boolean error) { | ||
if (Boolean.TRUE.equals(async)) { | ||
new Thread(() -> reply(response, error)).start(); | ||
} else { | ||
reply(response, error); | ||
} | ||
} | ||
|
||
private void reply(AsyncResponse response, Boolean error) { | ||
if (Boolean.TRUE.equals(error)) { | ||
response.resume(new WebApplicationException(417)); | ||
} else { | ||
response.resume(Response.ok("success").build()); | ||
} | ||
} | ||
} |
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,5 @@ | ||
server.port=8999 | ||
management.server.port=8998 | ||
spring.application.name=spring-framework-32730 | ||
management.endpoint.metrics.enabled=true | ||
management.endpoints.web.exposure.include=metrics |
31 changes: 31 additions & 0 deletions
31
src/test/java/com/example/springframework32730/SpringFramework32730ApplicationTests.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,31 @@ | ||
package com.example.springframework32730; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.slf4j.Logger; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
class SpringFramework32730ApplicationTests { | ||
private static final Logger LOG = getLogger(SpringFramework32730ApplicationTests.class); | ||
|
||
@Autowired | ||
private TestRestTemplate template; | ||
|
||
@Test | ||
void testGet() { | ||
int i = 0; | ||
while (!Thread.interrupted()) { | ||
final ResponseEntity<String> response = template.getForEntity("/test", String.class); | ||
if (i % 1000 == 0) { | ||
LOG.info("response={}", response); | ||
} | ||
i++; | ||
} | ||
} | ||
} | ||
|