Java CompletableFuture + Resteasy -


i have been using java's completablefuture

completablefuture.runasync(() -> {//some code here }); 

when try use resteasy client inside block of code

javax.ws.rs.processingexception: unable find messagebodyreader of content-type application/json;charset=utf-8 , type class java.lang.string 

if use client outside of completablefuture works. resteasy code looks

        resteasyclient client = new resteasyclientbuilder().build();         client.register(new acceptencodingfilter("gzip"));         resteasywebtarget target = client.target(exampleurl);          target = target.queryparam("1", 1)                 .queryparam("2", "1")                 .queryparam("3", 3)                 .queryparam("4", 4)                 .queryparam("5", "5");          response response = target.request().get();         resultstring = response.readentity(string.class); 

i run resteasy code outisde of completablefuture "fix" problem understand why happens.

the resteasy code inside completablefuture looks this:

completablefuture.runasync(() -> {             try {                 resteasyclient client = new resteasyclientbuilder().build();                 client.register(new acceptencodingfilter("gzip"));                 resteasywebtarget target = client.target("http://test.com");                  target = target.queryparam("1", "1")                         .queryparam("2", "2")                         .queryparam("3", "3")                         .queryparam("4", "4")                         .queryparam("5", "5");                  response response = target.request().get();                 string resultstring = response.readentity(string.class);                  response.close();                 client.close();             } catch (exception e){                 e.printstacktrace();             }         }); 

the same code outside completablefuture works


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -