You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2025/12/10 20:46:07 UTC
(couchdb) 01/01: upgrade to dropwizard 5
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch dropwizard-5
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ed2746685063c10671deb867984af983db71ac13
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Dec 10 20:43:57 2025 +0000
upgrade to dropwizard 5
ServletSpec 6.0 prohibits using encoded forward slash, which
nouveau (and couchdb more generally) has used on purpose.
For now I swap it for : and back again but will need to ponder this
more before merging this.
---
extra/nouveau/build.gradle | 2 +-
.../org/apache/couchdb/nouveau/core/IndexManager.java | 5 ++---
.../couchdb/nouveau/resources/IndexResource.java | 18 +++++++++++-------
src/nouveau/src/nouveau_api.erl | 11 +++++++----
4 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/extra/nouveau/build.gradle b/extra/nouveau/build.gradle
index a91555971..c6008be12 100644
--- a/extra/nouveau/build.gradle
+++ b/extra/nouveau/build.gradle
@@ -16,7 +16,7 @@ repositories {
}
dependencies {
- implementation platform('io.dropwizard:dropwizard-dependencies:4.0.12')
+ implementation platform('io.dropwizard:dropwizard-dependencies:5.0.0')
implementation 'io.dropwizard:dropwizard-core'
implementation 'io.dropwizard:dropwizard-http2'
implementation 'io.dropwizard.metrics:metrics-core'
diff --git a/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java b/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java
index 4067716ee..9f4ffc3df 100644
--- a/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java
+++ b/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java
@@ -102,8 +102,7 @@ public final class IndexManager implements Managed {
private StripedLock<String> createLock;
- public <R> R with(final String name, final IndexFunction<Index, R> indexFun)
- throws IOException, InterruptedException {
+ public <R> R with(String name, final IndexFunction<Index, R> indexFun) throws IOException, InterruptedException {
evictIfOverCapacity();
retry:
@@ -214,7 +213,7 @@ public final class IndexManager implements Managed {
}
}
- public void create(final String name, IndexDefinition indexDefinition) throws IOException {
+ public void create(String name, IndexDefinition indexDefinition) throws IOException {
if (exists(name)) {
assertSame(indexDefinition, loadIndexDefinition(name));
return;
diff --git a/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/resources/IndexResource.java b/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/resources/IndexResource.java
index 9ba382109..0e09a1c57 100644
--- a/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/resources/IndexResource.java
+++ b/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/resources/IndexResource.java
@@ -63,7 +63,7 @@ public final class IndexResource {
throw new WebApplicationException(
"Cannot create a new version " + indexDefinition.getLuceneVersion() + " index", Status.BAD_REQUEST);
}
- indexManager.create(name, indexDefinition);
+ indexManager.create(fix(name), indexDefinition);
return Ok.INSTANCE;
}
@@ -74,7 +74,7 @@ public final class IndexResource {
@PathParam("docId") String docId,
@NotNull @Valid DocumentDeleteRequest request)
throws Exception {
- return indexManager.with(name, (index) -> {
+ return indexManager.with(fix(name), (index) -> {
index.delete(docId, request);
return Ok.INSTANCE;
});
@@ -82,20 +82,20 @@ public final class IndexResource {
@DELETE
public Ok deletePath(@PathParam("name") String path, @Valid final List<String> exclusions) throws IOException {
- indexManager.deleteAll(path, exclusions);
+ indexManager.deleteAll(fix(path), exclusions);
return Ok.INSTANCE;
}
@GET
public IndexInfo getIndexInfo(@PathParam("name") String name) throws Exception {
- return indexManager.with(name, (index) -> {
+ return indexManager.with(fix(name), (index) -> {
return index.info();
});
}
@POST
public Ok setIndexInfo(@PathParam("name") String name, @NotNull @Valid IndexInfoRequest request) throws Exception {
- return indexManager.with(name, (index) -> {
+ return indexManager.with(fix(name), (index) -> {
if (request.getMatchUpdateSeq().isPresent()
&& request.getUpdateSeq().isPresent()) {
index.setUpdateSeq(
@@ -115,7 +115,7 @@ public final class IndexResource {
@Path("/search")
public SearchResults searchIndex(@PathParam("name") String name, @NotNull @Valid SearchRequest request)
throws Exception {
- return indexManager.with(name, (index) -> {
+ return indexManager.with(fix(name), (index) -> {
return index.search(request);
});
}
@@ -127,9 +127,13 @@ public final class IndexResource {
@PathParam("docId") String docId,
@NotNull @Valid DocumentUpdateRequest request)
throws Exception {
- return indexManager.with(name, (index) -> {
+ return indexManager.with(fix(name), (index) -> {
index.update(docId, request);
return Ok.INSTANCE;
});
}
+
+ private String fix(final String path) {
+ return path.replaceAll(":", "/");
+ }
}
diff --git a/src/nouveau/src/nouveau_api.erl b/src/nouveau/src/nouveau_api.erl
index 2d140e580..b58a0de32 100644
--- a/src/nouveau/src/nouveau_api.erl
+++ b/src/nouveau/src/nouveau_api.erl
@@ -230,18 +230,21 @@ supported_lucene_versions() ->
%% private functions
index_path(Path) when is_binary(Path) ->
- [<<"/index/">>, couch_util:url_encode(Path)];
+ [<<"/index/">>, disambiguate_path(Path)];
index_path(#index{} = Index) ->
- [<<"/index/">>, couch_util:url_encode(nouveau_util:index_name(Index))].
+ [<<"/index/">>, disambiguate_path(nouveau_util:index_name(Index))].
doc_path(#index{} = Index, DocId) ->
[
<<"/index/">>,
- couch_util:url_encode(nouveau_util:index_name(Index)),
+ disambiguate_path(nouveau_util:index_name(Index)),
<<"/doc/">>,
- couch_util:url_encode(DocId)
+ DocId
].
+disambiguate_path(Path) ->
+ re:replace(Path, "/", ":", [global]).
+
search_path(#index{} = Index) ->
[index_path(Index), <<"/search">>].