--- old/src/share/jaxws_classes/com/sun/xml/internal/ws/server/ServiceDefinitionImpl.java 2014-03-28 17:28:47.000000000 +0100 +++ new/src/share/jaxws_classes/com/sun/xml/internal/ws/server/ServiceDefinitionImpl.java 2014-03-28 17:28:47.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import com.sun.xml.internal.ws.wsdl.SDDocumentResolver; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -47,7 +48,7 @@ * @author Kohsuke Kawaguchi */ public final class ServiceDefinitionImpl implements ServiceDefinition, SDDocumentResolver { - private final List docs; + private final Collection docs; private final Map bySystemId; private final @NotNull SDDocumentImpl primaryWsdl; @@ -65,12 +66,20 @@ * There must be at least one entry. * The first document is considered {@link #getPrimary() primary}. */ - public ServiceDefinitionImpl(List docs, @NotNull SDDocumentImpl primaryWsdl) { + public ServiceDefinitionImpl(Collection docs, @NotNull SDDocumentImpl primaryWsdl) { assert docs.contains(primaryWsdl); this.docs = docs; this.primaryWsdl = primaryWsdl; + this.bySystemId = new HashMap(); + } + + private boolean isInitialized = false; + + private synchronized void init() { + if (isInitialized) + return; + isInitialized = true; - this.bySystemId = new HashMap(docs.size()); for (SDDocumentImpl doc : docs) { bySystemId.put(doc.getURL().toExternalForm(),doc); doc.setFilters(filters); @@ -95,6 +104,7 @@ } public Iterator iterator() { + init(); return (Iterator)docs.iterator(); } @@ -106,6 +116,7 @@ * null if none is found. */ public SDDocument resolve(String systemId) { + init(); return bySystemId.get(systemId); } }