Java BufferingResponseListener和getContentAsString追加先前获取的内容

Java BufferingResponseListener和getContentAsString追加先前获取的内容,java,servlets,jetty,embedded-jetty,jetty-9,Java,Servlets,Jetty,Embedded Jetty,Jetty 9,我为Jetty运行了一个定制的WebSocketServlet,它使用Jetty HttpClient实例向许多平台(Facebook、Vk.com、Mail.ru、Ok.ru以及Firebase和Amazon messaging)发送短文本推送通知(对于异步移动和): public class MyServlet extends WebSocketServlet { private final SslContextFactory mSslFactory = new SslContext

我为Jetty运行了一个定制的WebSocketServlet,它使用Jetty HttpClient实例向许多平台(Facebook、Vk.com、Mail.ru、Ok.ru以及Firebase和Amazon messaging)发送短文本推送通知(对于异步移动和):

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);
    }
这在过去的一年中效果非常好,但自从我最近将WAR文件升级为使用Jetty 9.4.14.v20181114后,麻烦就开始了-

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);
    }
}
突然,为成功调用HttpClient调用而调用的
getContentAsString
方法开始传递字符串,这些字符串是先前获取的,并在实际结果字符串的前面


请问这可能是什么,是一些改变的行为还是一些不明显的Java怪癖?

BufferingResponseListener
从未打算跨请求重用


只需为每个请求/响应分配一个新的
BufferingResponseListener

BufferingResponseListener
从来都不打算跨请求重用

只需为每个请求/响应分配一个新的
BufferingResponseListener