It looks like a change in BufferingResponseListener, which used to allocate a new buffer in onHeaders. It now will just keep accumulating responses!
A work around until this is fixed is to assign a new BufferingResponseListener for each request. I have created https://github.com/eclipse/jetty.project/issues/3178 On Sun, 2 Dec 2018 at 16:19, Alexander Farber <[email protected]> wrote: > Good afternoon, > > I run a custom WebSocketServlet for Jetty, which sends short text push > notifications (for an async mobile and desktop word game) to many platforms > (Facebook, Vk.com, Mail.ru, Ok.ru also Firebase and Amazon messaging) using > a Jetty HttpClient instance: > > public class MyServlet extends WebSocketServlet { > private final SslContextFactory mSslFactory = new SslContextFactory(); > private final HttpClient mHttpClient = new HttpClient(mSslFactory); > > @Override > public void init() throws ServletException { > super.init(); > > try { > mHttpClient.start(); > } catch (Exception ex) { > throw new ServletException(ex); > } > > mFcm = new Fcm(mHttpClient); // Firebase > mAdm = new Adm(mHttpClient); // Amazon > mApns = new Apns(mHttpClient); // Apple > mFacebook = new Facebook(mHttpClient); > mMailru = new Mailru(mHttpClient); > mOk = new Ok(mHttpClient); > mVk = new Vk(mHttpClient); > } > > This has worked very good for the past year (thank you!), but since I have > recently upgraded my WAR-file to use Jetty 9.4.14.v20181114 the trouble has > begun - > > public class Facebook { > private final static String APP_ID = "XXXXX"; > private final static String APP_SECRET = "XXXXX"; > private final static String MESSAGE_URL = " > https://graph.facebook.com/%s/notifications?" + > // the app access token is: "app id | app secret" > "access_token=%s%%7C%s" + > "&template=%s"; > > private final HttpClient mHttpClient; > > public Facebook(HttpClient httpClient) { > mHttpClient = httpClient; > } > > private final BufferingResponseListener mMessageListener = new > BufferingResponseListener() { > @Override > public void onComplete(Result result) { > if (!result.isSucceeded()) { > LOG.warn("facebook failure: {}", result.getFailure()); > return; > } > > try { > // THE jsonStr SUDDENLY CONTAINS PREVIOUS CONTENT! > String jsonStr = > getContentAsString(StandardCharsets.UTF_8); > LOG.info("facebook success: {}", jsonStr); > } catch (Exception ex) { > LOG.warn("facebook exception: ", ex); > } > } > }; > > public void postMessage(int uid, String sid, String body) { > String url = String.format(MESSAGE_URL, sid, APP_ID, APP_SECRET, > UrlEncoded.encodeString(body)); > mHttpClient.POST(url).send(mMessageListener); > } > } > > Suddenly the getContentAsString method called for successful HttpClient > invocations started to deliver the strings, which were fetched previously - > prepended to the the actual result string. > > What could it be please, is it some changed BufferingResponseListener > behaviour or maybe some non-obvious Java quirk? > > Best regards > Alex > > PS: I have also asked this question at > https://stackoverflow.com/questions/53581559/bufferingresponselistener-and-getcontentasstring-append-the-previously-fetched-c > _______________________________________________ > jetty-users mailing list > [email protected] > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://www.eclipse.org/mailman/listinfo/jetty-users -- Greg Wilkins <[email protected]> CTO http://webtide.com
_______________________________________________ jetty-users mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
