Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] After upgrading to 9.4.14.v20181114 getContentAsString() prepends previously fetched strings

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,,, 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);

    public void init() throws ServletException {

        try {
        } 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 = "" +
            // the app access token is: "app id | app secret"
            "access_token=%s%%7C%s" +

    private final HttpClient mHttpClient;

    public Facebook(HttpClient httpClient) {
        mHttpClient = httpClient;

    private final BufferingResponseListener mMessageListener = new BufferingResponseListener() {
        public void onComplete(Result result) {
            if (!result.isSucceeded()) {
                LOG.warn("facebook failure: {}", result.getFailure());

            try {
                String jsonStr = getContentAsString(StandardCharsets.UTF_8);
      "facebook success: {}", jsonStr);
            } catch (Exception ex) {
                LOG.warn("facebook exception: ", ex);

    public void postMessage(int uid, String sid, String body) {
        String url = "" sid, APP_ID, APP_SECRET, UrlEncoded.encodeString(body));

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

Back to the top