Skip to content

Commit d2c8c24

Browse files
authored
Merge branch 'eXist-db:develop' into 4438-deadlock
2 parents 2bba45c + a2d1ca9 commit d2c8c24

File tree

109 files changed

+6648
-966
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+6648
-966
lines changed

exist-core/pom.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<dependency>
6060
<groupId>com.fasterxml.jackson.core</groupId>
6161
<artifactId>jackson-core</artifactId>
62-
<version>2.13.3</version>
62+
<version>2.13.4</version>
6363
</dependency>
6464

6565
<!-- dependency>
@@ -263,7 +263,7 @@
263263
</dependency>
264264
<dependency>
265265
<groupId>org.apache.logging.log4j</groupId>
266-
<artifactId>slf4j-impl</artifactId>
266+
<artifactId>log4j-slf4j2-impl</artifactId>
267267
<scope>runtime</scope>
268268
</dependency>
269269

@@ -419,7 +419,7 @@
419419
<dependency>
420420
<groupId>com.fifesoft</groupId>
421421
<artifactId>rsyntaxtextarea</artifactId>
422-
<version>3.2.0</version>
422+
<version>3.3.0</version>
423423
</dependency>
424424

425425
<dependency>
@@ -693,6 +693,7 @@
693693
<exclude>src/main/java/org/exist/util/CollectionOfArrayIterator.java</exclude>
694694
<exclude>src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java</exclude>
695695
<exclude>src/main/java/org/exist/util/IPUtil.java</exclude>
696+
<exclude>src/main/java/org/exist/util/MapUtil.java</exclude>
696697
<exclude>src/main/java/org/exist/xmlrpc/ACEAiderParser.java</exclude>
697698
<exclude>src/main/java/org/exist/xmlrpc/ACEAiderSerializer.java</exclude>
698699
<exclude>src/main/java/org/exist/xquery/Cardinality.java</exclude>
@@ -841,6 +842,7 @@ The original license statement is also included below.]]></preamble>
841842
<include>src/main/java/org/exist/util/CollectionOfArrayIterator.java</include>
842843
<include>src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java</include>
843844
<include>src/main/java/org/exist/util/IPUtil.java</include>
845+
<include>src/main/java/org/exist/util/MapUtil.java</include>
844846
<include>src/main/java/org/exist/xmlrpc/ACEAiderParser.java</include>
845847
<include>src/main/java/org/exist/xmlrpc/ACEAiderSerializer.java</include>
846848
<include>src/main/java/org/exist/xquery/Cardinality.java</include>
@@ -921,7 +923,7 @@ The BaseX Team. The original license statement is also included below.]]></pream
921923
<ignoredUnusedDeclaredDependencies>
922924
<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-core:jar:${log4j.version}</ignoredUnusedDeclaredDependency>
923925
<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-jcl:jar:${log4j.version}</ignoredUnusedDeclaredDependency>
924-
<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:slf4j-impl:jar:${log4j.slf4j.impl.version}</ignoredUnusedDeclaredDependency>
926+
<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-slf4j2-impl:jar:${log4j.version}</ignoredUnusedDeclaredDependency>
925927

926928
<ignoredUnusedDeclaredDependency>org.glassfish.jaxb:jaxb-runtime:jar:${jaxb.impl.version}</ignoredUnusedDeclaredDependency>
927929
<ignoredUnusedDeclaredDependency>org.fusesource.jansi:jansi:jar:2.4.0</ignoredUnusedDeclaredDependency>

exist-core/src/main/java/org/exist/client/InteractiveClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
import se.softhouse.jargo.ArgumentException;
8585

8686
import static java.nio.charset.StandardCharsets.UTF_8;
87+
import static org.exist.storage.serializers.EXistOutputKeys.OUTPUT_DOCTYPE;
8788

