Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @NoCache without fields handling in RESTEasy Reactive #19823

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,53 @@ public JavaArchive get() {
});

@Test
public void testWith() {
RestAssured.get("/test/with")
public void testWithFields() {
RestAssured.get("/test/withFields")
.then()
.statusCode(200)
.body(equalTo("with"))
.body(equalTo("withFields"))
.header("Cache-Control", "no-cache=\"f1\", no-cache=\"f2\"");
}

@Test
public void testWithout() {
RestAssured.get("/test/without")
public void testWithoutFields() {
RestAssured.get("/test/withoutFields")
.then()
.statusCode(200)
.body(equalTo("without"))
.body(equalTo("withoutFields"))
.header("Cache-Control", "no-cache");
}

@Test
public void testWithoutAnnotation() {
RestAssured.get("/test/withoutAnnotation")
.then()
.statusCode(200)
.body(equalTo("withoutAnnotation"))
.header("Cache-Control", nullValue());
}

@Path("test")
public static class ResourceWithNoCache {

@Path("with")
@Path("withFields")
@GET
@NoCache(fields = { "f1", "f2" })
public String with() {
return "with";
public String withFields() {
return "withFields";
}

@Path("withoutFields")
@GET
@NoCache
public String withoutFields() {
return "withoutFields";
}

@Path("without")
@Path("withoutAnnotation")
@GET
public String without() {
return "without";
public String withoutAnnotation() {
return "withoutAnnotation";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ private ExtendedCacheControl noCacheToCacheControl(AnnotationInstance noCacheIns
if (noCacheInstance == null) {
return null;
}
ExtendedCacheControl cacheControl = new ExtendedCacheControl();
cacheControl.setNoCache(true);
cacheControl.setNoTransform(false);
AnnotationValue fieldsValue = noCacheInstance.value("fields");
if (fieldsValue != null) {
String[] fields = fieldsValue.asStringArray();
if ((fields != null) && (fields.length > 0)) {
ExtendedCacheControl cacheControl = new ExtendedCacheControl();
cacheControl.setNoCache(true);
cacheControl.setNoTransform(false);
cacheControl.getNoCacheFields().addAll(Arrays.asList(fields));
return cacheControl;

}
}
return null;
return cacheControl;
}

private ExtendedCacheControl cacheToCacheControl(AnnotationInstance cacheInstance) {
Expand Down