Tested and indeed, there's a race condition the will leave you with an invalid configuration:
- Have 3 workspaces with the same uri: ws1:http://example.com ws2:http://example.com ws3:http://example.com - Change the config of ws1 to isolated:false and save now, depending existing = getNamespaceByURI(namespace.getURI()); may return ws1, in which case the validation proceeds and lets you with ws1 being non isolated and the other two being isolated, but with the same ns uri. On Sat, 2 Nov 2019 at 11:38, Gabriel Roldan <[email protected]> wrote: > Hey, > > stumbled upon this code in CatalogImpl.validate(NamespaceInfo) and there > seems to be a bug: > > if (!namespace.isIsolated()) { > // not an isolated namespace \ workplace so we need to check > for duplicates > existing = getNamespaceByURI(namespace.getURI()); > if (existing != null && > !existing.getId().equals(namespace.getId())) { > throw new IllegalArgumentException( > "Namespace with URI '" + namespace.getURI() + "' > already exists."); > } > } > > It calls getNamespaceByURI(namespace.getURI()), but that will get you only > one of the possible many (say you have multiple isolated workspaces with > the same namespace URI) > > I think the following would be correct, provided my understanding is too: > > if (!namespace.isIsolated()) { > // not an isolated namespace \ workplace so we need to check > for duplicates > List<NamespaceInfo> currentList = > facade.getNamespacesByURI(namespace.getURI()); > for (NamespaceInfo current : currentList) { > if (!current.getId().equals(namespace.getId())) { > throw new IllegalArgumentException( > "Namespace with URI '" + namespace.getURI() + > "' already exists."); > } > } > } > > -- > Gabriel Roldán > -- Gabriel Roldán
_______________________________________________ Geoserver-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geoserver-devel
