Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions exist-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ The BaseX Team. The original license statement is also included below.]]></pream
<jetty.home>${project.basedir}/../exist-jetty-config/target/classes/org/exist/jetty</jetty.home>
<exist.configurationFile>${project.build.testOutputDirectory}/conf.xml</exist.configurationFile>
<exist.jetty.standalone.webapp.dir>${project.build.testOutputDirectory}/standalone-webapp</exist.jetty.standalone.webapp.dir>
<exist.jetty.portal.dir>${project.basedir}/../exist-jetty-config/src/main/resources/org/exist/jetty/etc/webapps/portal</exist.jetty.portal.dir>
<log4j.configurationFile>${project.build.testOutputDirectory}/log4j2.xml</log4j.configurationFile>
</systemPropertyVariables>

Expand All @@ -1229,6 +1230,7 @@ The BaseX Team. The original license statement is also included below.]]></pream
<jetty.home>${project.basedir}/../exist-jetty-config/target/classes/org/exist/jetty</jetty.home>
<exist.configurationFile>${project.build.testOutputDirectory}/conf.xml</exist.configurationFile>
<exist.jetty.standalone.webapp.dir>${project.build.testOutputDirectory}/standalone-webapp</exist.jetty.standalone.webapp.dir>
<exist.jetty.portal.dir>${project.basedir}/../exist-jetty-config/src/main/resources/org/exist/jetty/etc/webapps/portal</exist.jetty.portal.dir>
<log4j.configurationFile>${project.build.testOutputDirectory}/log4j2.xml</log4j.configurationFile>
</systemPropertyVariables>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,25 @@ public void addCookie(final String name, final String value, final int maxAge, b
final Cookie cookie = new Cookie(name, encode(value));
cookie.setMaxAge(maxAge);
cookie.setSecure( secure );
if (domain != null) {
if (domain != null && !domain.isEmpty()) {
cookie.setDomain(domain);
}
if (path != null) {
setCookiePath(cookie, path);
response.addCookie(cookie);
}

/**
* Apply a cookie path only when it is a non-empty string.
* <p>
* Standalone Jetty deployments use a root context ({@code getContextPath()} returns {@code ""}).
* Passing that empty string as an explicit Path makes many HTTP clients (including Apache HttpClient
* used in integration tests) reject the cookie entirely. Omitting Path lets the container apply
* the RFC 6265 default for the request URI.
*/
private static void setCookiePath(final Cookie cookie, final String path) {
if (path != null && !path.isEmpty()) {
cookie.setPath(path);
}
response.addCookie(cookie);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
import org.w3c.dom.NodeList;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.exist.security.PermissionDeniedException;
Expand All @@ -56,7 +58,14 @@ public enum CollectionIndexRemovalMode {
CONFIG_ONLY_REINDEX
}

private final Map<String, IndexWorker> indexWorkers = new HashMap<>();
/**
* Stable iteration order for listener chains and {@link #flush()}.
*/
private static final Comparator<IndexWorker> INDEX_WORKER_ORDER = Comparator
.comparingInt(IndexWorker::getChainPriority)
.thenComparing(IndexWorker::getIndexId);

private final Map<String, IndexWorker> indexWorkers = new LinkedHashMap<>();

private final DBBroker broker;
private StreamListener listener = null;
Expand All @@ -68,9 +77,9 @@ public enum CollectionIndexRemovalMode {
public IndexController(final DBBroker broker) {
this.broker = broker;
final List<IndexWorker> workers = broker.getBrokerPool().getIndexManager().getWorkers(broker);
for (final IndexWorker worker : workers) {
indexWorkers.put(worker.getIndexId(), worker);
}
workers.stream()
.sorted(INDEX_WORKER_ORDER)
.forEach(worker -> indexWorkers.put(worker.getIndexId(), worker));
}

/**
Expand Down
18 changes: 18 additions & 0 deletions exist-core/src/main/java/org/exist/indexing/IndexWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ public interface IndexWorker {
*/
public static final String VALUE_COUNT = "value_count";

/**
* Lower values run earlier in {@link IndexController} listener chains and {@link #flush()}.
* Gaps reserve room for future workers: {@code 0} structural, {@code 1–99} pre-statistics,
* {@code 100–999} pre-Lucene, {@code 1000+} Lucene and later; unranked workers use
* {@link Integer#MAX_VALUE}.
*/
int CHAIN_PRIORITY_STRUCTURAL = 0;
int CHAIN_PRIORITY_STATISTICS = 100;
int CHAIN_PRIORITY_LUCENE = 1000;

/**
* Chain-order priority for {@link IndexController}. Default {@link Integer#MAX_VALUE} preserves
* legacy ordering among workers that do not override.
*/
default int getChainPriority() {
return Integer.MAX_VALUE;
}

/**
* Returns an ID which uniquely identifies this worker's index.
* @return a unique name identifying this worker's index.
Expand Down
Loading