svn commit: r1352788 - /tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java

2012-06-22 Thread markt
Author: markt
Date: Fri Jun 22 07:39:28 2012
New Revision: 1352788

URL: http://svn.apache.org/viewvc?rev=1352788&view=rev
Log:
As per clarification from Servlet EG, version declared in web.xml does not 
control annotation scanning. I don't like it but the EG was very clear this was 
the intended behaviour.

Modified:
tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java

Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1352788&r1=1352787&r2=1352788&view=diff
==
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Fri Jun 22 
07:39:28 2012
@@ -1121,13 +1121,24 @@ public class ContextConfig implements Li
  * web.xml file.
  */
 protected void webConfig() {
-/* Anything and everything can override the global and host defaults.
+/*
+ * Anything and everything can override the global and host defaults.
  * This is implemented in two parts
  * - Handle as a web fragment that gets added after everything else so
  *   everything else takes priority
  * - Mark Servlets as overridable so SCI configuration can replace
  *   configuration from the defaults
  */
+
+/*
+ * The rules for annotation scanning are not as clear-cut as one might
+ * think. Tomcat implements the following process:
+ * - As per SRV.1.6.2, Tomcat will scan for annotations regardless of
+ *   which Servlet spec version is declared in web.xml. The EG has
+ *   confirmed this is the expected behaviour.
+ * - This is not yet complete. Further clarifications (and possible 
code
+ *   changes to follow).
+ */
 Set defaults = new HashSet();
 defaults.add(getDefaultWebXmlFragment());
 
@@ -1137,161 +1148,154 @@ public class ContextConfig implements Li
 InputSource contextWebXml = getContextWebXmlSource();
 parseWebXml(contextWebXml, webXml, false);
 
-if (webXml.getMajorVersion() >= 3) {
-ServletContext sContext = context.getServletContext();
+ServletContext sContext = context.getServletContext();
+
+// Ordering is important here
 
-// Ordering is important here
+// Step 1. Identify all the JARs packaged with the application
+// If the JARs have a web-fragment.xml it will be parsed at this
+// point.
+Map fragments = processJarsForWebFragments();
+
+// Only need to process fragments and annotations if metadata is
+// not complete
+Set orderedFragments = null;
+if  (!webXml.isMetadataComplete()) {
+// Step 2. Order the fragments.
+orderedFragments = WebXml.orderWebFragments(webXml, fragments);
+
+// Step 3. Look for ServletContainerInitializer implementations
+if (ok) {
+processServletContainerInitializers(orderedFragments);
+}
 
-// Step 1. Identify all the JARs packaged with the application
-// If the JARs have a web-fragment.xml it will be parsed at this
-// point.
-Map fragments = processJarsForWebFragments();
-
-// Only need to process fragments and annotations if metadata is
-// not complete
-Set orderedFragments = null;
-if  (!webXml.isMetadataComplete()) {
-// Step 2. Order the fragments.
-orderedFragments = WebXml.orderWebFragments(webXml, fragments);
-
-// Step 3. Look for ServletContainerInitializer implementations
-if (ok) {
-processServletContainerInitializers(orderedFragments);
-}
-
-// Step 4. Process /WEB-INF/classes for annotations
-// This will add any matching classes to the typeInitializerMap
-if (ok) {
-// Hack required by Eclipse's "serve modules without
-// publishing" feature since this backs WEB-INF/classes by
-// multiple locations rather than one.
-NamingEnumeration listBindings = null;
+// Step 4. Process /WEB-INF/classes for annotations
+// This will add any matching classes to the typeInitializerMap
+if (ok) {
+// Hack required by Eclipse's "serve modules without
+// publishing" feature since this backs WEB-INF/classes by
+// multiple locations rather than one.
+NamingEnumeration listBindings = null;
+try {
 try {
-try {
-listBindings = conte

svn commit: r1352799 - in /tomcat/trunk: java/org/apache/catalina/startup/ContextConfig.java test/org/apache/catalina/startup/TestContextConfigAnnotation.java

2012-06-22 Thread markt
Author: markt
Date: Fri Jun 22 08:25:53 2012
New Revision: 1352799

URL: http://svn.apache.org/viewvc?rev=1352799&view=rev
Log:
metadata-complete does not control the processing of 
ServletContainerInitializers

Modified:
tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java

tomcat/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java

Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1352799&r1=1352798&r2=1352799&view=diff
==
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Fri Jun 22 
08:25:53 2012
@@ -1136,8 +1136,15 @@ public class ContextConfig implements Li
  * - As per SRV.1.6.2, Tomcat will scan for annotations regardless of
  *   which Servlet spec version is declared in web.xml. The EG has
  *   confirmed this is the expected behaviour.
- * - This is not yet complete. Further clarifications (and possible 
code
- *   changes to follow).
+ * - As per http://java.net/jira/browse/SERVLET_SPEC-36, if the main
+ *   web.xml is marked as metadata-complete, JARs are still processed
+ *   for SCIs.
+ * - TBD. If metadata-complete=true and an absolute ordering is
+ *   specified, are JARs excluded from the ordering also excluded from
+ *   the SCI processing? Current assumption is that they are.
+ * - If an SCI has a @HandlesType annotation then all classes (except
+ *   those in JARs excluded from an absolute ordering) need to be
+ *   scanned to check if they match.
  */
 Set defaults = new HashSet();
 defaults.add(getDefaultWebXmlFragment());
@@ -1157,20 +1164,17 @@ public class ContextConfig implements Li
 // point.
 Map fragments = processJarsForWebFragments();
 
-// Only need to process fragments and annotations if metadata is
-// not complete
+// Step 2. Order the fragments.
 Set orderedFragments = null;
-if  (!webXml.isMetadataComplete()) {
-// Step 2. Order the fragments.
-orderedFragments = WebXml.orderWebFragments(webXml, fragments);
+orderedFragments = WebXml.orderWebFragments(webXml, fragments);
 
-// Step 3. Look for ServletContainerInitializer implementations
-if (ok) {
-processServletContainerInitializers(orderedFragments);
-}
+// Step 3. Look for ServletContainerInitializer implementations
+if (ok) {
+processServletContainerInitializers(orderedFragments);
+}
 
+if  (!webXml.isMetadataComplete() || typeInitializerMap.size() > 0) {
 // Step 4. Process /WEB-INF/classes for annotations
-// This will add any matching classes to the typeInitializerMap
 if (ok) {
 // Hack required by Eclipse's "serve modules without
 // publishing" feature since this backs WEB-INF/classes by
@@ -1189,13 +1193,15 @@ public class ContextConfig implements Li
 if (binding.getObject() instanceof FileDirContext) {
 File webInfClassDir = new File(
 ((FileDirContext) 
binding.getObject()).getDocBase());
-processAnnotationsFile(webInfClassDir, webXml);
+processAnnotationsFile(webInfClassDir, webXml,
+webXml.isMetadataComplete());
 } else {
 String resource =
 "/WEB-INF/classes/" + binding.getName();
 try {
 URL url = sContext.getResource(resource);
-processAnnotationsUrl(url, webXml);
+processAnnotationsUrl(url, webXml,
+webXml.isMetadataComplete());
 } catch (MalformedURLException e) {
 log.error(sm.getString(
 "contextConfig.webinfClassesUrl",
@@ -1212,14 +1218,16 @@ public class ContextConfig implements Li
 
 // Step 5. Process JARs for annotations - only need to process
 // those fragments we are going to use
-// This will add any matching classes to the typeInitializerMap
 if (ok) {
-processAnnotations(orderedFragments);
+processAnnotations(
+orderedFragments, webXml.isMetadataComplete());
 }
 
 // Cache, if used, is no longer required so clear it
 

svn commit: r1352802 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/startup/ContextConfig.java webapps/docs/changelog.xml

2012-06-22 Thread markt
Author: markt
Date: Fri Jun 22 08:44:24 2012
New Revision: 1352802

URL: http://svn.apache.org/viewvc?rev=1352802&view=rev
Log:
As per clarification from Servlet EG, version declared in web.xml does not 
control annotation scanning. I don't like it but the EG was very clear this was 
the intended behaviour.

Modified:
tomcat/tc7.0.x/trunk/   (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
--
  Merged /tomcat/trunk:r1352788

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1352802&r1=1352801&r2=1352802&view=diff
==
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java 
Fri Jun 22 08:44:24 2012
@@ -1195,13 +1195,24 @@ public class ContextConfig implements Li
  * web.xml file.
  */
 protected void webConfig() {
-/* Anything and everything can override the global and host defaults.
+/*
+ * Anything and everything can override the global and host defaults.
  * This is implemented in two parts
  * - Handle as a web fragment that gets added after everything else so
  *   everything else takes priority
  * - Mark Servlets as overridable so SCI configuration can replace
  *   configuration from the defaults
  */ 
+
+/*
+ * The rules for annotation scanning are not as clear-cut as one might
+ * think. Tomcat implements the following process:
+ * - As per SRV.1.6.2, Tomcat will scan for annotations regardless of
+ *   which Servlet spec version is declared in web.xml. The EG has
+ *   confirmed this is the expected behaviour.
+ * - This is not yet complete. Further clarifications (and possible 
code
+ *   changes to follow).
+ */
 Set defaults = new HashSet();
 defaults.add(getDefaultWebXmlFragment());
 
@@ -1211,161 +1222,154 @@ public class ContextConfig implements Li
 InputSource contextWebXml = getContextWebXmlSource();
 parseWebXml(contextWebXml, webXml, false);
 
-if (webXml.getMajorVersion() >= 3) {
-ServletContext sContext = context.getServletContext();
+ServletContext sContext = context.getServletContext();
 
-// Ordering is important here
+// Ordering is important here
 
-// Step 1. Identify all the JARs packaged with the application
-// If the JARs have a web-fragment.xml it will be parsed at this
-// point.
-Map fragments = processJarsForWebFragments();
-
-// Only need to process fragments and annotations if metadata is
-// not complete
-Set orderedFragments = null;
-if  (!webXml.isMetadataComplete()) {
-// Step 2. Order the fragments.
-orderedFragments = WebXml.orderWebFragments(webXml, fragments);
+// Step 1. Identify all the JARs packaged with the application
+// If the JARs have a web-fragment.xml it will be parsed at this
+// point.
+Map fragments = processJarsForWebFragments();
+
+// Only need to process fragments and annotations if metadata is
+// not complete
+Set orderedFragments = null;
+if  (!webXml.isMetadataComplete()) {
+// Step 2. Order the fragments.
+orderedFragments = WebXml.orderWebFragments(webXml, fragments);
 
-// Step 3. Look for ServletContainerInitializer implementations
-if (ok) {
-processServletContainerInitializers(orderedFragments);
-}
+// Step 3. Look for ServletContainerInitializer implementations
+if (ok) {
+processServletContainerInitializers(orderedFragments);
+}
 
-// Step 4. Process /WEB-INF/classes for annotations
-// This will add any matching classes to the typeInitializerMap
-if (ok) {
-// Hack required by Eclipse's "serve modules without
-// publishing" feature since this backs WEB-INF/classes by
-// multiple locations rather than one.
-NamingEnumeration listBindings = null;
+// Step 4. Process /WEB-INF/classes for annotations
+// This will add any matching classes to the typeInitializerMap
+if (ok) {
+// Hack required by Eclipse's "serve modules without
+// p

svn commit: r1352803 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/startup/ContextConfig.java test/org/apache/catalina/startup/TestContextConfigAnnotation.java webapps/docs/changelog.xml

2012-06-22 Thread markt
Author: markt
Date: Fri Jun 22 08:46:55 2012
New Revision: 1352803

URL: http://svn.apache.org/viewvc?rev=1352803&view=rev
Log:
metadata-complete does not control the processing of 
ServletContainerInitializers

Modified:
tomcat/tc7.0.x/trunk/   (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java

tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
--
  Merged /tomcat/trunk:r1352799

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1352803&r1=1352802&r2=1352803&view=diff
==
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java 
Fri Jun 22 08:46:55 2012
@@ -1210,8 +1210,15 @@ public class ContextConfig implements Li
  * - As per SRV.1.6.2, Tomcat will scan for annotations regardless of
  *   which Servlet spec version is declared in web.xml. The EG has
  *   confirmed this is the expected behaviour.
- * - This is not yet complete. Further clarifications (and possible 
code
- *   changes to follow).
+ * - As per http://java.net/jira/browse/SERVLET_SPEC-36, if the main
+ *   web.xml is marked as metadata-complete, JARs are still processed
+ *   for SCIs.
+ * - TBD. If metadata-complete=true and an absolute ordering is
+ *   specified, are JARs excluded from the ordering also excluded from
+ *   the SCI processing? Current assumption is that they are.
+ * - If an SCI has a @HandlesType annotation then all classes (except
+ *   those in JARs excluded from an absolute ordering) need to be
+ *   scanned to check if they match.
  */
 Set defaults = new HashSet();
 defaults.add(getDefaultWebXmlFragment());
@@ -1231,20 +1238,17 @@ public class ContextConfig implements Li
 // point.
 Map fragments = processJarsForWebFragments();
 
-// Only need to process fragments and annotations if metadata is
-// not complete
+// Step 2. Order the fragments.
 Set orderedFragments = null;
-if  (!webXml.isMetadataComplete()) {
-// Step 2. Order the fragments.
-orderedFragments = WebXml.orderWebFragments(webXml, fragments);
+orderedFragments = WebXml.orderWebFragments(webXml, fragments);
 
-// Step 3. Look for ServletContainerInitializer implementations
-if (ok) {
-processServletContainerInitializers(orderedFragments);
-}
+// Step 3. Look for ServletContainerInitializer implementations
+if (ok) {
+processServletContainerInitializers(orderedFragments);
+}
 
+if  (!webXml.isMetadataComplete() || typeInitializerMap.size() > 0) {
 // Step 4. Process /WEB-INF/classes for annotations
-// This will add any matching classes to the typeInitializerMap
 if (ok) {
 // Hack required by Eclipse's "serve modules without
 // publishing" feature since this backs WEB-INF/classes by
@@ -1263,13 +1267,15 @@ public class ContextConfig implements Li
 if (binding.getObject() instanceof FileDirContext) {
 File webInfClassDir = new File(
 ((FileDirContext) 
binding.getObject()).getDocBase());
-processAnnotationsFile(webInfClassDir, webXml);
+processAnnotationsFile(webInfClassDir, webXml,
+webXml.isMetadataComplete());
 } else {
 String resource =
 "/WEB-INF/classes/" + binding.getName();
 try {
 URL url = sContext.getResource(resource);
-processAnnotationsUrl(url, webXml);
+processAnnotationsUrl(url, webXml,
+webXml.isMetadataComplete());
 } catch (MalformedURLException e) {
 log.error(sm.getString(
 "contextConfig.webinfClassesUrl",
@@ -1286,14 +1292,16 @@ public class ContextConfig implements Li
 
 // Step 5. Process JARs for annotations - only need to process
 // those fragments we are going to use
-// This will add any matching classes to

[Bug 53454] New: Default doHead implementation overrides 'Content-Length' header

2012-06-22 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=53454

  Priority: P2
Bug ID: 53454
  Assignee: dev@tomcat.apache.org
   Summary: Default doHead implementation overrides
'Content-Length' header
  Severity: normal
Classification: Unclassified
  Reporter: n.s.skvort...@gmail.com
  Hardware: PC
Status: NEW
   Version: 6.0.29
 Component: Servlet & JSP API
   Product: Tomcat 6

Created attachment 28985
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28985&action=edit
Sampe app with sources

If a client extends HttpServlet and desides to override doGet() method,
resulting servlet can fail to correctly handle HEAD requests.

This will happen, if client chooses to set Content-Length manually (e.g., to
allow content bigger than 2Gb):

  resp.setHeader("Content-Length", String.valueOf(12345678900L));

and only writes actual content if it is a GET request (e.g., because it is
costly operation).

In such conditions, GET request will have correct "Content-Length" header, but
HEAD requset will have "Content-Length" header with value 0. 

Sample project with sources is attached

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 53456] New: Minor tweaks to config/http.html

2012-06-22 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=53456

  Priority: P2
Bug ID: 53456
  Assignee: dev@tomcat.apache.org
   Summary: Minor tweaks to config/http.html
  Severity: normal
Classification: Unclassified
OS: Windows XP
  Reporter: s...@apache.org
  Hardware: PC
Status: NEW
   Version: unspecified
 Component: Documentation
   Product: Tomcat 7

Created attachment 28986
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28986&action=edit
Patch to fix doc as per description

The attached patch makes some minor changes to the http.html page.

This page is now quite long, and it can be hard distinguishing between the
attributes that apply to BIO-NIO compared with APR/Native, so I added
subsection headers around the attributes.

I also moved the reference to the SSL Howto to the beginning, because it
applies to both.

Also made a couple of other minor edits. 

e.g. in the table at the bottom:

Java Nio Blocking Connector => Java Non Blocking Connector

It builds OK for me in WinXP.

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[jira] [Created] (MTOMCAT-165) http status 401 reported as success

2012-06-22 Thread Tim Pizey (JIRA)
Tim Pizey created MTOMCAT-165:
-

 Summary: http status 401 reported as success
 Key: MTOMCAT-165
 URL: https://issues.apache.org/jira/browse/MTOMCAT-165
 Project: Apache Tomcat Maven Plugin
  Issue Type: Bug
Affects Versions: 2.0-beta-1
 Environment: Ubuntu/openjdk6
Reporter: Tim Pizey


If tomcat.username and tomcat.password empty then the 401 response is rendered 
as INFO and SUCCESS is reported.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira



-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org