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

Disable JSON-P / JSON-B Default Registration in JAX-RS 3.1 (from CXF 4.1.0-SNAPSHOT) #1636

Merged
merged 3 commits into from
Nov 18, 2024
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 @@ -26,6 +26,7 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.cxf.BusFactory;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
Expand Down Expand Up @@ -64,6 +65,8 @@ public static WebArchive createDeployment() {
@Before
public void before() {
this.client = ClientBuilder.newClient();
//disable json-p / json-b default registration in JAX-RS 3.1
BusFactory.getDefaultBus().setProperty("skip.jakarta.json.providers.registration", "true");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
import net.minidev.json.JSONObject;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.feature.LoggingFeature;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.johnzon.jaxrs.JohnzonProvider;
Expand Down Expand Up @@ -69,6 +71,10 @@ public static WebArchive createDeployment() {

@Test
public void movieRestTest() throws Exception {
final Bus bus = BusFactory.getDefaultBus();
//disable json-p / json-b default registration in JAX-RS 3.1
bus.setProperty("skip.jakarta.json.providers.registration", "true");

final WebClient webClient = WebClient
.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()),
singletonList(new LoggingFeature()), null);
Expand All @@ -82,7 +88,6 @@ public void movieRestTest() throws Exception {
LOGGER.info("responsePayload = " + responsePayload);
assertEquals("alice", responsePayload);


// Testing REST endpoint with group claims manager
Book newBook = new Book(1, "The Lord of the Rings", "J.R.R.Tolkien");
Response response = webClient.reset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ public void init(final Properties properties) throws Exception {
private void initCxfProviders(final Bus bus) {
if (noProvidersExplicitlyAdded(bus)) {
bus.setProperty("skip.default.json.provider.registration", "true"); // client jaxrs, we want johnzon not jettison
bus.setProperty("skip.jakarta.json.providers.registration",
SystemInstance.get().getProperty("openejb.jaxrs.skip.jakarta.json.providers.registration", "true")); // Make sure default JAXRS 3.1 JSON-P/JSON-B providers are not loaded

final Collection<Object> defaults = new ArrayList<>();
List<String> jsonProviders;
Expand Down
1 change: 1 addition & 0 deletions tck/jax-rs/jax-rs-tests-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
<password>j2ee</password>
<authuser>javajoe</authuser>
<authpassword>javajoe</authpassword>
<openejb.jaxrs.skip.jakarta.json.providers.registration>false</openejb.jaxrs.skip.jakarta.json.providers.registration>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down
1 change: 1 addition & 0 deletions tck/jax-rs/jax-rs-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
<password>j2ee</password>
<authuser>javajoe</authuser>
<authpassword>javajoe</authpassword>
<openejb.jaxrs.skip.jakarta.json.providers.registration>false</openejb.jaxrs.skip.jakarta.json.providers.registration>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down