-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Migrate to jetty 12 with EE8 and bump java servlet to 4.0.1 #6783
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,17 +28,21 @@ | |
import java.util.regex.Pattern; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Handler; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.ee8.nested.AbstractHandler; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Response; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Slf4jRequestLogWriter; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.util.Callback; | ||
import org.junit.rules.ExternalResource; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Request; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.CustomRequestLog; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.ee8.nested.Request; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.RequestLog; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Server; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.ServerConnector; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Slf4jRequestLog; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.AbstractHandler; | ||
import org.apache.hbase.thirdparty.org.eclipse.jetty.util.RegexSet; | ||
|
||
/** | ||
|
@@ -115,13 +119,12 @@ protected void after() { | |
} | ||
|
||
private static RequestLog buildRequestLog() { | ||
final Slf4jRequestLog requestLog = new Slf4jRequestLog(); | ||
requestLog.setLoggerName(LOG.getName() + ".RequestLog"); | ||
requestLog.setExtended(true); | ||
return requestLog; | ||
Slf4jRequestLogWriter writer = new Slf4jRequestLogWriter(); | ||
writer.setLoggerName(LOG.getName() + ".RequestLog"); | ||
return new CustomRequestLog(writer, CustomRequestLog.EXTENDED_NCSA_FORMAT); | ||
} | ||
|
||
private static class MockHandler extends AbstractHandler { | ||
private static class MockHandler extends Handler.Abstract { | ||
|
||
private final ReadWriteLock responseMappingLock = new ReentrantReadWriteLock(); | ||
private final Map<String, BiConsumer<String, HttpServletResponse>> responseMapping = | ||
|
@@ -151,6 +154,32 @@ void clearRegistrations() { | |
} | ||
|
||
@Override | ||
public boolean handle(org.apache.hbase.thirdparty.org.eclipse.jetty.server.Request request, Response response, Callback callback) throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Don't think the changes made in this file are correct. Will check later! |
||
// TODO: TestRESTApiClusterManager is failing because of this line?? | ||
String target = request.getHttpURI().asString(); | ||
responseMappingLock.readLock().lock(); | ||
try { | ||
if (!regexSet.matches(target)) { | ||
response.setStatus(HttpServletResponse.SC_NOT_FOUND); | ||
callback.succeeded(); | ||
return true; | ||
} | ||
responseMapping.entrySet().stream() | ||
.filter(e -> Pattern.matches(e.getKey(), target)) | ||
.findAny() | ||
.map(Map.Entry::getValue) | ||
.orElseThrow(() -> noMatchFound(target)) | ||
.accept(target, (HttpServletResponse) response); | ||
callback.succeeded(); | ||
} catch (Exception e) { | ||
callback.failed(e); | ||
} finally { | ||
responseMappingLock.readLock().unlock(); | ||
} | ||
return true; | ||
} | ||
|
||
//@Override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah drop old version |
||
public void handle(final String target, final Request baseRequest, | ||
final HttpServletRequest request, final HttpServletResponse response) { | ||
responseMappingLock.readLock().lock(); | ||
|
@@ -168,8 +197,7 @@ public void handle(final String target, final Request baseRequest, | |
} | ||
|
||
private static RuntimeException noMatchFound(final String target) { | ||
return new RuntimeException( | ||
String.format("Target path '%s' matches no registered regex.", target)); | ||
return new RuntimeException(String.format("Target path '%s' matches no registered regex.", target)); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ public Response get(final @Context ServletContext context, final @Context UriInf | |
return Response.ok(rowModel).build(); | ||
} catch (IOException e) { | ||
servlet.getMetrics().incrementFailedGetRequests(1); | ||
throw new RuntimeException("Cannot retrieve list of namespaces."); | ||
throw new RuntimeException("Cannot retrieve list of namespaces.", e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. undo change |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,8 @@ allowed_expr+="|^PropertyList-1.0.dtd$" | |
# Shaded jetty resources | ||
allowed_expr+="|^about.html$" | ||
allowed_expr+="|^jetty-dir.css$" | ||
# Required by jetty 12 on ee8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to do this to include xsd file in javax/servlet/resources coming from
|
||
allowed_expr="(|^javax/$)" | ||
|
||
|
||
if [ -n "${allow_hadoop}" ]; then | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log folder is broken if we have a relative path, I suspect it is a jetty bug, may need to check more. Works fine for absolute path, otherwise fails similar to https://www.eclipse.org/lists/jetty-users/msg10296.html
So basically it works fine if log directory is "/a/b/c/logs" but fails with 404 if it is "/a/b/c/d/../logs".
Need to figure this out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jetty/jetty.project#12833 might help?