Source:
<code>private void addRequiredNamespaces(FeatureTypeInfo[] featureTypeInfos, XSDSchema schema) { final WorkspaceInfo localWorkspace = LocalWorkspace.get(); if (localWorkspace != null) { LocalWorkspace.remove(); } try { if (localWorkspace != null && localWorkspace.isIsolated()) { final Map<String, String> schemaNamespacesMap = schema.getQNamePrefixToNamespaceMap(); final List<NamespaceInfo> catalogNamespaces = catalog.getNamespaces(); for (FeatureTypeInfo featureTypeInfo : featureTypeInfos) { Object mapObject = featureTypeInfo .getFeatureType() .getUserData() .get(Types.DECLARED_NAMESPACES_MAP); if (!(mapObject instanceof Map)) continue; final Map<String, String> featureTypeNamespaces = (Map<String, String>) mapObject; featureTypeNamespaces .entrySet() .forEach( entry -> { final String uri = entry.getValue(); if (schemaNamespacesMap.containsValue(uri)) return; final Optional<NamespaceInfo> nsFromCatalog = catalogNamespaces .stream() .filter( nsi -> Objects.equals( nsi.getURI(), uri)) .findFirst(); final String prefix = nsFromCatalog .map(NamespaceInfo::getPrefix) .orElse(entry.getKey()); schemaNamespacesMap.put(prefix, uri); }); } } else { <START> for (NamespaceInfo nameSpaceinfo : catalog.getNamespaces()) { <END> if (!schema.getQNamePrefixToNamespaceMap() .containsKey(nameSpaceinfo.getPrefix())) { schema.getQNamePrefixToNamespaceMap() .put(nameSpaceinfo.getPrefix(), nameSpaceinfo.getURI()); } } } } catch (IOException e) { logger.log(Level.SEVERE, "Unable to add namespaces", e); throw new UncheckedIOException(e); } finally { LocalWorkspace.set(localWorkspace); } }</code><technical_language>This is wrong, DECLARED_NAMESPACES_MAP shoudl necessary namespaces no? adding namespaces? IMHO behavior be, is a simple feature? business usual. Is a complex feature? get necessary namespaces complex type add them, sense? matter if a local workspaces not</technical_language>

Target:
private void addRequiredNamespaces(FeatureTypeInfo[] featureTypeInfos, XSDSchema schema) { final WorkspaceInfo localWorkspace = LocalWorkspace.get(); if (localWorkspace != null) { LocalWorkspace.remove(); } try { final Map<String, String> schemaNamespacesMap = schema.getQNamePrefixToNamespaceMap(); final List<NamespaceInfo> catalogNamespaces = catalog.getNamespaces(); for (FeatureTypeInfo featureTypeInfo : featureTypeInfos) { Object mapObject = featureTypeInfo .getFeatureType() .getUserData() .get(Types.DECLARED_NAMESPACES_MAP); if (!(mapObject instanceof Map)) continue; final Map<String, String> featureTypeNamespaces = (Map<String, String>) mapObject; featureTypeNamespaces .entrySet() .forEach( entry -> { final String uri = entry.getValue(); if (schemaNamespacesMap.containsValue(uri)) return; final Optional<NamespaceInfo> nsFromCatalog = catalogNamespaces .stream() .filter( nsi -> Objects.equals( nsi.getURI(), uri)) .findFirst(); final String prefix = nsFromCatalog .map(NamespaceInfo::getPrefix) .orElse(entry.getKey()); schemaNamespacesMap.put(prefix, uri); }); } if (!schemaNamespacesMap.containsValue(XLINK.NAMESPACE)) { Optional<NamespaceInfo> xlinkNSFromCatalog = catalogNamespaces .stream() .filter(x -> XLINK.NAMESPACE.equals(x.getURI())) .findFirst(); schemaNamespacesMap.put( xlinkNSFromCatalog .map(NamespaceInfo::getPrefix) .orElse(WFSXmlUtils.XLINK_DEFAULT_PREFIX), XLINK.NAMESPACE); } } catch (IOException e) { logger.log(Level.SEVERE, "Unable to add namespaces", e); throw new UncheckedIOException(e); } finally { LocalWorkspace.set(localWorkspace); } }