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

Ensure that a JAX-RS client exception does not depend on the server parts #16680

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
package org.jboss.resteasy.reactive.client.api;

import java.lang.annotation.Annotation;
import java.net.URI;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.EntityTag;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Link;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.NewCookie;
import javax.ws.rs.core.Response;

/**
Expand All @@ -17,19 +29,150 @@ public WebClientApplicationException() {
}

public WebClientApplicationException(String reason) {
super(reason);
}

public WebClientApplicationException(Throwable t) {
super(t);
}

public WebClientApplicationException(String reason, Throwable t) {
FroMage marked this conversation as resolved.
Show resolved Hide resolved
super(reason, t);
super(reason, null, DummyResponse.INSTANCE);
}

@Override
public final Response getResponse() {
return null;
}

// used in order to avoid depending on the server parts just for generating the exception
private static class DummyResponse extends Response {

private static final DummyResponse INSTANCE = new DummyResponse();

private DummyResponse() {
}

@Override
public int getStatus() {
return 0;
}

@Override
public StatusType getStatusInfo() {
return null;
}

@Override
public Object getEntity() {
return null;
}

@Override
public <T> T readEntity(Class<T> entityType) {
return null;
}

@Override
public <T> T readEntity(GenericType<T> entityType) {
return null;
}

@Override
public <T> T readEntity(Class<T> entityType, Annotation[] annotations) {
return null;
}

@Override
public <T> T readEntity(GenericType<T> entityType, Annotation[] annotations) {
return null;
}

@Override
public boolean hasEntity() {
return false;
}

@Override
public boolean bufferEntity() {
return false;
}

@Override
public void close() {

}

@Override
public MediaType getMediaType() {
return null;
}

@Override
public Locale getLanguage() {
return null;
}

@Override
public int getLength() {
return 0;
}

@Override
public Set<String> getAllowedMethods() {
return null;
}

@Override
public Map<String, NewCookie> getCookies() {
return null;
}

@Override
public EntityTag getEntityTag() {
return null;
}

@Override
public Date getDate() {
return null;
}

@Override
public Date getLastModified() {
return null;
}

@Override
public URI getLocation() {
return null;
}

@Override
public Set<Link> getLinks() {
return null;
}

@Override
public boolean hasLink(String relation) {
return false;
}

@Override
public Link getLink(String relation) {
return null;
}

@Override
public Link.Builder getLinkBuilder(String relation) {
return null;
}

@Override
public MultivaluedMap<String, Object> getMetadata() {
return null;
}

@Override
public MultivaluedMap<String, String> getStringHeaders() {
return null;
}

@Override
public String getHeaderString(String name) {
return null;
}
}
}