Merge remote-tracking branch 'origin/master' into jetty-http2
This commit is contained in:
commit
706fe1eba3
|
@ -301,6 +301,9 @@ public abstract class HttpReceiver
|
|||
if (decoder != null)
|
||||
{
|
||||
buffer = decoder.decode(buffer);
|
||||
|
||||
// TODO If the decoder consumes all the content, should we return here?
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Response content decoded ({}) {}{}{}", decoder, response, System.lineSeparator(), BufferUtil.toDetailString(buffer));
|
||||
}
|
||||
|
|
|
@ -116,6 +116,11 @@ public class HostnameVerificationTest
|
|||
|
||||
// ExecutionException wraps an SSLHandshakeException
|
||||
Throwable cause = x.getCause();
|
||||
if (cause==null)
|
||||
{
|
||||
x.printStackTrace();
|
||||
Assert.fail("No cause?");
|
||||
}
|
||||
if (cause instanceof SSLHandshakeException)
|
||||
Assert.assertThat(cause.getCause().getCause(), Matchers.instanceOf(CertificateException.class));
|
||||
else
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -46,6 +47,7 @@ import org.eclipse.jetty.server.Handler;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.Assert;
|
||||
|
@ -187,7 +189,7 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
|||
{
|
||||
baseRequest.setHandled(true);
|
||||
if (requests.incrementAndGet() == 1)
|
||||
response.sendRedirect(scheme + "://" + request.getServerName() + ":" + request.getServerPort() + request.getRequestURI());
|
||||
response.sendRedirect(URIUtil.newURI(scheme,request.getServerName(),request.getServerPort(),request.getRequestURI(),null));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -226,7 +228,7 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
|||
{
|
||||
baseRequest.setHandled(true);
|
||||
if (request.getRequestURI().endsWith("/redirect"))
|
||||
response.sendRedirect(scheme + "://" + request.getServerName() + ":" + request.getServerPort() + "/secure");
|
||||
response.sendRedirect(URIUtil.newURI(scheme,request.getServerName(),request.getServerPort(),"/secure",null));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -230,8 +231,12 @@ public class HttpReceiverOverHTTPTest
|
|||
@Override
|
||||
public void onContent(Response response, ByteBuffer content)
|
||||
{
|
||||
boolean hadRemaining=content.hasRemaining();
|
||||
super.onContent(response, content);
|
||||
latch.countDown();
|
||||
|
||||
// TODO gzip decoding can pass on empty chunks. Currently ignoring them here, but could be done at the decoder???
|
||||
if (hadRemaining) // Ignore empty chunks
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
HttpExchange exchange = new HttpExchange(destination, request, Collections.<Response.ResponseListener>singletonList(listener));
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Set;
|
|||
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.Handler;
|
||||
import org.eclipse.jetty.annotations.ClassNameResolver;
|
||||
import org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration;
|
||||
import org.eclipse.jetty.osgi.boot.OSGiWebappConstants;
|
||||
import org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -92,7 +93,7 @@ public class AnnotationConfiguration extends org.eclipse.jetty.annotations.Annot
|
|||
AnnotationParser oparser = (AnnotationParser)parser;
|
||||
|
||||
Bundle webbundle = (Bundle) context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE);
|
||||
Bundle[] fragAndRequiredBundles = PackageAdminServiceTracker.INSTANCE.getFragmentsAndRequiredBundles(webbundle);
|
||||
Set<Bundle> fragAndRequiredBundles = (Set<Bundle>)context.getAttribute(OSGiWebInfConfiguration.FRAGMENT_AND_REQUIRED_BUNDLES);
|
||||
if (fragAndRequiredBundles != null)
|
||||
{
|
||||
//index and scan fragments
|
||||
|
|
|
@ -1,129 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.osgi.boot;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelperFactory;
|
||||
import org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.MetaInfConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
/**
|
||||
* OSGiMetaInfConfiguration
|
||||
*
|
||||
* Extension of standard Jetty MetaInfConfiguration class to handle OSGi bundle
|
||||
* fragments that may also need to be scanned for META-INF info.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public class OSGiMetaInfConfiguration extends MetaInfConfiguration
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(OSGiMetaInfConfiguration.class);
|
||||
|
||||
|
||||
/**
|
||||
* Inspect bundle fragments associated with the bundle of the webapp for web-fragment, resources, tlds.
|
||||
*
|
||||
* @see org.eclipse.jetty.webapp.MetaInfConfiguration#preConfigure(org.eclipse.jetty.webapp.WebAppContext)
|
||||
*/
|
||||
@Override
|
||||
public void preConfigure(final WebAppContext context) throws Exception
|
||||
{
|
||||
Map<Resource, Resource> frags = (Map<Resource, Resource>) context.getAttribute(METAINF_FRAGMENTS);
|
||||
Set<Resource> resfrags = (Set<Resource>) context.getAttribute(METAINF_RESOURCES);
|
||||
List<Resource> tldfrags = (List<Resource>) context.getAttribute(METAINF_TLDS);
|
||||
|
||||
Bundle[] fragments = PackageAdminServiceTracker.INSTANCE.getFragmentsAndRequiredBundles((Bundle)context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE));
|
||||
//TODO not convinced we need to do this, as we added any fragment jars to the MetaData.webInfJars in OSGiWebInfConfiguration,
|
||||
//so surely the web-fragments and resources tlds etc can be discovered normally?
|
||||
for (Bundle frag : fragments)
|
||||
{
|
||||
URL webFrag = frag.getEntry("/META-INF/web-fragment.xml");
|
||||
Enumeration<URL> resEnum = frag.findEntries("/META-INF/resources", "*", true);
|
||||
Enumeration<URL> tldEnum = frag.findEntries("/META-INF", "*.tld", false);
|
||||
if (webFrag != null || (resEnum != null && resEnum.hasMoreElements()) || (tldEnum != null && tldEnum.hasMoreElements()))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (webFrag != null)
|
||||
{
|
||||
if (frags == null)
|
||||
{
|
||||
frags = new HashMap<Resource,Resource>();
|
||||
context.setAttribute(METAINF_FRAGMENTS, frags);
|
||||
}
|
||||
frags.put(Resource.newResource(BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(frag).toURI()),
|
||||
Resource.newResource(webFrag));
|
||||
}
|
||||
if (resEnum != null && resEnum.hasMoreElements())
|
||||
{
|
||||
URL resourcesEntry = frag.getEntry("/META-INF/resources/");
|
||||
if (resourcesEntry == null)
|
||||
{
|
||||
// probably we found some fragments to a
|
||||
// bundle.
|
||||
// those are already contributed.
|
||||
// so we skip this.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resfrags == null)
|
||||
{
|
||||
resfrags = new HashSet<Resource>();
|
||||
context.setAttribute(METAINF_RESOURCES, resfrags);
|
||||
}
|
||||
resfrags.add(Resource.newResource(BundleFileLocatorHelperFactory.getFactory().getHelper().getLocalURL(resourcesEntry)));
|
||||
}
|
||||
}
|
||||
if (tldEnum != null && tldEnum.hasMoreElements())
|
||||
{
|
||||
if (tldfrags == null)
|
||||
{
|
||||
tldfrags = new ArrayList<Resource>();
|
||||
context.setAttribute(METAINF_TLDS, tldfrags);
|
||||
}
|
||||
while (tldEnum.hasMoreElements())
|
||||
{
|
||||
URL tldUrl = tldEnum.nextElement();
|
||||
tldfrags.add(Resource.newResource(BundleFileLocatorHelperFactory.getFactory().getHelper().getLocalURL(tldUrl)));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Unable to locate the bundle " + frag.getBundleId(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.preConfigure(context);
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ import java.net.URL;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -51,6 +52,9 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
|||
|
||||
|
||||
public static final String CONTAINER_BUNDLE_PATTERN = "org.eclipse.jetty.server.webapp.containerIncludeBundlePattern";
|
||||
public static final String FRAGMENT_AND_REQUIRED_BUNDLES = "org.eclipse.jetty.osgi.fragmentAndRequiredBundles";
|
||||
public static final String FRAGMENT_AND_REQUIRED_RESOURCES = "org.eclipse.jetty.osgi.fragmentAndRequiredResources";
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -87,7 +91,6 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
|||
while (tokenizer.hasMoreTokens())
|
||||
names.add(tokenizer.nextToken());
|
||||
}
|
||||
|
||||
HashSet<Resource> matchingResources = new HashSet<Resource>();
|
||||
if ( !names.isEmpty() || pattern != null)
|
||||
{
|
||||
|
@ -111,14 +114,20 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
|||
matchingResources.addAll(getBundleAsResource(bundle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (Resource r:matchingResources)
|
||||
{
|
||||
context.getMetaData().addContainerResource(r);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
context.setAttribute(FRAGMENT_AND_REQUIRED_BUNDLES, null);
|
||||
context.setAttribute(FRAGMENT_AND_REQUIRED_RESOURCES, null);
|
||||
super.postConfigure(context);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -137,12 +146,34 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
|||
if (webInfJars != null)
|
||||
mergedResources.addAll(webInfJars);
|
||||
|
||||
//add fragment jars as if in WEB-INF/lib of the associated webapp
|
||||
Bundle[] fragments = PackageAdminServiceTracker.INSTANCE.getFragmentsAndRequiredBundles((Bundle)context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE));
|
||||
for (Bundle frag : fragments)
|
||||
//add fragment jars and any Required-Bundles as if in WEB-INF/lib of the associated webapp
|
||||
Bundle[] bundles = PackageAdminServiceTracker.INSTANCE.getFragmentsAndRequiredBundles((Bundle)context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE));
|
||||
if (bundles != null && bundles.length > 0)
|
||||
{
|
||||
File fragFile = BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(frag);
|
||||
mergedResources.add(Resource.newResource(fragFile.toURI()));
|
||||
Set<Bundle> fragsAndReqsBundles = (Set<Bundle>)context.getAttribute(FRAGMENT_AND_REQUIRED_BUNDLES);
|
||||
if (fragsAndReqsBundles == null)
|
||||
{
|
||||
fragsAndReqsBundles = new HashSet<Bundle>();
|
||||
context.setAttribute(FRAGMENT_AND_REQUIRED_BUNDLES, fragsAndReqsBundles);
|
||||
}
|
||||
|
||||
Set<Resource> fragsAndReqsResources = (Set<Resource>)context.getAttribute(FRAGMENT_AND_REQUIRED_RESOURCES);
|
||||
if (fragsAndReqsResources == null)
|
||||
{
|
||||
fragsAndReqsResources = new HashSet<Resource>();
|
||||
context.setAttribute(FRAGMENT_AND_REQUIRED_RESOURCES, fragsAndReqsResources);
|
||||
}
|
||||
|
||||
for (Bundle b : bundles)
|
||||
{
|
||||
//add to context attribute storing associated fragments and required bundles
|
||||
fragsAndReqsBundles.add(b);
|
||||
File f = BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(b);
|
||||
Resource r = Resource.newResource(f.toURI());
|
||||
//add to convenience context attribute storing fragments and required bundles as Resources
|
||||
fragsAndReqsResources.add(r);
|
||||
mergedResources.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
return mergedResources;
|
||||
|
@ -165,9 +196,8 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
|||
Bundle bundle = (Bundle)context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE);
|
||||
if (bundle != null)
|
||||
{
|
||||
//TODO anything we need to do to improve PackageAdminServiceTracker?
|
||||
Bundle[] fragments = PackageAdminServiceTracker.INSTANCE.getFragmentsAndRequiredBundles(bundle);
|
||||
if (fragments != null && fragments.length != 0)
|
||||
Set<Bundle> fragments = (Set<Bundle>)context.getAttribute(FRAGMENT_AND_REQUIRED_BUNDLES);
|
||||
if (fragments != null && !fragments.isEmpty())
|
||||
{
|
||||
// sorted extra resource base found in the fragments.
|
||||
// the resources are either overriding the resourcebase found in the
|
||||
|
|
|
@ -32,6 +32,8 @@ import javax.servlet.UnavailableException;
|
|||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
|
||||
public class BalancerServlet extends ProxyServlet
|
||||
{
|
||||
private static final String BALANCER_MEMBER_PREFIX = "balancerMember.";
|
||||
|
@ -86,7 +88,7 @@ public class BalancerServlet extends ProxyServlet
|
|||
}
|
||||
}
|
||||
|
||||
private void initStickySessions() throws ServletException
|
||||
private void initStickySessions()
|
||||
{
|
||||
_stickySessions = Boolean.parseBoolean(getServletConfig().getInitParameter("stickySessions"));
|
||||
}
|
||||
|
@ -219,17 +221,17 @@ public class BalancerServlet extends ProxyServlet
|
|||
URI locationURI = URI.create(headerValue).normalize();
|
||||
if (locationURI.isAbsolute() && isBackendLocation(locationURI))
|
||||
{
|
||||
String newURI = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
|
||||
StringBuilder newURI = URIUtil.newURIBuilder(request.getScheme(), request.getServerName(), request.getServerPort());
|
||||
String component = locationURI.getRawPath();
|
||||
if (component != null)
|
||||
newURI += component;
|
||||
newURI.append(component);
|
||||
component = locationURI.getRawQuery();
|
||||
if (component != null)
|
||||
newURI += "?" + component;
|
||||
newURI.append('?').append(component);
|
||||
component = locationURI.getRawFragment();
|
||||
if (component != null)
|
||||
newURI += "#" + component;
|
||||
return URI.create(newURI).normalize().toString();
|
||||
newURI.append('#').append(component);
|
||||
return URI.create(newURI.toString()).normalize().toString();
|
||||
}
|
||||
}
|
||||
return headerValue;
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.eclipse.jetty.server.Request;
|
|||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
|
@ -627,7 +628,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
|
|||
@Override
|
||||
protected RoleInfo prepareConstraintInfo(String pathInContext, Request request)
|
||||
{
|
||||
Map<String, RoleInfo> mappings = (Map<String, RoleInfo>)_constraintMap.match(pathInContext);
|
||||
Map<String, RoleInfo> mappings = _constraintMap.match(pathInContext);
|
||||
|
||||
if (mappings != null)
|
||||
{
|
||||
|
@ -700,11 +701,8 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
|
|||
{
|
||||
String scheme = httpConfig.getSecureScheme();
|
||||
int port = httpConfig.getSecurePort();
|
||||
String url = ("https".equalsIgnoreCase(scheme) && port==443)
|
||||
? "https://"+request.getServerName()+request.getRequestURI()
|
||||
: scheme + "://" + request.getServerName() + ":" + port + request.getRequestURI();
|
||||
if (request.getQueryString() != null)
|
||||
url += "?" + request.getQueryString();
|
||||
|
||||
String url = URIUtil.newURI(scheme, request.getServerName(), port,request.getRequestURI(),request.getQueryString());
|
||||
response.setContentLength(0);
|
||||
response.sendRedirect(url);
|
||||
}
|
||||
|
|
|
@ -623,7 +623,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("SendCB@%x{s=%s,i=%s,cb=%s}",hashCode(),getState(),_info,_callback);
|
||||
return String.format("%s[i=%s,cb=%s]",super.toString(),getState(),_info,_callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,8 @@ public class LocalConnector extends AbstractConnector
|
|||
LocalEndPoint endp = executeRequest(requestsBuffer);
|
||||
endp.waitUntilClosedOrIdleFor(idleFor,units);
|
||||
ByteBuffer responses = endp.takeOutput();
|
||||
endp.getConnection().close();
|
||||
if (endp.isOutputShutdown())
|
||||
endp.close();
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("responses {}", BufferUtil.toUTF8String(responses));
|
||||
return responses;
|
||||
|
|
|
@ -61,10 +61,15 @@ public class SPDYClientFactoryTest extends AbstractTest
|
|||
|
||||
session.goAway(new GoAwayInfo(5, TimeUnit.SECONDS));
|
||||
|
||||
// Sleep a while to allow the factory to remove the session
|
||||
// since it is done asynchronously by the selector thread
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
// Sleep a while to allow the factory to remove the session
|
||||
// since it is done asynchronously by the selector thread
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
if (clientFactory.getSessions().isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
Assert.assertTrue(clientFactory.getSessions().isEmpty());
|
||||
Assert.fail(clientFactory.getSessions().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ public abstract class IteratingCallback implements Callback
|
|||
default:
|
||||
if (_state.compareAndSet(current, State.CLOSED))
|
||||
{
|
||||
onCompleteFailure(new IllegalStateException("Closed with pending callback "+current));
|
||||
onCompleteFailure(new IllegalStateException("Closed with pending callback "+this));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,14 +159,11 @@ public class SharedBlockingCallback
|
|||
{
|
||||
if (_state == null)
|
||||
{
|
||||
// TODO remove when feedback received on 435322
|
||||
if (cause==null)
|
||||
LOG.warn("null failed cause (please report stack trace) ",new Throwable());
|
||||
_state = cause==null?FAILED:cause;
|
||||
_complete.signalAll();
|
||||
}
|
||||
else if (_state == IDLE)
|
||||
throw new IllegalStateException("IDLE");
|
||||
throw new IllegalStateException("IDLE",cause);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -663,7 +663,49 @@ public class URIUtil
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Create a new URI from the arguments, handling IPv6 host encoding and default ports
|
||||
* @param scheme
|
||||
* @param server
|
||||
* @param port
|
||||
* @param path
|
||||
* @param query
|
||||
* @return A String URI
|
||||
*/
|
||||
public static String newURI(String scheme,String server, int port,String path,String query)
|
||||
{
|
||||
StringBuilder builder = newURIBuilder(scheme, server, port);
|
||||
builder.append(path);
|
||||
if (query!=null && query.length()>0)
|
||||
builder.append('?').append(query);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Create a new URI StringBuilder from the arguments, handling IPv6 host encoding and default ports
|
||||
* @param scheme
|
||||
* @param server
|
||||
* @param port
|
||||
* @return a StringBuilder containing URI prefix
|
||||
*/
|
||||
public static StringBuilder newURIBuilder(String scheme,String server, int port)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
appendSchemeHostPort(builder, scheme, server, port);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports</p>
|
||||
* @param url StringBuilder to append to
|
||||
* @param scheme
|
||||
* @param server
|
||||
* @param port
|
||||
*/
|
||||
public static void appendSchemeHostPort(StringBuilder url,String scheme,String server, int port)
|
||||
{
|
||||
if (server.indexOf(':')>=0&&server.charAt(0)!='[')
|
||||
|
@ -671,10 +713,34 @@ public class URIUtil
|
|||
else
|
||||
url.append(scheme).append("://").append(server);
|
||||
|
||||
if (port > 0 && (("http".equalsIgnoreCase(scheme) && port != 80) || ("https".equalsIgnoreCase(scheme) && port != 443)))
|
||||
url.append(':').append(port);
|
||||
if (port > 0)
|
||||
{
|
||||
switch(scheme)
|
||||
{
|
||||
case "http":
|
||||
if (port!=80)
|
||||
url.append(':').append(port);
|
||||
break;
|
||||
|
||||
case "https":
|
||||
if (port!=443)
|
||||
url.append(':').append(port);
|
||||
break;
|
||||
|
||||
default:
|
||||
url.append(':').append(port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports</p>
|
||||
* @param url StringBuffer to append to
|
||||
* @param scheme
|
||||
* @param server
|
||||
* @param port
|
||||
*/
|
||||
public static void appendSchemeHostPort(StringBuffer url,String scheme,String server, int port)
|
||||
{
|
||||
synchronized (url)
|
||||
|
@ -684,8 +750,24 @@ public class URIUtil
|
|||
else
|
||||
url.append(scheme).append("://").append(server);
|
||||
|
||||
if (port > 0 && (("http".equalsIgnoreCase(scheme) && port != 80) || ("https".equalsIgnoreCase(scheme) && port != 443)))
|
||||
url.append(':').append(port);
|
||||
if (port > 0)
|
||||
{
|
||||
switch(scheme)
|
||||
{
|
||||
case "http":
|
||||
if (port!=80)
|
||||
url.append(':').append(port);
|
||||
break;
|
||||
|
||||
case "https":
|
||||
if (port!=443)
|
||||
url.append(':').append(port);
|
||||
break;
|
||||
|
||||
default:
|
||||
url.append(':').append(port);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,41 +131,50 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
* Scan for META-INF/resources dir in the given jar.
|
||||
*
|
||||
* @param context
|
||||
* @param jar
|
||||
* @param target
|
||||
* @param cache
|
||||
* @throws Exception
|
||||
*/
|
||||
public void scanForResources (WebAppContext context, Resource jar, ConcurrentHashMap<Resource,Resource> cache)
|
||||
public void scanForResources (WebAppContext context, Resource target, ConcurrentHashMap<Resource,Resource> cache)
|
||||
throws Exception
|
||||
{
|
||||
Resource resourcesDir = null;
|
||||
if (cache != null && cache.containsKey(jar))
|
||||
if (cache != null && cache.containsKey(target))
|
||||
{
|
||||
resourcesDir = cache.get(jar);
|
||||
resourcesDir = cache.get(target);
|
||||
if (resourcesDir == EmptyResource.INSTANCE)
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug(jar+" cached as containing no META-INF/resources");
|
||||
if (LOG.isDebugEnabled()) LOG.debug(target+" cached as containing no META-INF/resources");
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (LOG.isDebugEnabled()) LOG.debug(jar+" META-INF/resources found in cache ");
|
||||
if (LOG.isDebugEnabled()) LOG.debug(target+" META-INF/resources found in cache ");
|
||||
}
|
||||
else
|
||||
{
|
||||
//not using caches or not in the cache so check for the resources dir
|
||||
if (LOG.isDebugEnabled()) LOG.debug(jar+" META-INF/resources checked");
|
||||
URI uri = jar.getURI();
|
||||
resourcesDir = Resource.newResource("jar:"+uri+"!/META-INF/resources");
|
||||
if (LOG.isDebugEnabled()) LOG.debug(target+" META-INF/resources checked");
|
||||
if (target.isDirectory())
|
||||
{
|
||||
//TODO think how to handle an unpacked jar file (eg for osgi)
|
||||
resourcesDir = target.addPath("/META-INF/resources");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Resource represents a packed jar
|
||||
URI uri = target.getURI();
|
||||
resourcesDir = Resource.newResource("jar:"+uri+"!/META-INF/resources");
|
||||
}
|
||||
if (!resourcesDir.exists() || !resourcesDir.isDirectory())
|
||||
resourcesDir = EmptyResource.INSTANCE;
|
||||
|
||||
if (cache != null)
|
||||
{
|
||||
Resource old = cache.putIfAbsent(jar, resourcesDir);
|
||||
Resource old = cache.putIfAbsent(target, resourcesDir);
|
||||
if (old != null)
|
||||
resourcesDir = old;
|
||||
else
|
||||
if (LOG.isDebugEnabled()) LOG.debug(jar+" META-INF/resources cache updated");
|
||||
if (LOG.isDebugEnabled()) LOG.debug(target+" META-INF/resources cache updated");
|
||||
}
|
||||
|
||||
if (resourcesDir == EmptyResource.INSTANCE)
|
||||
|
@ -210,8 +219,16 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
{
|
||||
//not using caches or not in the cache so check for the web-fragment.xml
|
||||
if (LOG.isDebugEnabled()) LOG.debug(jar+" META-INF/web-fragment.xml checked");
|
||||
URI uri = jar.getURI();
|
||||
webFrag = Resource.newResource("jar:"+uri+"!/META-INF/web-fragment.xml");
|
||||
if (jar.isDirectory())
|
||||
{
|
||||
//TODO ????
|
||||
webFrag = jar.addPath("/META-INF/web-fragment.xml");
|
||||
}
|
||||
else
|
||||
{
|
||||
URI uri = jar.getURI();
|
||||
webFrag = Resource.newResource("jar:"+uri+"!/META-INF/web-fragment.xml");
|
||||
}
|
||||
if (!webFrag.exists() || webFrag.isDirectory())
|
||||
webFrag = EmptyResource.INSTANCE;
|
||||
|
||||
|
@ -270,8 +287,17 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
else
|
||||
{
|
||||
//not using caches or not in the cache so find all tlds
|
||||
URI uri = jar.getURI();
|
||||
Resource metaInfDir = Resource.newResource("jar:"+uri+"!/META-INF/");
|
||||
Resource metaInfDir = null;
|
||||
if (jar.isDirectory())
|
||||
{
|
||||
//TODO ??????
|
||||
metaInfDir = jar.addPath("/META-INF/");
|
||||
}
|
||||
else
|
||||
{
|
||||
URI uri = jar.getURI();
|
||||
metaInfDir = Resource.newResource("jar:"+uri+"!/META-INF/");
|
||||
}
|
||||
|
||||
//find any *.tld files inside META-INF or subdirs
|
||||
tlds = new HashSet<URL>();
|
||||
|
|
Loading…
Reference in New Issue