Skip to content

Commit

Permalink
Merged branch 'jetty-10.0.x' into 'jetty-10.0.x-250-http_connect_for_…
Browse files Browse the repository at this point in the history
…http2'.
  • Loading branch information
sbordet committed Jul 4, 2019
2 parents 911e2aa + 9902794 commit 01ce4eb
Show file tree
Hide file tree
Showing 303 changed files with 4,913 additions and 3,821 deletions.
10 changes: 8 additions & 2 deletions build-resources/src/main/resources/jetty-checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@
===========================================================================================
-->

<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="@checkstyle-disable-check : ([\w\|]+)"/>
<property name="onCommentFormat" value="@checkstyle-enable-check : ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>

<!-- Check abbreviations(consecutive capital letters) length in identifier name -->
<module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="true"/>
<property name="allowedAbbreviations" value="RFC, XML, URL, URI, HTTP, IP, ID, ISO8859, UTF8, CRLF, AWT"/>
<property name="allowedAbbreviations" value="ALPN, ASCII, AWT, CRLDP, CRLF, FCGI, GZIP, HTTP, HTTPS, ID, IP, ISO8859, JAAS, JDBC, JMXRMI, JNDI, JPMS, JSON, JSTL, LDAP, PROXY, RFC, SPNEGO, URI, URL, UTF8, XML"/>
</module>

<!-- Location of Annotations -->
Expand All @@ -51,7 +57,7 @@

<!-- Catch Parameter Name Format -->
<module name="CatchParameterName">
<property name="format" value="^(e|t|x|ex|[a-z][a-z][a-zA-Z0-9]+)$"/>
<property name="format" value="^(e|t|x|ex|th|e2|[a-z][a-z][a-zA-Z0-9]+)$"/>
</module>

<!-- Class Type Parameter Name Format -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void onComplete()
// We have results!

// Generate the response
String thumbs = generateThumbs(results);
final String thumbs = generateThumbs(results);

response.setContentType("text/html");
PrintWriter out = response.getWriter();
Expand Down Expand Up @@ -194,9 +194,10 @@ public void onComplete(Result result)
onComplete();
}

abstract void onComplete();

abstract void onAuctionFound(Map<String, String> details);

abstract void onComplete();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SerialRestServlet extends AbstractRestServlet
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
long start = System.nanoTime();
final long start = System.nanoTime();

String[] keywords = sanitize(request.getParameter(ITEMS_PARAM)).split(",");
Queue<Map<String, String>> results = new LinkedList<Map<String, String>>();
Expand All @@ -67,7 +67,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
}

// Generate the response
String thumbs = generateThumbs(results);
final String thumbs = generateThumbs(results);

response.setContentType("text/html");
PrintWriter out = response.getWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void main(String[] args) throws Exception
// Create a basic Jetty server object that will listen on port 8080. Note that if you set this to port 0
// then a randomly available port will be assigned that you can either look in the logs for the port,
// or programmatically obtain it for use in test cases.
Server server = new Server(8080);
final Server server = new Server(8080);

