Jetty.project: Compatible JDK version for Jetty 9.4.7

Created on 23 Jan 2018  路  15Comments  路  Source: eclipse/jetty.project

Hi,

I have question, can i work with jdk 1.7 or jdk 1.8 while using Jetty 9.4.8 version?

Also, if i override "onRequestFailure" method for callback then in that case how can i get the Throwable object from it or error?

@Override
public Request onRequestFailure(FailureListener listener) {
//ToDo
}

Regards,
Pratibha

Question

All 15 comments

Jetty 9.4.x requires JDK 8 or later.

request.onRequestFailure((Request request, Throwable failure) -> {
    // Your code
});

Thanks a lot :+1:

Hello Simone,

I have few more questions:
1) Earlier we used to do like : bayeuxClient.setDebugEnabled(true);
But now this method is not available in bayeux-api-3.1.3
Could you please let me know if is there any alternate API for it?

2) ExecutorThreadPool pool = new ExecutorThreadPool(execSvc);
httpClient.setThreadPool(pool);
In the HttpClient there is no "setThreadPool" method is present so can i use like below:
httpClient.setExecutor(pool);

3) httpClient.setTimeout(timeout);
There is no setTimeout method is present now where timeout is the period in ms that an exchange will wait for a response from the server.
How can we do the same using latest HttpClient?

Regards,
Pratibha

  1. No alternate APIs. Just configure the logging system you are using.
  2. Correct
  3. Request.timeout(time, unit)

Hello Simone,

Earlier we used to do like : exchange.waitForDone();
But how can we do the same thing with "request" object?

Regards,
Pratibha

Thanks Simone.
If i have a map of subscribers and i want to abort the subscriber when someone removes it using below code:
subscriberRequests.remove("anyname").abort();

What throwable object should i pass in the abort method, can i do like below:
subscriberRequests.remove("anyname").abort(new Exception());

Yes you can pass whatever Throwable you like.

Could you let me know what is the alternative method for "void onException(Throwable x) {}" in jetty 9.

Response.CompleteListener is the interface you want to implement to be notified of results.
The Result parameter tells you whether the request/response cycle completed successfully or not, and if not what are the failures.

Hello Simone,

Thanks for your quick responses. Could you please answer the below queries too :
1) ClientTransport had "TIMEOUT_OPTION" constant earlier but now in latest cometD library it is not present, could you please let us know to set the timeout value for ClientTransport?
2) We used to do ise isDone() for ContentExchange to check whether this exchange has been done or not but how can we do the same in case of Jetty 9 for HttpRequest??
3) As per the doc : https://wiki.eclipse.org/Jetty/Tutorial/HttpClient
We used to set the timeout value for client using "client.setTimeout(30000)"
How can we set it now using jetty 9, i do not want to set it to Request, while i want to set it to httpClient Object?
Or now it is default that if we won't set it also it will wait for 30 seconds?

Thanks,
Pratibha

  1. CometD's ClientTransport did not have TIMEOUT_OPTION. That is a constant in AbstractServerTransport and it's still there.
  2. https://www.eclipse.org/jetty/documentation/current/http-client-api.html
  3. I think you are confusing the CometD timeout, which you want to set on the CometD server, with the Jetty HttpClient timeout which is the max time the request/response cycle may last before being aborted.

Hi Simone,

  1. We were using cometd-java-client-2.4.3.jar and there we had TIMEOUT_OPTION in the ClientTransport class but now its not there.
  2. Yes, i want to set the timeput value for JettyHttpClient.
    private HttpClient httpClient = new org.eclipse.jetty.client.HttpClient();
    now i want to set timeout for httpClient, like client.setTimeout(30000) using jetty 9 libarary. (not idle timeout)
  1. In CometD 2.4.3, ClientTransport.TIMEOUT_OPTION was a constant that was not used and hence has been removed in later releases. I'm guessing whatever you were setting with that option had no effect.
  2. The old HttpClient.timeout property was controlling the total time an exchange could last. In Jetty 9.x this has been replaced by Request.timeout().

This really helped ! Thanks a lot Simone.

Was this page helpful?
0 / 5 - 0 ratings