8889
/**
8990
* Command-line client based on the XML:DB API.
@@ -137,6 +138,7 @@ public class InteractiveClient {
137138
defaultProps.setProperty(USER, USER_DEFAULT);
138139
defaultProps.setProperty(EDITOR, EDIT_CMD);
139140
defaultProps.setProperty(INDENT, "true");
141+
defaultProps.setProperty(OUTPUT_DOCTYPE, "true");
140142
defaultProps.setProperty(ENCODING, ENCODING_DEFAULT.name());
141143
defaultProps.setProperty(COLORS, "false");
142144
defaultProps.setProperty(PERMISSIONS, "false");

exist-core/src/main/java/org/exist/dom/memtree/NodeImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import java.util.Properties;
4949

5050

51-
public abstract class NodeImpl<T extends NodeImpl> implements INode<DocumentImpl, T>, NodeValue {
51+
public abstract class NodeImpl<T extends NodeImpl<T>> implements INode<DocumentImpl, T>, NodeValue {
5252

5353
public static final short REFERENCE_NODE = 100;
5454
public static final short NAMESPACE_NODE = 101;

exist-core/src/main/java/org/exist/dom/persistent/AttrImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
import static java.nio.charset.StandardCharsets.UTF_8;
4242

43-
public class AttrImpl extends NamedNode implements Attr {
43+
public class AttrImpl extends NamedNode<AttrImpl> implements Attr {
4444

4545
public static final int LENGTH_NS_ID = 2; //sizeof short
4646
public static final int LENGTH_PREFIX_LENGTH = 2; //sizeof short

exist-core/src/main/java/org/exist/dom/persistent/ElementImpl.java

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.exist.EXistException;
2727
import org.exist.Namespaces;
2828
import org.exist.dom.NamedNodeMapImpl;
29+
import org.exist.dom.NodeListImpl;
2930
import org.exist.dom.QName;
3031
import org.exist.dom.QName.IllegalQNameException;
3132
import org.exist.indexing.IndexController;
@@ -67,7 +68,7 @@
6768
*
6869
* @author Wolfgang Meier
6970
*/
70-
public class ElementImpl extends NamedNode implements Element {
71+
public class ElementImpl extends NamedNode<ElementImpl> implements Element {
7172

7273
public static final int LENGTH_ELEMENT_CHILD_COUNT = 4; //sizeof int
7374
public static final int LENGTH_ATTRIBUTES_COUNT = 2; //sizeof short
@@ -527,7 +528,7 @@ public Node appendChild(final Node newChild) throws DOMException {
527528
}
528529
}
529530

530-
private void appendAttributes(final Txn transaction, final NodeList attribs) throws DOMException {
531+
private void appendAttributes(final Txn transaction, final NodeListImpl attribs) throws DOMException {
531532
final NodeList duplicateAttrs = findDupAttributes(attribs);
532533
removeAppendAttributes(transaction, duplicateAttrs, attribs);
533534
}
@@ -633,6 +634,16 @@ private void appendChildren(final Txn transaction,
633634
}
634635
}
635636

637+
private QName attrName(Attr attr) {
638+
final String ns = attr.getNamespaceURI();
639+
final String prefix = (Namespaces.XML_NS.equals(ns) ? XMLConstants.XML_NS_PREFIX : attr.getPrefix());
640+
String name = attr.getLocalName();
641+
if(name == null) {
642+
name = attr.getName();
643+
}
644+
return new QName(name, ns, prefix);
645+
}
646+
636647
private Node appendChild(final Txn transaction, final NodeId newNodeId, final NodeImplRef last, final NodePath lastPath, final Node child, final StreamListener listener)
637648
throws DOMException {
638649
if(last == null || last.getNode() == null) {
@@ -725,17 +736,11 @@ private Node appendChild(final Txn transaction, final NodeId newNodeId, final No
725736

726737
case Node.ATTRIBUTE_NODE:
727738
final Attr attr = (Attr) child;
728-
final String ns = attr.getNamespaceURI();
729-
final String prefix = (Namespaces.XML_NS.equals(ns) ? XMLConstants.XML_NS_PREFIX : attr.getPrefix());
730-
String name = attr.getLocalName();
731-
if(name == null) {
732-
name = attr.getName();
733-
}
734-
final QName attrName = new QName(name, ns, prefix);
739+
final QName attrName = attrName(attr);
735740
final AttrImpl attrib = new AttrImpl(getExpression(), attrName, attr.getValue(), broker.getBrokerPool().getSymbols());
736741
attrib.setNodeId(newNodeId);
737742
attrib.setOwnerDocument(owner);
738-
if(ns != null && attrName.compareTo(Namespaces.XML_ID_QNAME) == Constants.EQUAL) {
743+
if(attrName.getNamespaceURI() != null && attrName.compareTo(Namespaces.XML_ID_QNAME) == Constants.EQUAL) {
739744
// an xml:id attribute. Normalize the attribute and set its type to ID
740745
attrib.setValue(StringValue.trimWhitespace(StringValue.collapseWhitespace(attrib.getValue())));
741746
attrib.setType(AttrImpl.ID);
@@ -829,6 +834,10 @@ public NamedNodeMap getAttributes() {
829834
final int childCount = getChildCount();
830835
for(int i = 0; i < childCount; i++) {
831836
final IStoredNode next = iterator.next();
837+
if (next == null) {
838+
LOG.warn("Miscounted getChildCount() index: {} was null of: {}", i, childCount);
839+
continue;
840+
}
832841
if(next.getNodeType() != Node.ATTRIBUTE_NODE) {
833842
break;
834843
}
@@ -1339,10 +1348,17 @@ public void setNamespaceMappings(final Map<String, String> map) {
13391348
}
13401349

13411350
public Iterator<String> getPrefixes() {
1351+
1352+
if (namespaceMappings == null) {
1353+
return Collections.<String>emptySet().iterator();
1354+
}
13421355
return namespaceMappings.keySet().iterator();
13431356
}
13441357

13451358
public String getNamespaceForPrefix(final String prefix) {
1359+
if (namespaceMappings == null) {
1360+
return null;
1361+
}
13461362
return namespaceMappings.get(prefix);
13471363
}
13481364

@@ -2039,4 +2055,19 @@ public boolean accept(final INodeIterator iterator, final NodeVisitor visitor) {
20392055
}
20402056
return true;
20412057
}
2058+
2059+
@Override
2060+
public String lookupNamespaceURI(final String prefix) {
2061+
2062+
for (Node pathNode = this; pathNode != null; pathNode = pathNode.getParentNode()) {
2063+
if (pathNode instanceof ElementImpl) {
2064+
final String namespaceForPrefix = ((ElementImpl)pathNode).getNamespaceForPrefix(prefix);
2065+
if (namespaceForPrefix != null) {
2066+
return namespaceForPrefix;
2067+
}
2068+
}
2069+
}
2070+
2071+
return XMLConstants.NULL_NS_URI;
2072+
}
20422073
}

exist-core/src/main/java/org/exist/http/RESTServer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ private String getParameter(final HttpServletRequest request, final RESTServerPa
250250
*
251251
* <li>_xsl: an URI pointing to an XSL stylesheet that will be applied to
252252
* the returned XML.</li>
253+
*
254+
* <li>_output-doctype: if set to "yes", the returned XML will include
255+
* a Document Type Declaration if one is present, if "no" the Document Type Declaration will be omitted.</li>
253256
* </ul>
254257
*
255258
* @param broker the database broker
@@ -346,6 +349,14 @@ public void doGet(final DBBroker broker, final Txn transaction, final HttpServle
346349
if ((option = getParameter(request, Indent)) != null) {
347350
outputProperties.setProperty(OutputKeys.INDENT, option);
348351
}
352+
if ((option = getParameter(request, Output_Doctype)) != null) {
353+
// take user query-string specified output-doctype setting
354+
outputProperties.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, option);
355+
} else {
356+
// set output-doctype by configuration
357+
final String outputDocType = broker.getConfiguration().getProperty(Serializer.PROPERTY_OUTPUT_DOCTYPE, "yes");
358+
outputProperties.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, outputDocType);
359+
}
349360
if ((option = getParameter(request, Source)) != null && !safeMode) {
350361
source = "yes".equals(option);
351362
}

exist-core/src/main/java/org/exist/http/RESTServerParameter.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,18 @@ enum RESTServerParameter {
346346
* <exist:property name = string
347347
* value = string/>
348348
*/
349-
Property;
349+
Property,
350+
351+
/**
352+
* Can be used in the Query String of a GET request
353+
* to indicate that the doctype of an XML document should also
354+
* be serialized if present.
355+
*
356+
* Contexts: GET
357+
*
358+
* The value of the parameter should be either "yes" or "no".
359+
*/
360+
Output_Doctype;
350361

351362
/**
352363
* Get the parameter key that is
@@ -366,6 +377,6 @@ public String queryStringKey() {
366377
* @return The parameter key, suitable for use in an XML document
367378
*/
368379
public String xmlKey() {
369-
return name().toLowerCase();
380+
return name().toLowerCase().replace('_', '-');
370381
}
371382
}

exist-core/src/main/java/org/exist/http/servlets/HttpRequestWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private void parseMultipartContent() {
188188
// Create a factory for disk-based file items
189189
final DiskFileItemFactory factory = new DiskFileItemFactory();
190190

191-
// Dizzzz: Wonder why this should be zero
191+
// Ensure small attachments are readable in XQuery context
192192
factory.setSizeThreshold(0);
193193

194194
// Create a new file upload handler

exist-core/src/main/java/org/exist/protocolhandler/xmlrpc/XmlrpcDownload.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
3737

3838
import org.exist.protocolhandler.xmldb.XmldbURL;
39+
import org.exist.storage.serializers.EXistOutputKeys;
40+
41+
import javax.xml.transform.OutputKeys;
3942

4043
import static java.nio.charset.StandardCharsets.UTF_8;
4144

@@ -75,8 +78,9 @@ public void stream(final XmldbURL xmldbURL, final OutputStream os) throws IOExce
7578

7679
// Setup xml serializer
7780
final Map<String, String> options = new HashMap<>();
78-
options.put("indent", "no");
79-
options.put("encoding", UTF_8.name());
81+
options.put(OutputKeys.INDENT, "no");
82+
options.put(OutputKeys.ENCODING, UTF_8.name());
83+
options.put(EXistOutputKeys.OUTPUT_DOCTYPE, "yes"); // Preserve doctype
8084

8185
// Setup client parameters
8286
final List<Object> params = new ArrayList<>();

exist-core/src/main/java/org/exist/repo/ExistRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void configure(final Configuration configuration) throws BrokerPoolServic
8787

8888
@Override
8989
public void prepare(final BrokerPool brokerPool) throws BrokerPoolServiceException {
90-
if(!Files.exists(expathDir)) {
90+
if (!Files.exists(expathDir) && brokerPool != null) {
9191
moveOldRepo(brokerPool.getConfiguration().getExistHome(), expathDir);
9292
}
9393
try {

0 commit comments

Comments
 (0)