cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "iris ding (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CXF-6001) CXF fails to find a correct MessageBodyWritter for List<E> if resource is defined under async way
Date Sat, 13 Sep 2014 07:25:33 GMT
iris ding created CXF-6001:
------------------------------

             Summary: CXF fails to find a correct MessageBodyWritter for List<E> if
resource is defined under async way
                 Key: CXF-6001
                 URL: https://issues.apache.org/jira/browse/CXF-6001
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 3.0.1
            Reporter: iris ding



CXF fails to find a correct MessageBodyWritter for List<E> if Resource is defined under
async way, 
see below example, I have two method defien, the **/collecitons can be returned successfully
however
we will get an error for the **/asyncCollections.

@Path("/bookstore")
public class BookContinuationStore {

   private final List<Book> bookList = new ArrayList<Book>();

    public BookContinuationStore() {
        init();
    }

    @GET
    @Path("/collections")
    @Produces({ "application/xml", "application/json" })
    public List<Book> getBookCollection() throws Exception {
        return bookList;
    }

   

    @GET
    @Path("/asyncCollections")
    @Produces({ "application/xml", "application/json" })
    public void getBookCollection(@Suspended AsyncResponse response) throws Exception {
        resumeSuspendedBookList(response);
    }

    

    private void resumeSuspendedBookList(final AsyncResponse response) {

        executor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException ex) {
                    // ignore
                }
                response.resume(bookList);

            }
        });

    }


    private void init() {
        Book b1 = new Book("Iris1", 1);
        Book b2 = new Book("Iris2", 2);
        bookList.add(b1);
        bookList.add(b2);
    }

    
}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message