// Create the ResourceHandler. It is the object that will actually handle the request for a given file. It is
// a Jetty Handler object so it is suitable for chaining with other handlers as you will see in other examples.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class JarServer
{
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
final Server server = new Server(8080);

ServletContextHandler context = new ServletContextHandler();
Resource.setDefaultUseCaches(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ public static void main(String[] args) throws Exception

// === jetty-requestlog.xml ===
AsyncRequestLogWriter logWriter = new AsyncRequestLogWriter(jettyHome + "/logs/yyyy_mm_dd.request.log");
CustomRequestLog requestLog = new CustomRequestLog(logWriter, CustomRequestLog.EXTENDED_NCSA_FORMAT + " \"%C\"");
logWriter.setFilenameDateFormat("yyyy_MM_dd");
logWriter.setRetainDays(90);
logWriter.setTimeZone("GMT");
CustomRequestLog requestLog = new CustomRequestLog(logWriter, CustomRequestLog.EXTENDED_NCSA_FORMAT + " \"%C\"");
server.setRequestLog(requestLog);

// === jetty-lowresources.xml ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ManyContexts
{
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
final Server server = new Server(8080);

ContextHandler context = new ContextHandler("/");
context.setContextPath("/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ public void handle(String target,

public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
final Server server = new Server(8080);

// create the handlers
Handler param = new ParamHandler();
HandlerWrapper wrapper = new WelcomeWrapHandler();
Handler hello = new HelloHandler();
Handler dft = new DefaultHandler();
final Handler param = new ParamHandler();
final HandlerWrapper wrapper = new WelcomeWrapHandler();
final Handler hello = new HelloHandler();
final Handler dft = new DefaultHandler();

// configure request logging
File requestLogFile = File.createTempFile("demo", "log");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ServerWithAnnotations
public static final void main(String[] args) throws Exception
{
// Create the server
Server server = new Server(8080);
final Server server = new Server(8080);

// Create a WebApp
WebAppContext webapp = new WebAppContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void onMessage(Session session, String message)

public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
final Server server = new Server(8080);

HandlerList handlers = new HandlerList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,6 @@ protected void scanForAnnotations(WebAppContext context)
AnnotationParser parser = createAnnotationParser(javaPlatform);
_parserTasks = new ArrayList<ParserTask>();

long start = 0;

if (LOG.isDebugEnabled())
LOG.debug("Annotation scanning commencing: webxml={}, metadatacomplete={}, configurationDiscovered={}, multiThreaded={}, maxScanWait={}",
context.getServletContext().getEffectiveMajorVersion(),
Expand All @@ -447,7 +445,7 @@ protected void scanForAnnotations(WebAppContext context)
parseWebInfClasses(context, parser);
parseWebInfLib(context, parser);

start = System.nanoTime();
long start = System.nanoTime();

//execute scan, either effectively synchronously (1 thread only), or asynchronously (limited by number of processors available)
final Semaphore task_limit = (isUseMultiThreading(context) ? new Semaphore(ProcessorUtils.availableProcessors()) : new Semaphore(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,68 +694,6 @@ public void parse(Set<? extends Handler> handlers, List<String> classNames) thro
me.ifExceptionThrow();
}

/**
* Parse all classes in a directory
*
* @param handlers the set of handlers to look for classes in
* @param root the resource directory to look for classes
* @throws Exception if unable to parse
*/
protected void parseDir(Set<? extends Handler> handlers, Resource root) throws Exception
{
if (!root.isDirectory() || !root.exists() || root.getName().startsWith("."))
return;

if (LOG.isDebugEnabled())
LOG.debug("Scanning dir {}", root);

File rootFile = root.getFile();

MultiException me = new MultiException();
Collection<Resource> resources = root.getAllResources();
if (resources != null)
{
for (Resource r : resources)
{
if (r.isDirectory())
continue;

File file = r.getFile();
if (isValidClassFileName((file == null ? null : file.getName())))
{
Path classpath = rootFile.toPath().relativize(file.toPath());
String str = classpath.toString();
str = str.substring(0, str.lastIndexOf(".class"));
str = StringUtil.replace(str, File.separatorChar, '.');

try
{
if (LOG.isDebugEnabled())
LOG.debug("Scanning class {}", r);
addParsedClass(str, r);
try (InputStream is = r.getInputStream())
{
scanClass(handlers, Resource.newResource(file.getParentFile()), is);
}
}
catch (Exception ex)
{
if (LOG.isDebugEnabled())
LOG.debug("Error scanning file " + file, ex);
me.add(new RuntimeException("Error scanning file " + file, ex));
}
}
else
{
if (LOG.isDebugEnabled())
LOG.debug("Skipping scan on invalid file {}", file);
}
}
}

me.ifExceptionThrow();
}

/**
* Parse classes in the supplied uris.
*
Expand Down Expand Up @@ -837,6 +775,68 @@ public void parse(final Set<? extends Handler> handlers, Resource r) throws Exce
LOG.warn("Resource not scannable for classes: {}", r);
}

/**
* Parse all classes in a directory
*
* @param handlers the set of handlers to look for classes in
* @param root the resource directory to look for classes
* @throws Exception if unable to parse
*/
protected void parseDir(Set<? extends Handler> handlers, Resource root) throws Exception
{
if (!root.isDirectory() || !root.exists() || root.getName().startsWith("."))
return;

if (LOG.isDebugEnabled())
LOG.debug("Scanning dir {}", root);

File rootFile = root.getFile();

MultiException me = new MultiException();
Collection<Resource> resources = root.getAllResources();
if (resources != null)
{
for (Resource r : resources)
{
if (r.isDirectory())
continue;

File file = r.getFile();
if (isValidClassFileName((file == null ? null : file.getName())))
{
Path classpath = rootFile.toPath().relativize(file.toPath());
String str = classpath.toString();
str = str.substring(0, str.lastIndexOf(".class"));
str = StringUtil.replace(str, File.separatorChar, '.');

try
{
if (LOG.isDebugEnabled())
LOG.debug("Scanning class {}", r);
addParsedClass(str, r);
try (InputStream is = r.getInputStream())
{
scanClass(handlers, Resource.newResource(file.getParentFile()), is);
}
}
catch (Exception ex)
{
if (LOG.isDebugEnabled())
LOG.debug("Error scanning file " + file, ex);
me.add(new RuntimeException("Error scanning file " + file, ex));
}
}
else
{
if (LOG.isDebugEnabled())
LOG.debug("Skipping scan on invalid file {}", file);
}
}
}

me.ifExceptionThrow();
}

/**
* Parse a resource that is a jar file.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,6 @@ protected Class<?> findClass(String name) throws ClassNotFoundException
return super.findClass(name);
}

@Override
protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException
{
return super.definePackage(name, man, url);
}

@Override
public URL findResource(String name)
{
Expand Down Expand Up @@ -255,6 +249,12 @@ public Enumeration<URL> getResources(String name) throws IOException
return super.getResources(name);
}

@Override
protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException
{
return super.definePackage(name, man, url);
}

@Override
protected Package definePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion,
String implVendor, URL sealBase) throws IllegalArgumentException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,12 @@ private void startScanners() throws Exception
if (scanIntervalSecs <= 0)
return;

List<File> scanList = awc.getScanFiles();

TaskLog.log("Web application '" + awc + "': starting scanner at interval of " + scanIntervalSecs + " seconds.");
Scanner.Listener changeListener = new WebAppScannerListener(awc);
Scanner scanner = new Scanner();
scanner.setScanInterval(scanIntervalSecs);
scanner.addListener(changeListener);
scanner.setScanDirs(scanList);
scanner.setScanDirs(awc.getScanFiles());
scanner.setReportExistingFilesOnStartup(false);
scanner.start();
}
Expand Down

0 comments on commit 01ce4eb

Please sign in to comment.