Skip to content

Commit

Permalink
Partial cleanup in xml package
Browse files Browse the repository at this point in the history
- Maybe (!!!) fixes race condition in GlassFish. Since this change the TCK
  jstl/spec/xml/xmlcore/types passed several times without failing.
  However, I am still not convinced, because the failure wasn't well
  reproducible and also the cause wasn't clearly visible.
- XPathUtil doesn't set system properties any more (see XPathUtil).
- DocumentBuilderFactory should not be used as a constant,
  it is not thread-safe. Despite in this case I doubt it could cause issue,
  I cannot be sure.
- Deleted unused methods
- JSTLNodeList moved to own file
- Deleted copy pasted javadocs from old versions
- More should be done, but let's start with this.


Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 26, 2022
1 parent e1de679 commit 8cf656a
Show file tree
Hide file tree
Showing 6 changed files with 518 additions and 810 deletions.
185 changes: 84 additions & 101 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
<parent>
<groupId>org.eclipse.ee4j</groupId>
<artifactId>project</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
<relativePath/>
</parent>

<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Jakarta Standard Tag Library Implementation</name>
Expand Down Expand Up @@ -106,7 +106,8 @@
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>xalan</groupId>
Expand Down Expand Up @@ -179,7 +180,7 @@
</execution>
</executions>
</plugin>

<!-- Restricts the Java version to 11 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -190,13 +191,6 @@
</configuration>
</plugin>

<!-- Execute unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M6</version>
</plugin>

<!-- Creates the OSGi MANIFEST.MF file -->
<plugin>
<groupId>org.apache.felix</groupId>
Expand Down Expand Up @@ -230,17 +224,15 @@
org.glassfish.jstl.integration
</Export-Package>
<Import-Package>
!org.apache.xpath,
!org.apache.xpath.objects,
!org.apache.xpath.jaxp,
!org.apache.bcel,
!org.apache.regexp,
!org.apache.xml,
!org.apache.xml.dtm,
!org.apache.xml.utils,
!org.apache.xalan,
!org.apache.xalan.res,
!org.apache.xpath,
!org.apache.xpath.jaxp,
!org.apache.xpath.objects,
!org.apache.xpath.res,
!org.apache.regexp,
!org.apache.bcel,
!java_cup.runtime,
!trax,
org.xml.sax.ext,
Expand All @@ -258,7 +250,7 @@
</execution>
</executions>
</plugin>

<!-- Adds the manifest file created by the org.apache.felix:maven-bundle-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -279,7 +271,7 @@
</archive>
</configuration>
</plugin>

<!-- Post process the jar we created by including XALAN and moving packages -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -340,28 +332,22 @@
</execution>
</executions>
</plugin>

<!-- Creates the source jar -->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<includePom>true</includePom>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<!--
Create Javadoc for IMPL jar
-->

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
Expand All @@ -382,7 +368,6 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<configuration>
Expand Down Expand Up @@ -421,76 +406,74 @@ Copyright &#169; 2019, ${current.year} Eclipse Foundation. All rights reserved.
</plugin>
</plugins>
</build>

<profiles>
<!--
Generation of TLDDocs typically fails with the following when excuted directly from the impl module:

[WARNING]
Could not transfer metadata org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/):

transfer failed for http://0.0.0.0/org/glassfish/web/tagsdoc/1.0-SNAPSHOT/maven-metadata.xml

[WARNING]
org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xmlfailed to transfer from http://0.0.0.0/ during a previous attempt.
This failure was cached in the local repository and resolution will not be reattempted until the update interval of
maven-default-http-blocker has elapsed or updates are forced.


Original error:

Could not transfer metadata org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/):

transfer failed for http://0.0.0.0/org/glassfish/web/tagsdoc/1.0-SNAPSHOT/maven-metadata.xml


-->
<profile>
<id>tlddocs</id>
<build>
<plugins>
<!-- Generate the TLD docs -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>generateTldDoc</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>false</includeProjectDependencies>
<mainClass>com.sun.tlddoc.TLDDoc</mainClass>
<arguments>
<argument>-doctitle</argument>
<argument>Jakarta Tags doc</argument>
<argument>-windowtitle</argument>
<argument>Jakarta Tags Doc</argument>
<argument>-d</argument>
<argument>${project.build.directory}/tlddoc</argument>
<argument>${project.basedir}/src/main/resources/META-INF/sql.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/x.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/fmt.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/c.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/fn.tld</argument>
</arguments>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>tagsdoc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<profiles>
<!--
Generation of TLDDocs typically fails with the following when excuted directly from the impl module:

[WARNING]
Could not transfer metadata org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/):

transfer failed for http://0.0.0.0/org/glassfish/web/tagsdoc/1.0-SNAPSHOT/maven-metadata.xml

[WARNING]
org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xmlfailed to transfer from http://0.0.0.0/ during a previous attempt.
This failure was cached in the local repository and resolution will not be reattempted until the update interval of
maven-default-http-blocker has elapsed or updates are forced.


Original error:

Could not transfer metadata org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/):

transfer failed for http://0.0.0.0/org/glassfish/web/tagsdoc/1.0-SNAPSHOT/maven-metadata.xml
-->
<profile>
<id>tlddocs</id>
<build>
<plugins>
<!-- Generate the TLD docs -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>generateTldDoc</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>false</includeProjectDependencies>
<mainClass>com.sun.tlddoc.TLDDoc</mainClass>
<arguments>
<argument>-doctitle</argument>
<argument>Jakarta Tags doc</argument>
<argument>-windowtitle</argument>
<argument>Jakarta Tags Doc</argument>
<argument>-d</argument>
<argument>${project.build.directory}/tlddoc</argument>
<argument>${project.basedir}/src/main/resources/META-INF/sql.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/x.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/fmt.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/c.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/fn.tld</argument>
</arguments>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>tagsdoc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.apache.taglibs.standard.tag.common.xml;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

/**
* @author David Matejcek
*/
public class DocumentBuilderProvider {

/**
* Creates a namespace-aware {@link DocumentBuilder} with disabled validation.
* <p>
* Note that {@link DocumentBuilder} instances are not thread-safe and their implementation can
* be chosen as described in {@link DocumentBuilderFactory} documentation.
*
* @return new {@link DocumentBuilder} instance.
*/
static DocumentBuilder createDocumentBuilder() {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(false);
return dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// this should never happen with a well-behaving JAXP implementation.
throw new Error(e);
}
}
}
Loading

0 comments on commit 8cf656a

Please sign in to comment.