Open rorytorneymf opened 1 week ago
First off, have you looked at the migration guide yet? https://jetty.org/docs/jetty/12/programming-guide/migration/11-to-12.html
First off, have you looked at the migration guide yet? https://jetty.org/docs/jetty/12/programming-guide/migration/11-to-12.html
Yes thanks, I have went through the migration guide. I don't see any mention of where the above classes/methods have been moved to, or what they should be replaced by.
@rorytorneymf you didn't say which ee version you are moving to? ee8, ee9, ee10 ? This is critical to know and why we put it in the issue template. Some classes are in core jetty modules (eg org.eclipse.jetty.jetty-security jar) but others needed to be adapted to specific ee versions so can be found in ee specific jars.
@rorytorneymf you didn't say which ee version you are moving to? ee8, ee9, ee10 ? This is critical to know and why we put it in the issue template. Some classes are in core jetty modules (eg org.eclipse.jetty.jetty-security jar) but others needed to be adapted to specific ee versions so can be found in ee specific jars.
Thanks, apologies, I am using EE10. I updated the table above with some classes/methods that I think are the replacements I am looking for, there were a few remaining though I have not found yet.
@rorytorneymf jetty 12 has disentangled core apis from the servlet spec apis, whereas in previous versions of jetty there were co-mingled (as your list of apis shows). This separation allows jetty greater ease of implementing new servlet specs as a layer on top of the core. This also means you need to pick your paradigm: go with just jetty core apis or go with the servlet spec apis. So a lot of the answers to your api equivalence questions depend on which approach you're going to go with.
Also note that Requests are now immutable, and we use wrapping to vary the information we return rather than mutate the existing request so you're not going to find these extra jetty setters on any of the Request classes (core or servlet api).
BTW any class you see that has "internal" in the package name is not intended for external use, and are not exposed for osgi nor for jpms.
I would take a look at the unit tests in each of the org.eclipse.jetty.server
and org.eclipse.jetty.session
and org.eclipse.jetty.security
modules to get a sense of how they may apply to your application. There is some documentation available on them as well, but I admit it's pretty patchy right now.
Thanks, for wrapping the request to modify the Content-Type header, replace the form params, and set the method, is this the general idea?
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.server.FormFields;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.Fields;
import org.eclipse.jetty.util.MultiMap;
import java.util.ListIterator;
import java.util.concurrent.CompletableFuture;
/**
* The org.eclipse.jetty.server.Request object in Jetty 12 no longer has methods to set the method, content type, and parameters like
* Jetty 11 did, so this class is a way achieving the same behaviour in Jetty 12.
*/
public final class RestoredRequest extends Request.Wrapper
{
private String method;
private final HttpFields fields;
public WrappedRequest(
final Request request,
final String method,
final String contentType,
final MultiMap<String> formMap)
{
super(request);
this.method = method;
this.fields = setContentType(request, contentType);
setFormFields(request, formMap);
}
private HttpFields setContentType(final Request request, final String contentType)
{
final HttpFields fields = request.getHeaders();
final HttpFields.Mutable newFields = HttpFields.build(fields);
for (ListIterator<HttpField> i = newFields.listIterator(); i.hasNext(); ) {
final HttpField field = i.next();
final HttpHeader header = field.getHeader();
if (header == null) {
continue;
}
if (header.equals(HttpHeader.CONTENT_TYPE)) {
i.set(new HttpField(HttpHeader.CONTENT_TYPE, contentType));
}
}
return newFields.asImmutable();
}
private void setFormFields(final Request request, final MultiMap<String> formMap)
{
final Fields fields = new Fields(formMap);
FormFields.set(request, CompletableFuture.completedFuture(fields));
}
@Override
public String getMethod()
{
return this.method;
}
@Override
public HttpFields getHeaders()
{
return this.fields;
}
}
Hello, I am updating jetty from
11.0.24
to12.0.14
and am using EE 10.I cannot find the following classes/methods, does anyone know if these classes has been moved to different packages, or have been replaced with something else? I think I found a few replacements but not sure:
Many thanks!