[jira] Commented: (WICKET-3163) support building wicket offline by resolving DTD references locally
[ https://issues.apache.org/jira/browse/WICKET-3163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12931678#action_12931678 ] Peter Ertl commented on WICKET-3163: Seems like this improvement was really necessary as we get timeouts on hudson quite often, e.g.: https://hudson.apache.org/hudson/job/Apache%20Wicket%201.5.x/507/org.apache.wicket$wicket Should be solved now :-) support building wicket offline by resolving DTD references locally --- Key: WICKET-3163 URL: https://issues.apache.org/jira/browse/WICKET-3163 Project: Wicket Issue Type: Improvement Components: wicket Affects Versions: 1.5-M3 Reporter: Peter Ertl Assignee: Peter Ertl Fix For: 1.5-M4 Attachments: local-lookup.patch, LocalEntityResolver.java Wicket developers, please give me some comment on this: Some wicket test cases parse XML which refers to an external DTD. An example is org.apache.wicket.protocol.http.WicketFilterTest It refers to org.apache.wicket.util.file.WebXmlFile will will parse a custom web.xml. The web.xml will make the parser to look up http://java.sun.com/dtd/web-app_2_3.dtd When building wicket offline this will cause a network error and the test will fail. I would like to add org.apache.wicket.util.xml.LocalEntityResolver which may contain a set of local entitites to avoid hitting the network. As wicket 1.5 is getting close to final I would like to get some feedback first before putting that into trunk... By adding this like to WebXmlFile network lookup would be avoided. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); builder.setEntityResolver(LocalEntityResolver.getDefault()); // no more network lookups Document document = builder.parse(is); package org.apache.wicket.util.xml; import org.apache.wicket.util.lang.Args; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import javax.servlet.Filter; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; /** * entity resolver that tries to locate a document type definition (DTD) using a set of custom entity resolvers * * @author pete */ public class LocalEntityResolver implements EntityResolver { private final MapEntityKey, EntityLocator entities = new HashMapEntityKey, EntityLocator(3); public static LocalEntityResolver getDefault() { LocalEntityResolver resolver = new LocalEntityResolver(); // // look up servlet 2.3 web.xml DTD right from inside servlet-api.jar // resolver.put(new EntityKey(-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN, http://java.sun.com/dtd/web-app_2_3.dtd;), new ServletApiEntityLocator(web-app_2_3.dtd)); return resolver; } public void put(EntityKey key, EntityLocator locator) { Args.notNull(key, key); Args.notNull(locator, locator); entities.put(key, locator); } public InputSource resolveEntity(String id, String url) throws SAXException, IOException { for (Map.EntryEntityKey, EntityLocator entry : entities.entrySet()) if (entry.getKey().id.equals(id) || entry.getKey().url.equals(url)) return entry.getValue().locateInputSource(); return null; } public static class EntityKey { private final String id; private final String url; private EntityKey(String id, String url) { Args.notEmpty(id, id); Args.notEmpty(url, url); this.id = id; this.url = url; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof EntityKey)) return false; EntityKey key = (EntityKey) o; if (!id.equals(key.id)) return false; return url.equals(key.url); } @Override public int hashCode() { int result = id.hashCode(); result = 31 * result + url.hashCode(); return result; }
[jira] Commented: (WICKET-3163) support building wicket offline by resolving DTD references locally
[ https://issues.apache.org/jira/browse/WICKET-3163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12931682#action_12931682 ] Hudson commented on WICKET-3163: Integrated in Apache Wicket 1.5.x #508 (See [https://hudson.apache.org/hudson/job/Apache%20Wicket%201.5.x/508/]) WICKET-3163: support offline builds of wicket (avoid hitting java.sun.com for lookup of web.xml 2.3 DTD) support building wicket offline by resolving DTD references locally --- Key: WICKET-3163 URL: https://issues.apache.org/jira/browse/WICKET-3163 Project: Wicket Issue Type: Improvement Components: wicket Affects Versions: 1.5-M3 Reporter: Peter Ertl Assignee: Peter Ertl Fix For: 1.5-M4 Attachments: local-lookup.patch, LocalEntityResolver.java Wicket developers, please give me some comment on this: Some wicket test cases parse XML which refers to an external DTD. An example is org.apache.wicket.protocol.http.WicketFilterTest It refers to org.apache.wicket.util.file.WebXmlFile will will parse a custom web.xml. The web.xml will make the parser to look up http://java.sun.com/dtd/web-app_2_3.dtd When building wicket offline this will cause a network error and the test will fail. I would like to add org.apache.wicket.util.xml.LocalEntityResolver which may contain a set of local entitites to avoid hitting the network. As wicket 1.5 is getting close to final I would like to get some feedback first before putting that into trunk... By adding this like to WebXmlFile network lookup would be avoided. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); builder.setEntityResolver(LocalEntityResolver.getDefault()); // no more network lookups Document document = builder.parse(is); package org.apache.wicket.util.xml; import org.apache.wicket.util.lang.Args; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import javax.servlet.Filter; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; /** * entity resolver that tries to locate a document type definition (DTD) using a set of custom entity resolvers * * @author pete */ public class LocalEntityResolver implements EntityResolver { private final MapEntityKey, EntityLocator entities = new HashMapEntityKey, EntityLocator(3); public static LocalEntityResolver getDefault() { LocalEntityResolver resolver = new LocalEntityResolver(); // // look up servlet 2.3 web.xml DTD right from inside servlet-api.jar // resolver.put(new EntityKey(-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN, http://java.sun.com/dtd/web-app_2_3.dtd;), new ServletApiEntityLocator(web-app_2_3.dtd)); return resolver; } public void put(EntityKey key, EntityLocator locator) { Args.notNull(key, key); Args.notNull(locator, locator); entities.put(key, locator); } public InputSource resolveEntity(String id, String url) throws SAXException, IOException { for (Map.EntryEntityKey, EntityLocator entry : entities.entrySet()) if (entry.getKey().id.equals(id) || entry.getKey().url.equals(url)) return entry.getValue().locateInputSource(); return null; } public static class EntityKey { private final String id; private final String url; private EntityKey(String id, String url) { Args.notEmpty(id, id); Args.notEmpty(url, url); this.id = id; this.url = url; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof EntityKey)) return false; EntityKey key = (EntityKey) o; if (!id.equals(key.id)) return false; return url.equals(key.url); } @Override public int hashCode() { int result = id.hashCode(); result = 31 * result + url.hashCode(); return result; }
[jira] Commented: (WICKET-3163) support building wicket offline by resolving DTD references locally
[ https://issues.apache.org/jira/browse/WICKET-3163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12931413#action_12931413 ] Martin Grigorov commented on WICKET-3163: - As discussed in the IRC channel WicketFilterTest fails here from time to time with Connection timed out message. But Java doesn't say what is the endpoint for that connection. Removing the DOCTYPE for web1.xml and web2.xml temporarily fixes the problem. This started to happen last week. Running the build in offline (mvn -o clean install) mode passes. I suspect DTD resolving to be the problem but I am not sure. support building wicket offline by resolving DTD references locally --- Key: WICKET-3163 URL: https://issues.apache.org/jira/browse/WICKET-3163 Project: Wicket Issue Type: Improvement Components: wicket Affects Versions: 1.5-M3 Reporter: Peter Ertl Assignee: Peter Ertl Attachments: LocalEntityResolver.java Wicket developers, please give me some comment on this: Some wicket test cases parse XML which refers to an external DTD. An example is org.apache.wicket.protocol.http.WicketFilterTest It refers to org.apache.wicket.util.file.WebXmlFile will will parse a custom web.xml. The web.xml will make the parser to look up http://java.sun.com/dtd/web-app_2_3.dtd When building wicket offline this will cause a network error and the test will fail. I would like to add org.apache.wicket.util.xml.LocalEntityResolver which may contain a set of local entitites to avoid hitting the network. As wicket 1.5 is getting close to final I would like to get some feedback first before putting that into trunk... By adding this like to WebXmlFile network lookup would be avoided. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); builder.setEntityResolver(LocalEntityResolver.getDefault()); // no more network lookups Document document = builder.parse(is); package org.apache.wicket.util.xml; import org.apache.wicket.util.lang.Args; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import javax.servlet.Filter; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; /** * entity resolver that tries to locate a document type definition (DTD) using a set of custom entity resolvers * * @author pete */ public class LocalEntityResolver implements EntityResolver { private final MapEntityKey, EntityLocator entities = new HashMapEntityKey, EntityLocator(3); public static LocalEntityResolver getDefault() { LocalEntityResolver resolver = new LocalEntityResolver(); // // look up servlet 2.3 web.xml DTD right from inside servlet-api.jar // resolver.put(new EntityKey(-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN, http://java.sun.com/dtd/web-app_2_3.dtd;), new ServletApiEntityLocator(web-app_2_3.dtd)); return resolver; } public void put(EntityKey key, EntityLocator locator) { Args.notNull(key, key); Args.notNull(locator, locator); entities.put(key, locator); } public InputSource resolveEntity(String id, String url) throws SAXException, IOException { for (Map.EntryEntityKey, EntityLocator entry : entities.entrySet()) if (entry.getKey().id.equals(id) || entry.getKey().url.equals(url)) return entry.getValue().locateInputSource(); return null; } public static class EntityKey { private final String id; private final String url; private EntityKey(String id, String url) { Args.notEmpty(id, id); Args.notEmpty(url, url); this.id = id; this.url = url; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof EntityKey)) return false; EntityKey key = (EntityKey) o; if (!id.equals(key.id)) return false; return url.equals(key.url); } @Override public int hashCode() {