javaee / jersey

This is no longer the active Jersey repository. Please see the README.md
http://jersey.github.io
Other
2.86k stars 2.35k forks source link

PUT Operation without entity body must fail to deploy #2560

Closed glassfishrobot closed 10 years ago

glassfishrobot commented 10 years ago

Consider a REST service as below:

@Path("project1")
public class EmpService {
    List<Employee> empList = new ArrayList<Employee>();
    public EmpService() {
        super();
        Employee emp = new Employee();
        emp.setEmpID(1);
        emp.setName("Mitch");
        empList.add(emp);

    }

    @GET
    @Produces("application/xml")
    public List<Employee> allEmps(){
            return empList;
        }

    @PUT
    @Produces("application/xml")
    @Path("{id}/{name}")
    public List<Employee> newEmp(@PathParam("id") int id, @PathParam("name") String name){
        Employee e = new Employee();
        e.setEmpID(id);
        e.setName(name);
        empList.add(e);
        return empList;
        }
}

The Employee Bean is as below:

package project1;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Employee {
    String name;
    int empID;
    public Employee() {
        super();
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setEmpID(int empID) {
        this.empID = empID;
    }

    public int getEmpID() {
        return empID;
    }
}

On testing the PUT operation in some tool (like Google Chrome extension POSTMAN), it is successful. However, on invoking the PUT operation in a Jersey Java client, exception is seen: java.lang.IllegalStateException: Entity must not be null for http method PUT.

If Entity is mandatory for PUT operations, service deployment must fail in the absence of Entity.

Environment

Windows 7

Affected Versions

[2.4.1]

glassfishrobot commented 10 years ago

Reported by padbhat

glassfishrobot commented 10 years ago

@mpotociar said: Please use the SUPPRESS_HTTP_COMPLIANCE_VALIDATION client configuration property to suppress the exception on the client side.

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JERSEY-2288

glassfishrobot commented 10 years ago

Marked as works as designed on Wednesday, January 15th 2014, 3:08:24 am