Merge branch 'jetty-9.4.x' into jetty-9.4.x-1027-SearchPattern
This commit is contained in:
commit
244db8c482
|
@ -40,7 +40,7 @@ def getFullBuild(jdk, os) {
|
||||||
withMaven(
|
withMaven(
|
||||||
maven: 'maven3',
|
maven: 'maven3',
|
||||||
jdk: "$jdk",
|
jdk: "$jdk",
|
||||||
options: disableMvnReporters(),
|
publisherStrategy: 'EXPLICIT',
|
||||||
mavenLocalRepo: "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}") {
|
mavenLocalRepo: "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}") {
|
||||||
sh "mvn -V -B clean install -Dtest=None -T6"
|
sh "mvn -V -B clean install -Dtest=None -T6"
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ def getFullBuild(jdk, os) {
|
||||||
withMaven(
|
withMaven(
|
||||||
maven: 'maven3',
|
maven: 'maven3',
|
||||||
jdk: "$jdk",
|
jdk: "$jdk",
|
||||||
options: disableMvnReporters(),
|
publisherStrategy: 'EXPLICIT',
|
||||||
mavenLocalRepo: "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}") {
|
mavenLocalRepo: "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}") {
|
||||||
sh "mvn -V -B javadoc:javadoc -T5"
|
sh "mvn -V -B javadoc:javadoc -T5"
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ def getFullBuild(jdk, os) {
|
||||||
withMaven(
|
withMaven(
|
||||||
maven: 'maven3',
|
maven: 'maven3',
|
||||||
jdk: "$jdk",
|
jdk: "$jdk",
|
||||||
options: disableMvnReporters(),
|
publisherStrategy: 'EXPLICIT',
|
||||||
mavenLocalRepo: "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}") {
|
mavenLocalRepo: "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}") {
|
||||||
//
|
//
|
||||||
sh "mvn -V -B install -Dmaven.test.failure.ignore=true -Prun-its -T3 -e -Dmaven.repo.local=${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}"
|
sh "mvn -V -B install -Dmaven.test.failure.ignore=true -Prun-its -T3 -e -Dmaven.repo.local=${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}"
|
||||||
|
@ -136,7 +136,7 @@ def getFullBuild(jdk, os) {
|
||||||
withMaven(
|
withMaven(
|
||||||
maven: 'maven3',
|
maven: 'maven3',
|
||||||
jdk: "$jdk",
|
jdk: "$jdk",
|
||||||
options: disableMvnReporters(),
|
publisherStrategy: 'EXPLICIT',
|
||||||
mavenLocalRepo: "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}") {
|
mavenLocalRepo: "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}") {
|
||||||
sh "mvn -V -B -Pcompact3 clean install -T5"
|
sh "mvn -V -B -Pcompact3 clean install -T5"
|
||||||
}
|
}
|
||||||
|
@ -198,17 +198,4 @@ def notifyBuild(String buildStatus, String jdk)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
def disableMvnReporters() {
|
|
||||||
return [
|
|
||||||
concordionPublisher(disabled: true),
|
|
||||||
dependenciesFingerprintPublisher(disabled: true),
|
|
||||||
findbugsPublisher(disabled: true),
|
|
||||||
artifactsPublisher(disabled: true),
|
|
||||||
invokerPublisher(disabled: true),
|
|
||||||
jgivenPublisher(disabled: true),
|
|
||||||
junitPublisher(disabled: true),
|
|
||||||
pipelineGraphPublisher(disabled: true),
|
|
||||||
openTasksPublisher(disabled: true)];
|
|
||||||
}
|
|
||||||
|
|
||||||
// vim: et:ts=2:sw=2:ft=groovy
|
// vim: et:ts=2:sw=2:ft=groovy
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.eclipse.jetty.annotations.AnnotationParser.Handler;
|
||||||
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
|
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
|
||||||
import org.eclipse.jetty.util.JavaVersion;
|
import org.eclipse.jetty.util.JavaVersion;
|
||||||
import org.eclipse.jetty.util.MultiException;
|
import org.eclipse.jetty.util.MultiException;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
import org.eclipse.jetty.util.TypeUtil;
|
import org.eclipse.jetty.util.TypeUtil;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
@ -453,7 +454,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
start = System.nanoTime();
|
start = System.nanoTime();
|
||||||
|
|
||||||
//execute scan, either effectively synchronously (1 thread only), or asynchronously (limited by number of processors available)
|
//execute scan, either effectively synchronously (1 thread only), or asynchronously (limited by number of processors available)
|
||||||
final Semaphore task_limit = (isUseMultiThreading(context)? new Semaphore(Runtime.getRuntime().availableProcessors()):new Semaphore(1));
|
final Semaphore task_limit = (isUseMultiThreading(context)? new Semaphore(ProcessorUtils.availableProcessors()):new Semaphore( 1));
|
||||||
final CountDownLatch latch = new CountDownLatch(_parserTasks.size());
|
final CountDownLatch latch = new CountDownLatch(_parserTasks.size());
|
||||||
final MultiException me = new MultiException();
|
final MultiException me = new MultiException();
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@ package org.eclipse.jetty.client;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.client.api.Connection;
|
import org.eclipse.jetty.client.api.Connection;
|
||||||
import org.eclipse.jetty.client.api.Destination;
|
import org.eclipse.jetty.client.api.Destination;
|
||||||
|
import org.eclipse.jetty.util.AtomicBiInteger;
|
||||||
import org.eclipse.jetty.util.Callback;
|
import org.eclipse.jetty.util.Callback;
|
||||||
import org.eclipse.jetty.util.Promise;
|
import org.eclipse.jetty.util.Promise;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
@ -39,7 +39,12 @@ public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
|
||||||
private static final Logger LOG = Log.getLogger(AbstractConnectionPool.class);
|
private static final Logger LOG = Log.getLogger(AbstractConnectionPool.class);
|
||||||
|
|
||||||
private final AtomicBoolean closed = new AtomicBoolean();
|
private final AtomicBoolean closed = new AtomicBoolean();
|
||||||
private final AtomicInteger connectionCount = new AtomicInteger();
|
|
||||||
|
/**
|
||||||
|
* The connectionCount encodes both the total connections plus the pending connection counts, so both can be atomically changed.
|
||||||
|
* The bottom 32 bits represent the total connections and the top 32 bits represent the pending connections.
|
||||||
|
*/
|
||||||
|
private final AtomicBiInteger connections = new AtomicBiInteger();
|
||||||
private final Destination destination;
|
private final Destination destination;
|
||||||
private final int maxConnections;
|
private final int maxConnections;
|
||||||
private final Callback requester;
|
private final Callback requester;
|
||||||
|
@ -60,13 +65,19 @@ public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
|
||||||
@ManagedAttribute(value = "The number of connections", readonly = true)
|
@ManagedAttribute(value = "The number of connections", readonly = true)
|
||||||
public int getConnectionCount()
|
public int getConnectionCount()
|
||||||
{
|
{
|
||||||
return connectionCount.get();
|
return connections.getLo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute(value = "The number of pending connections", readonly = true)
|
||||||
|
public int getPendingCount()
|
||||||
|
{
|
||||||
|
return connections.getHi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty()
|
public boolean isEmpty()
|
||||||
{
|
{
|
||||||
return connectionCount.get() == 0;
|
return connections.getLo() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,29 +91,34 @@ public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
|
||||||
{
|
{
|
||||||
Connection connection = activate();
|
Connection connection = activate();
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
connection = tryCreate();
|
{
|
||||||
|
tryCreate(-1);
|
||||||
|
connection = activate();
|
||||||
|
}
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Connection tryCreate()
|
protected void tryCreate(int maxPending)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int current = getConnectionCount();
|
long encoded = connections.get();
|
||||||
final int next = current + 1;
|
int pending = AtomicBiInteger.getHi(encoded);
|
||||||
|
int total = AtomicBiInteger.getLo(encoded);
|
||||||
|
|
||||||
if (next > maxConnections)
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("tryCreate {}/{} connections {}/{} pending",total,maxConnections,pending,maxPending);
|
||||||
|
|
||||||
|
if (total >= maxConnections)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (maxPending>=0 && pending>=maxPending)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (connections.compareAndSet(encoded,pending+1,total+1))
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Max connections {}/{} reached", current, maxConnections);
|
LOG.debug("newConnection {}/{} connections {}/{} pending", total+1, maxConnections, pending+1, maxPending);
|
||||||
// Try again the idle connections
|
|
||||||
return activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connectionCount.compareAndSet(current, next))
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Connection {}/{} creation", next, maxConnections);
|
|
||||||
|
|
||||||
destination.newConnection(new Promise<Connection>()
|
destination.newConnection(new Promise<Connection>()
|
||||||
{
|
{
|
||||||
|
@ -110,7 +126,8 @@ public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
|
||||||
public void succeeded(Connection connection)
|
public void succeeded(Connection connection)
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Connection {}/{} creation succeeded {}", next, maxConnections, connection);
|
LOG.debug("Connection {}/{} creation succeeded {}", total+1, maxConnections, connection);
|
||||||
|
connections.update(-1,0);
|
||||||
onCreated(connection);
|
onCreated(connection);
|
||||||
proceed();
|
proceed();
|
||||||
}
|
}
|
||||||
|
@ -119,14 +136,13 @@ public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
|
||||||
public void failed(Throwable x)
|
public void failed(Throwable x)
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Connection " + next + "/" + maxConnections + " creation failed", x);
|
LOG.debug("Connection " + (total+1) + "/" + maxConnections + " creation failed", x);
|
||||||
connectionCount.decrementAndGet();
|
connections.update(-1,-1);
|
||||||
requester.failed(x);
|
requester.failed(x);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Try again the idle connections
|
return;
|
||||||
return activate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +190,7 @@ public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
|
||||||
|
|
||||||
protected void removed(Connection connection)
|
protected void removed(Connection connection)
|
||||||
{
|
{
|
||||||
int pooled = connectionCount.decrementAndGet();
|
int pooled = connections.updateLo(-1);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Connection removed {} - pooled: {}", connection, pooled);
|
LOG.debug("Connection removed {} - pooled: {}", connection, pooled);
|
||||||
}
|
}
|
||||||
|
@ -184,7 +200,7 @@ public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
|
||||||
{
|
{
|
||||||
if (closed.compareAndSet(false, true))
|
if (closed.compareAndSet(false, true))
|
||||||
{
|
{
|
||||||
connectionCount.set(0);
|
connections.set(0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,21 +88,22 @@ public abstract class AbstractConnectorHttpClientTransport extends AbstractHttpC
|
||||||
context.put(SslClientConnectionFactory.SSL_PEER_HOST_CONTEXT_KEY, destination.getHost());
|
context.put(SslClientConnectionFactory.SSL_PEER_HOST_CONTEXT_KEY, destination.getHost());
|
||||||
context.put(SslClientConnectionFactory.SSL_PEER_PORT_CONTEXT_KEY, destination.getPort());
|
context.put(SslClientConnectionFactory.SSL_PEER_PORT_CONTEXT_KEY, destination.getPort());
|
||||||
|
|
||||||
|
boolean connected = true;
|
||||||
if (client.isConnectBlocking())
|
if (client.isConnectBlocking())
|
||||||
{
|
{
|
||||||
channel.socket().connect(address, (int)client.getConnectTimeout());
|
channel.socket().connect(address, (int)client.getConnectTimeout());
|
||||||
channel.configureBlocking(false);
|
channel.configureBlocking(false);
|
||||||
selectorManager.accept(channel, context);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
channel.configureBlocking(false);
|
channel.configureBlocking(false);
|
||||||
if (channel.connect(address))
|
connected = channel.connect(address);
|
||||||
|
}
|
||||||
|
if (connected)
|
||||||
selectorManager.accept(channel, context);
|
selectorManager.accept(channel, context);
|
||||||
else
|
else
|
||||||
selectorManager.connect(channel, context);
|
selectorManager.connect(channel, context);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Must catch all exceptions, since some like
|
// Must catch all exceptions, since some like
|
||||||
// UnresolvedAddressException are not IOExceptions.
|
// UnresolvedAddressException are not IOExceptions.
|
||||||
catch (Throwable x)
|
catch (Throwable x)
|
||||||
|
|
|
@ -64,6 +64,7 @@ import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||||
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
|
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
|
||||||
import org.eclipse.jetty.util.Fields;
|
import org.eclipse.jetty.util.Fields;
|
||||||
import org.eclipse.jetty.util.Jetty;
|
import org.eclipse.jetty.util.Jetty;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
import org.eclipse.jetty.util.Promise;
|
import org.eclipse.jetty.util.Promise;
|
||||||
import org.eclipse.jetty.util.SocketAddressResolver;
|
import org.eclipse.jetty.util.SocketAddressResolver;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
@ -213,7 +214,7 @@ public class HttpClient extends ContainerLifeCycle
|
||||||
byteBufferPool = new MappedByteBufferPool(2048,
|
byteBufferPool = new MappedByteBufferPool(2048,
|
||||||
executor instanceof ThreadPool.SizedThreadPool
|
executor instanceof ThreadPool.SizedThreadPool
|
||||||
? ((ThreadPool.SizedThreadPool)executor).getMaxThreads()/2
|
? ((ThreadPool.SizedThreadPool)executor).getMaxThreads()/2
|
||||||
: Runtime.getRuntime().availableProcessors()*2);
|
: ProcessorUtils.availableProcessors()*2);
|
||||||
addBean(byteBufferPool);
|
addBean(byteBufferPool);
|
||||||
|
|
||||||
if (scheduler == null)
|
if (scheduler == null)
|
||||||
|
|
|
@ -81,6 +81,17 @@ public class HttpContent implements Callback, Closeable
|
||||||
this.iterator = provider == null ? Collections.<ByteBuffer>emptyIterator() : provider.iterator();
|
this.iterator = provider == null ? Collections.<ByteBuffer>emptyIterator() : provider.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param buffer
|
||||||
|
* @return true if the buffer is the sentinel instance {@link CLOSE}
|
||||||
|
*/
|
||||||
|
private static boolean isTheCloseBuffer(ByteBuffer buffer)
|
||||||
|
{
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean isTheCloseBuffer = (buffer == CLOSE);
|
||||||
|
return isTheCloseBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether there is any content at all
|
* @return whether there is any content at all
|
||||||
*/
|
*/
|
||||||
|
@ -177,6 +188,7 @@ public class HttpContent implements Callback, Closeable
|
||||||
/**
|
/**
|
||||||
* @return whether the cursor has been advanced past the {@link #isLast() last} position.
|
* @return whether the cursor has been advanced past the {@link #isLast() last} position.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
public boolean isConsumed()
|
public boolean isConsumed()
|
||||||
{
|
{
|
||||||
return buffer == AFTER;
|
return buffer == AFTER;
|
||||||
|
@ -187,7 +199,7 @@ public class HttpContent implements Callback, Closeable
|
||||||
{
|
{
|
||||||
if (isConsumed())
|
if (isConsumed())
|
||||||
return;
|
return;
|
||||||
if (buffer == CLOSE)
|
if (isTheCloseBuffer(buffer))
|
||||||
return;
|
return;
|
||||||
if (iterator instanceof Callback)
|
if (iterator instanceof Callback)
|
||||||
((Callback)iterator).succeeded();
|
((Callback)iterator).succeeded();
|
||||||
|
@ -198,7 +210,7 @@ public class HttpContent implements Callback, Closeable
|
||||||
{
|
{
|
||||||
if (isConsumed())
|
if (isConsumed())
|
||||||
return;
|
return;
|
||||||
if (buffer == CLOSE)
|
if (isTheCloseBuffer(buffer))
|
||||||
return;
|
return;
|
||||||
if (iterator instanceof Callback)
|
if (iterator instanceof Callback)
|
||||||
((Callback)iterator).failed(x);
|
((Callback)iterator).failed(x);
|
||||||
|
|
|
@ -204,7 +204,10 @@ public class HttpRequest implements Request
|
||||||
{
|
{
|
||||||
if (uri == null)
|
if (uri == null)
|
||||||
uri = buildURI(true);
|
uri = buildURI(true);
|
||||||
return uri == NULL_URI ? null : uri;
|
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean isNullURI = (uri == NULL_URI);
|
||||||
|
return isNullURI ? null : uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class MultiplexConnectionPool extends AbstractConnectionPool implements S
|
||||||
private static final Logger LOG = Log.getLogger(MultiplexConnectionPool.class);
|
private static final Logger LOG = Log.getLogger(MultiplexConnectionPool.class);
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
private final HttpDestination destination;
|
||||||
private final Deque<Holder> idleConnections;
|
private final Deque<Holder> idleConnections;
|
||||||
private final Map<Connection, Holder> muxedConnections;
|
private final Map<Connection, Holder> muxedConnections;
|
||||||
private final Map<Connection, Holder> busyConnections;
|
private final Map<Connection, Holder> busyConnections;
|
||||||
|
@ -49,12 +50,26 @@ public class MultiplexConnectionPool extends AbstractConnectionPool implements S
|
||||||
public MultiplexConnectionPool(HttpDestination destination, int maxConnections, Callback requester, int maxMultiplex)
|
public MultiplexConnectionPool(HttpDestination destination, int maxConnections, Callback requester, int maxMultiplex)
|
||||||
{
|
{
|
||||||
super(destination, maxConnections, requester);
|
super(destination, maxConnections, requester);
|
||||||
|
this.destination = destination;
|
||||||
this.idleConnections = new ArrayDeque<>(maxConnections);
|
this.idleConnections = new ArrayDeque<>(maxConnections);
|
||||||
this.muxedConnections = new HashMap<>(maxConnections);
|
this.muxedConnections = new HashMap<>(maxConnections);
|
||||||
this.busyConnections = new HashMap<>(maxConnections);
|
this.busyConnections = new HashMap<>(maxConnections);
|
||||||
this.maxMultiplex = maxMultiplex;
|
this.maxMultiplex = maxMultiplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Connection acquire()
|
||||||
|
{
|
||||||
|
Connection connection = activate();
|
||||||
|
if (connection == null)
|
||||||
|
{
|
||||||
|
int maxPending = 1 + destination.getQueuedRequestCount() / getMaxMultiplex();
|
||||||
|
tryCreate(maxPending);
|
||||||
|
connection = activate();
|
||||||
|
}
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
protected void lock()
|
protected void lock()
|
||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.jetty.client.HttpDestination;
|
||||||
import org.eclipse.jetty.client.Origin;
|
import org.eclipse.jetty.client.Origin;
|
||||||
import org.eclipse.jetty.client.api.Connection;
|
import org.eclipse.jetty.client.api.Connection;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
import org.eclipse.jetty.util.Promise;
|
import org.eclipse.jetty.util.Promise;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ public class HttpClientTransportOverHTTP extends AbstractConnectorHttpClientTran
|
||||||
{
|
{
|
||||||
public HttpClientTransportOverHTTP()
|
public HttpClientTransportOverHTTP()
|
||||||
{
|
{
|
||||||
this(Math.max(1, Runtime.getRuntime().availableProcessors() / 2));
|
this(Math.max( 1, ProcessorUtils.availableProcessors() / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpClientTransportOverHTTP(int selectors)
|
public HttpClientTransportOverHTTP(int selectors)
|
||||||
|
|
|
@ -321,10 +321,10 @@ public class HttpSenderOverHTTP extends HttpSender
|
||||||
private void release()
|
private void release()
|
||||||
{
|
{
|
||||||
ByteBufferPool bufferPool = httpClient.getByteBufferPool();
|
ByteBufferPool bufferPool = httpClient.getByteBufferPool();
|
||||||
if (headerBuffer != BufferUtil.EMPTY_BUFFER)
|
if (!BufferUtil.isTheEmptyBuffer(headerBuffer))
|
||||||
bufferPool.release(headerBuffer);
|
bufferPool.release(headerBuffer);
|
||||||
headerBuffer = null;
|
headerBuffer = null;
|
||||||
if (chunkBuffer != BufferUtil.EMPTY_BUFFER)
|
if (!BufferUtil.isTheEmptyBuffer(chunkBuffer))
|
||||||
bufferPool.release(chunkBuffer);
|
bufferPool.release(chunkBuffer);
|
||||||
chunkBuffer = null;
|
chunkBuffer = null;
|
||||||
contentBuffer = null;
|
contentBuffer = null;
|
||||||
|
|
|
@ -589,6 +589,7 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
public ByteBuffer current;
|
public ByteBuffer current;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
public boolean hasNext()
|
public boolean hasNext()
|
||||||
{
|
{
|
||||||
if (current == null)
|
if (current == null)
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
|
import org.eclipse.jetty.util.thread.ExecutorThreadPool;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -58,7 +59,7 @@ public class HttpClientTLSTest
|
||||||
|
|
||||||
private void startServer(SslContextFactory sslContextFactory, Handler handler) throws Exception
|
private void startServer(SslContextFactory sslContextFactory, Handler handler) throws Exception
|
||||||
{
|
{
|
||||||
QueuedThreadPool serverThreads = new QueuedThreadPool();
|
ExecutorThreadPool serverThreads = new ExecutorThreadPool();
|
||||||
serverThreads.setName("server");
|
serverThreads.setName("server");
|
||||||
server = new Server(serverThreads);
|
server = new Server(serverThreads);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -45,12 +46,14 @@ public class RoundRobinConnectionPoolTest extends AbstractHttpClientServerTest
|
||||||
@Test
|
@Test
|
||||||
public void testRoundRobin() throws Exception
|
public void testRoundRobin() throws Exception
|
||||||
{
|
{
|
||||||
|
AtomicBoolean record = new AtomicBoolean();
|
||||||
List<Integer> remotePorts = new ArrayList<>();
|
List<Integer> remotePorts = new ArrayList<>();
|
||||||
start(new EmptyServerHandler()
|
start(new EmptyServerHandler()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void service(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
protected void service(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
|
if (record.get())
|
||||||
remotePorts.add(request.getRemotePort());
|
remotePorts.add(request.getRemotePort());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -58,10 +61,24 @@ public class RoundRobinConnectionPoolTest extends AbstractHttpClientServerTest
|
||||||
int maxConnections = 3;
|
int maxConnections = 3;
|
||||||
client.getTransport().setConnectionPoolFactory(destination -> new RoundRobinConnectionPool(destination, maxConnections, destination));
|
client.getTransport().setConnectionPoolFactory(destination -> new RoundRobinConnectionPool(destination, maxConnections, destination));
|
||||||
|
|
||||||
|
// Prime the connections, so that they are all opened
|
||||||
|
// before we actually test the round robin behavior.
|
||||||
|
String host = "localhost";
|
||||||
|
int port = connector.getLocalPort();
|
||||||
|
for (int i = 0; i < maxConnections; ++i)
|
||||||
|
{
|
||||||
|
ContentResponse response = client.newRequest(host, port)
|
||||||
|
.scheme(scheme)
|
||||||
|
.timeout(5, TimeUnit.SECONDS)
|
||||||
|
.send();
|
||||||
|
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
record.set(true);
|
||||||
int requests = 2 * maxConnections - 1;
|
int requests = 2 * maxConnections - 1;
|
||||||
for (int i = 0; i < requests; ++i)
|
for (int i = 0; i < requests; ++i)
|
||||||
{
|
{
|
||||||
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
|
ContentResponse response = client.newRequest(host, port)
|
||||||
.scheme(scheme)
|
.scheme(scheme)
|
||||||
.timeout(5, TimeUnit.SECONDS)
|
.timeout(5, TimeUnit.SECONDS)
|
||||||
.send();
|
.send();
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
|
@ -311,10 +312,12 @@ public class DeploymentManager extends ContainerLifeCycle
|
||||||
*/
|
*/
|
||||||
public Collection<App> getApps(Node node)
|
public Collection<App> getApps(Node node)
|
||||||
{
|
{
|
||||||
|
Objects.requireNonNull(node);
|
||||||
|
|
||||||
List<App> ret = new ArrayList<>();
|
List<App> ret = new ArrayList<>();
|
||||||
for (AppEntry entry : _apps)
|
for (AppEntry entry : _apps)
|
||||||
{
|
{
|
||||||
if (entry.lifecyleNode == node)
|
if (node.equals(entry.lifecyleNode))
|
||||||
{
|
{
|
||||||
ret.add(entry.app);
|
ret.add(entry.app);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,9 @@ public final class Edge
|
||||||
|
|
||||||
public Edge(Node from, Node to)
|
public Edge(Node from, Node to)
|
||||||
{
|
{
|
||||||
if (from==null || to==null || from==to)
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean sameObject = (from==to);
|
||||||
|
if (from==null || to==null || sameObject)
|
||||||
throw new IllegalArgumentException("from "+from+" to "+to);
|
throw new IllegalArgumentException("from "+from+" to "+to);
|
||||||
_from = from;
|
_from = from;
|
||||||
_to = to;
|
_to = to;
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class Graph
|
||||||
addNode(toNode=edge.getTo());
|
addNode(toNode=edge.getTo());
|
||||||
|
|
||||||
// replace edge with normalized edge
|
// replace edge with normalized edge
|
||||||
if (edge.getFrom()!=fromNode || edge.getTo()!=toNode)
|
if (!edge.getFrom().equals(fromNode) || !edge.getTo().equals(toNode))
|
||||||
edge=new Edge(fromNode,toNode);
|
edge=new Edge(fromNode,toNode);
|
||||||
|
|
||||||
this._edges.add(edge);
|
this._edges.add(edge);
|
||||||
|
@ -129,7 +129,7 @@ public class Graph
|
||||||
|
|
||||||
for (Edge edge : this._edges)
|
for (Edge edge : this._edges)
|
||||||
{
|
{
|
||||||
if ((edge.getFrom() == node) || (edge.getTo() == node))
|
if (edge.getFrom().equals(node) || edge.getTo().equals(node))
|
||||||
{
|
{
|
||||||
fromedges.add(edge);
|
fromedges.add(edge);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public class Graph
|
||||||
|
|
||||||
for (Edge edge : this._edges)
|
for (Edge edge : this._edges)
|
||||||
{
|
{
|
||||||
if (edge.getFrom() == from)
|
if (edge.getFrom().equals(from))
|
||||||
{
|
{
|
||||||
fromedges.add(edge);
|
fromedges.add(edge);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,9 @@ public class Graph
|
||||||
*/
|
*/
|
||||||
public Path getPath(Node from, Node to)
|
public Path getPath(Node from, Node to)
|
||||||
{
|
{
|
||||||
if (from == to)
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean sameObject = (from==to);
|
||||||
|
if (sameObject)
|
||||||
{
|
{
|
||||||
return new Path();
|
return new Path();
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class DeploymentManagerMBean extends ObjectMBean
|
||||||
List<String> ret = new ArrayList<>();
|
List<String> ret = new ArrayList<>();
|
||||||
for (DeploymentManager.AppEntry entry : _manager.getAppEntries())
|
for (DeploymentManager.AppEntry entry : _manager.getAppEntries())
|
||||||
{
|
{
|
||||||
if (entry.getLifecyleNode() == node)
|
if (node.equals(entry.getLifecyleNode()))
|
||||||
{
|
{
|
||||||
ret.add(toRef(entry.getApp()));
|
ret.add(toRef(entry.getApp()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ _____
|
||||||
|Version |Year |Home |JVM |Protocols |Servlet |JSP |Status
|
|Version |Year |Home |JVM |Protocols |Servlet |JSP |Status
|
||||||
|9.4 |2016- |Eclipse |1.8 |HTTP/1.1 (RFC 7230), HTTP/2 (RFC 7540), WebSocket (RFC 6455, JSR 356), FastCGI |3.1 |2.3 |Stable
|
|9.4 |2016- |Eclipse |1.8 |HTTP/1.1 (RFC 7230), HTTP/2 (RFC 7540), WebSocket (RFC 6455, JSR 356), FastCGI |3.1 |2.3 |Stable
|
||||||
|9.3 |2015- |Eclipse |1.8 |HTTP/1.1 (RFC 7230), HTTP/2 (RFC 7540), WebSocket (RFC 6455, JSR 356), FastCGI |3.1 |2.3 |Stable
|
|9.3 |2015- |Eclipse |1.8 |HTTP/1.1 (RFC 7230), HTTP/2 (RFC 7540), WebSocket (RFC 6455, JSR 356), FastCGI |3.1 |2.3 |Stable
|
||||||
|9.2 |2014- |Eclipse |1.7 |HTTP/1.1 RFC2616, javax.websocket, SPDY v3 |3.1 |2.3 |Deprecated / *End of Life January 2018*
|
|9.2 |2014-2018 |Eclipse |1.7 |HTTP/1.1 RFC2616, javax.websocket, SPDY v3 |3.1 |2.3 |Deprecated / *End of Life January 2018*
|
||||||
|8 |2009-2014 |Eclipse/Codehaus |1.6 |HTTP/1.1 RFC2616, WebSocket RFC 6455, SPDY v3 |3.0 |2.2 |Deprecated / *End of Life November 2014*
|
|8 |2009-2014 |Eclipse/Codehaus |1.6 |HTTP/1.1 RFC2616, WebSocket RFC 6455, SPDY v3 |3.0 |2.2 |Deprecated / *End of Life November 2014*
|
||||||
|7 |2008-2014 |Eclipse/Codehaus |1.5 |HTTP/1.1 RFC2616, WebSocket RFC 6455, SPDY v3 |2.5 |2.1 |Deprecated / *End of Life November 2014*
|
|7 |2008-2014 |Eclipse/Codehaus |1.5 |HTTP/1.1 RFC2616, WebSocket RFC 6455, SPDY v3 |2.5 |2.1 |Deprecated / *End of Life November 2014*
|
||||||
|6 |2006-2010 |Codehaus |1.4-1.5 |HTTP/1.1 RFC2616 |2.5 |2.0 |Deprecated / *End of Life November 2010*
|
|6 |2006-2010 |Codehaus |1.4-1.5 |HTTP/1.1 RFC2616 |2.5 |2.0 |Deprecated / *End of Life November 2010*
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.jetty.client.api.Request;
|
||||||
import org.eclipse.jetty.fcgi.FCGI;
|
import org.eclipse.jetty.fcgi.FCGI;
|
||||||
import org.eclipse.jetty.http.HttpFields;
|
import org.eclipse.jetty.http.HttpFields;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
import org.eclipse.jetty.util.Promise;
|
import org.eclipse.jetty.util.Promise;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
@ -44,7 +45,7 @@ public class HttpClientTransportOverFCGI extends AbstractConnectorHttpClientTran
|
||||||
|
|
||||||
public HttpClientTransportOverFCGI(String scriptRoot)
|
public HttpClientTransportOverFCGI(String scriptRoot)
|
||||||
{
|
{
|
||||||
this(Math.max(1, Runtime.getRuntime().availableProcessors() / 2), false, scriptRoot);
|
this( Math.max( 1, ProcessorUtils.availableProcessors() / 2), false, scriptRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpClientTransportOverFCGI(int selectors, boolean multiplexed, String scriptRoot)
|
public HttpClientTransportOverFCGI(int selectors, boolean multiplexed, String scriptRoot)
|
||||||
|
|
|
@ -127,7 +127,9 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
|
||||||
|
|
||||||
private void releaseBuffer(ByteBuffer buffer)
|
private void releaseBuffer(ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
assert this.buffer == buffer;
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean isCurrentBuffer = (this.buffer == buffer);
|
||||||
|
assert(isCurrentBuffer);
|
||||||
HttpClient client = destination.getHttpClient();
|
HttpClient client = destination.getHttpClient();
|
||||||
ByteBufferPool bufferPool = client.getByteBufferPool();
|
ByteBufferPool bufferPool = client.getByteBufferPool();
|
||||||
bufferPool.release(buffer);
|
bufferPool.release(buffer);
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.eclipse.jetty.http.HttpFields;
|
||||||
import org.eclipse.jetty.http.HttpHeader;
|
import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.http.HttpScheme;
|
import org.eclipse.jetty.http.HttpScheme;
|
||||||
import org.eclipse.jetty.proxy.AsyncProxyServlet;
|
import org.eclipse.jetty.proxy.AsyncProxyServlet;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specific implementation of {@link org.eclipse.jetty.proxy.AsyncProxyServlet.Transparent} for FastCGI.
|
* Specific implementation of {@link org.eclipse.jetty.proxy.AsyncProxyServlet.Transparent} for FastCGI.
|
||||||
|
@ -111,7 +112,7 @@ public class FastCGIProxyServlet extends AsyncProxyServlet.Transparent
|
||||||
String scriptRoot = config.getInitParameter(SCRIPT_ROOT_INIT_PARAM);
|
String scriptRoot = config.getInitParameter(SCRIPT_ROOT_INIT_PARAM);
|
||||||
if (scriptRoot == null)
|
if (scriptRoot == null)
|
||||||
throw new IllegalArgumentException("Mandatory parameter '" + SCRIPT_ROOT_INIT_PARAM + "' not configured");
|
throw new IllegalArgumentException("Mandatory parameter '" + SCRIPT_ROOT_INIT_PARAM + "' not configured");
|
||||||
int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
|
int selectors = Math.max( 1, ProcessorUtils.availableProcessors() / 2);
|
||||||
String value = config.getInitParameter("selectors");
|
String value = config.getInitParameter("selectors");
|
||||||
if (value != null)
|
if (value != null)
|
||||||
selectors = Integer.parseInt(value);
|
selectors = Integer.parseInt(value);
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||||
import org.eclipse.jetty.util.LeakDetector;
|
import org.eclipse.jetty.util.LeakDetector;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -60,7 +61,7 @@ public abstract class AbstractHttpClientServerTest
|
||||||
ServerFCGIConnectionFactory fcgiConnectionFactory = new ServerFCGIConnectionFactory(new HttpConfiguration());
|
ServerFCGIConnectionFactory fcgiConnectionFactory = new ServerFCGIConnectionFactory(new HttpConfiguration());
|
||||||
serverBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged());
|
serverBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged());
|
||||||
connector = new ServerConnector( server, null, null, serverBufferPool,
|
connector = new ServerConnector( server, null, null, serverBufferPool,
|
||||||
1, Math.max(1, Runtime.getRuntime().availableProcessors() / 2), fcgiConnectionFactory);
|
1, Math.max( 1, ProcessorUtils.availableProcessors() / 2), fcgiConnectionFactory);
|
||||||
// connector.setPort(9000);
|
// connector.setPort(9000);
|
||||||
|
|
||||||
server.addConnector(connector);
|
server.addConnector(connector);
|
||||||
|
|
|
@ -417,7 +417,9 @@ public class GZIPContentDecoder implements Destroyable
|
||||||
*/
|
*/
|
||||||
public void release(ByteBuffer buffer)
|
public void release(ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
if (_pool!=null && buffer!=BufferUtil.EMPTY_BUFFER)
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean isTheEmptyBuffer = (buffer==BufferUtil.EMPTY_BUFFER);
|
||||||
|
if (_pool!=null && !isTheEmptyBuffer)
|
||||||
_pool.release(buffer);
|
_pool.release(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,9 +276,12 @@ public class HttpField
|
||||||
|
|
||||||
public boolean isSameName(HttpField field)
|
public boolean isSameName(HttpField field)
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean sameObject = (field==this);
|
||||||
|
|
||||||
if (field==null)
|
if (field==null)
|
||||||
return false;
|
return false;
|
||||||
if (field==this)
|
if (sameObject)
|
||||||
return true;
|
return true;
|
||||||
if (_header!=null && _header==field.getHeader())
|
if (_header!=null && _header==field.getHeader())
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2025,6 +2025,7 @@ public class HttpParserTest
|
||||||
Assert.assertEquals(null, _bad);
|
Assert.assertEquals(null, _bad);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
public void testCachedField() throws Exception
|
public void testCachedField() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.http2.client;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.SocketAddress;
|
||||||
import java.nio.channels.SelectableChannel;
|
import java.nio.channels.SelectableChannel;
|
||||||
import java.nio.channels.SelectionKey;
|
import java.nio.channels.SelectionKey;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
|
@ -122,6 +123,8 @@ public class HTTP2Client extends ContainerLifeCycle
|
||||||
private int selectors = 1;
|
private int selectors = 1;
|
||||||
private long idleTimeout = 30000;
|
private long idleTimeout = 30000;
|
||||||
private long connectTimeout = 10000;
|
private long connectTimeout = 10000;
|
||||||
|
private boolean connectBlocking;
|
||||||
|
private SocketAddress bindAddress;
|
||||||
private int inputBufferSize = 8192;
|
private int inputBufferSize = 8192;
|
||||||
private List<String> protocols = Arrays.asList("h2", "h2-17", "h2-16", "h2-15", "h2-14");
|
private List<String> protocols = Arrays.asList("h2", "h2-17", "h2-16", "h2-15", "h2-14");
|
||||||
private int initialSessionRecvWindow = 16 * 1024 * 1024;
|
private int initialSessionRecvWindow = 16 * 1024 * 1024;
|
||||||
|
@ -266,6 +269,27 @@ public class HTTP2Client extends ContainerLifeCycle
|
||||||
selector.setConnectTimeout(connectTimeout);
|
selector.setConnectTimeout(connectTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("Whether the connect() operation is blocking")
|
||||||
|
public boolean isConnectBlocking()
|
||||||
|
{
|
||||||
|
return connectBlocking;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnectBlocking(boolean connectBlocking)
|
||||||
|
{
|
||||||
|
this.connectBlocking = connectBlocking;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SocketAddress getBindAddress()
|
||||||
|
{
|
||||||
|
return bindAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBindAddress(SocketAddress bindAddress)
|
||||||
|
{
|
||||||
|
this.bindAddress = bindAddress;
|
||||||
|
}
|
||||||
|
|
||||||
@ManagedAttribute("The size of the buffer used to read from the network")
|
@ManagedAttribute("The size of the buffer used to read from the network")
|
||||||
public int getInputBufferSize()
|
public int getInputBufferSize()
|
||||||
{
|
{
|
||||||
|
@ -325,10 +349,23 @@ public class HTTP2Client extends ContainerLifeCycle
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SocketChannel channel = SocketChannel.open();
|
SocketChannel channel = SocketChannel.open();
|
||||||
|
SocketAddress bindAddress = getBindAddress();
|
||||||
|
if (bindAddress != null)
|
||||||
|
channel.bind(bindAddress);
|
||||||
configure(channel);
|
configure(channel);
|
||||||
|
boolean connected = true;
|
||||||
|
if (isConnectBlocking())
|
||||||
|
{
|
||||||
|
channel.socket().connect(address, (int)getConnectTimeout());
|
||||||
channel.configureBlocking(false);
|
channel.configureBlocking(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
channel.configureBlocking(false);
|
||||||
|
connected = channel.connect(address);
|
||||||
|
}
|
||||||
context = contextFrom(sslContextFactory, address, listener, promise, context);
|
context = contextFrom(sslContextFactory, address, listener, promise, context);
|
||||||
if (channel.connect(address))
|
if (connected)
|
||||||
selector.accept(channel, context);
|
selector.accept(channel, context);
|
||||||
else
|
else
|
||||||
selector.connect(channel, context);
|
selector.connect(channel, context);
|
||||||
|
|
|
@ -124,15 +124,15 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
|
||||||
{
|
{
|
||||||
session.frames(null, this, prefaceFrame, settingsFrame);
|
session.frames(null, this, prefaceFrame, settingsFrame);
|
||||||
}
|
}
|
||||||
// Only start reading from server after we have sent the client preface,
|
|
||||||
// otherwise we risk to read the server preface (a SETTINGS frame) and
|
|
||||||
// reply to that before we have the chance to send the client preface.
|
|
||||||
super.onOpen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void succeeded()
|
public void succeeded()
|
||||||
{
|
{
|
||||||
|
// Only start reading from server after we have sent the client preface,
|
||||||
|
// otherwise we risk to read the server preface (a SETTINGS frame) and
|
||||||
|
// reply to that before we have the chance to send the client preface.
|
||||||
|
super.onOpen();
|
||||||
promise.succeeded(getSession());
|
promise.succeeded(getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,7 @@ public class StreamResetTest extends AbstractTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Wait for the reset to happen.
|
// Wait for the reset to happen.
|
||||||
Assert.assertTrue(resetLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(resetLatch.await(10, TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
catch (InterruptedException x)
|
catch (InterruptedException x)
|
||||||
{
|
{
|
||||||
|
@ -273,9 +273,9 @@ public class StreamResetTest extends AbstractTest
|
||||||
{
|
{
|
||||||
// Write some content after the stream has
|
// Write some content after the stream has
|
||||||
// been reset, it should throw an exception.
|
// been reset, it should throw an exception.
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
Thread.sleep(500);
|
Thread.sleep(100);
|
||||||
response.getOutputStream().write(data);
|
response.getOutputStream().write(data);
|
||||||
response.flushBuffer();
|
response.flushBuffer();
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ public class StreamResetTest extends AbstractTest
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.assertTrue(dataLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(dataLatch.await(10, TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -223,7 +223,7 @@ public class HTTP2Flusher extends IteratingCallback implements Dumpable
|
||||||
IStream stream = entry.stream;
|
IStream stream = entry.stream;
|
||||||
if (stream != null && !entry.isControl())
|
if (stream != null && !entry.isControl())
|
||||||
{
|
{
|
||||||
Object channel = stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
|
Object channel = stream.getAttachment();
|
||||||
if (channel instanceof WriteFlusher.Listener)
|
if (channel instanceof WriteFlusher.Listener)
|
||||||
((WriteFlusher.Listener)channel).onFlushed(update - Frame.HEADER_LENGTH);
|
((WriteFlusher.Listener)channel).onFlushed(update - Frame.HEADER_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
private int initialSessionRecvWindow;
|
private int initialSessionRecvWindow;
|
||||||
private boolean pushEnabled;
|
private boolean pushEnabled;
|
||||||
private long idleTime;
|
private long idleTime;
|
||||||
|
private GoAwayFrame closeFrame;
|
||||||
|
|
||||||
public HTTP2Session(Scheduler scheduler, EndPoint endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
|
public HTTP2Session(Scheduler scheduler, EndPoint endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
|
||||||
{
|
{
|
||||||
|
@ -430,6 +431,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
{
|
{
|
||||||
// We received a GO_AWAY, so try to write
|
// We received a GO_AWAY, so try to write
|
||||||
// what's in the queue and then disconnect.
|
// what's in the queue and then disconnect.
|
||||||
|
closeFrame = frame;
|
||||||
notifyClose(this, frame, new DisconnectCallback());
|
notifyClose(this, frame, new DisconnectCallback());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -597,8 +599,8 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
{
|
{
|
||||||
if (closed.compareAndSet(current, CloseState.LOCALLY_CLOSED))
|
if (closed.compareAndSet(current, CloseState.LOCALLY_CLOSED))
|
||||||
{
|
{
|
||||||
GoAwayFrame frame = newGoAwayFrame(error, reason);
|
closeFrame = newGoAwayFrame(CloseState.LOCALLY_CLOSED, error, reason);
|
||||||
control(null, callback, frame);
|
control(null, callback, closeFrame);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -614,7 +616,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GoAwayFrame newGoAwayFrame(int error, String reason)
|
private GoAwayFrame newGoAwayFrame(CloseState closeState, int error, String reason)
|
||||||
{
|
{
|
||||||
byte[] payload = null;
|
byte[] payload = null;
|
||||||
if (reason != null)
|
if (reason != null)
|
||||||
|
@ -623,7 +625,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
reason = reason.substring(0, Math.min(reason.length(), 32));
|
reason = reason.substring(0, Math.min(reason.length(), 32));
|
||||||
payload = reason.getBytes(StandardCharsets.UTF_8);
|
payload = reason.getBytes(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
return new GoAwayFrame(lastStreamId.get(), error, payload);
|
return new GoAwayFrame(closeState, lastStreamId.get(), error, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1125,7 +1127,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return String.format("%s@%x{l:%s <-> r:%s,sendWindow=%s,recvWindow=%s,streams=%d,%s}",
|
return String.format("%s@%x{l:%s <-> r:%s,sendWindow=%s,recvWindow=%s,streams=%d,%s,%s}",
|
||||||
getClass().getSimpleName(),
|
getClass().getSimpleName(),
|
||||||
hashCode(),
|
hashCode(),
|
||||||
getEndPoint().getLocalAddress(),
|
getEndPoint().getLocalAddress(),
|
||||||
|
@ -1133,7 +1135,8 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
sendWindow,
|
sendWindow,
|
||||||
recvWindow,
|
recvWindow,
|
||||||
streams.size(),
|
streams.size(),
|
||||||
closed);
|
closed,
|
||||||
|
closeFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ControlEntry extends HTTP2Flusher.Entry
|
private class ControlEntry extends HTTP2Flusher.Entry
|
||||||
|
@ -1453,7 +1456,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
|
|
||||||
private void complete()
|
private void complete()
|
||||||
{
|
{
|
||||||
frames(null, Callback.NOOP, newGoAwayFrame(ErrorCode.NO_ERROR.code, null), new DisconnectFrame());
|
frames(null, Callback.NOOP, newGoAwayFrame(CloseState.CLOSED, ErrorCode.NO_ERROR.code, null), new DisconnectFrame());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpa
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(HTTP2Stream.class);
|
private static final Logger LOG = Log.getLogger(HTTP2Stream.class);
|
||||||
|
|
||||||
|
private final AtomicReference<Object> attachment = new AtomicReference<>();
|
||||||
private final AtomicReference<ConcurrentMap<String, Object>> attributes = new AtomicReference<>();
|
private final AtomicReference<ConcurrentMap<String, Object>> attributes = new AtomicReference<>();
|
||||||
private final AtomicReference<CloseState> closeState = new AtomicReference<>(CloseState.NOT_CLOSED);
|
private final AtomicReference<CloseState> closeState = new AtomicReference<>(CloseState.NOT_CLOSED);
|
||||||
private final AtomicReference<Callback> writing = new AtomicReference<>();
|
private final AtomicReference<Callback> writing = new AtomicReference<>();
|
||||||
|
@ -73,6 +74,18 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpa
|
||||||
return streamId;
|
return streamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getAttachment()
|
||||||
|
{
|
||||||
|
return attachment.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAttachment(Object attachment)
|
||||||
|
{
|
||||||
|
this.attachment.set(attachment);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLocal()
|
public boolean isLocal()
|
||||||
{
|
{
|
||||||
|
@ -460,7 +473,7 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpa
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return String.format("%s@%x#%d{sendWindow=%s,recvWindow=%s,reset=%b,%s}", getClass().getSimpleName(),
|
return String.format("%s@%x#%d{sendWindow=%s,recvWindow=%s,reset=%b,%s,attachment=%s}", getClass().getSimpleName(),
|
||||||
hashCode(), getId(), sendWindow, recvWindow, isReset(), closeState);
|
hashCode(), getId(), sendWindow, recvWindow, isReset(), closeState, attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,17 @@ import org.eclipse.jetty.util.Callback;
|
||||||
public interface IStream extends Stream, Closeable
|
public interface IStream extends Stream, Closeable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* <p>The constant used as attribute key to store/retrieve the HTTP
|
* @return the object attached to this stream
|
||||||
* channel associated with this stream</p>
|
* @see #setAttachment(Object)
|
||||||
*
|
|
||||||
* @see #setAttribute(String, Object)
|
|
||||||
*/
|
*/
|
||||||
public static final String CHANNEL_ATTRIBUTE = IStream.class.getName() + ".channel";
|
public Object getAttachment();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attaches the given object to this stream for later retrieval.
|
||||||
|
*
|
||||||
|
* @param attachment the object to attach to this stream
|
||||||
|
*/
|
||||||
|
public void setAttachment(Object attachment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether this stream is local or remote
|
* @return whether this stream is local or remote
|
||||||
|
|
|
@ -20,17 +20,25 @@ package org.eclipse.jetty.http2.frames;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.http2.CloseState;
|
||||||
import org.eclipse.jetty.http2.ErrorCode;
|
import org.eclipse.jetty.http2.ErrorCode;
|
||||||
|
|
||||||
public class GoAwayFrame extends Frame
|
public class GoAwayFrame extends Frame
|
||||||
{
|
{
|
||||||
|
private final CloseState closeState;
|
||||||
private final int lastStreamId;
|
private final int lastStreamId;
|
||||||
private final int error;
|
private final int error;
|
||||||
private final byte[] payload;
|
private final byte[] payload;
|
||||||
|
|
||||||
public GoAwayFrame(int lastStreamId, int error, byte[] payload)
|
public GoAwayFrame(int lastStreamId, int error, byte[] payload)
|
||||||
|
{
|
||||||
|
this(CloseState.REMOTELY_CLOSED, lastStreamId, error, payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GoAwayFrame(CloseState closeState, int lastStreamId, int error, byte[] payload)
|
||||||
{
|
{
|
||||||
super(FrameType.GO_AWAY);
|
super(FrameType.GO_AWAY);
|
||||||
|
this.closeState = closeState;
|
||||||
this.lastStreamId = lastStreamId;
|
this.lastStreamId = lastStreamId;
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
|
@ -69,10 +77,11 @@ public class GoAwayFrame extends Frame
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
ErrorCode errorCode = ErrorCode.from(error);
|
ErrorCode errorCode = ErrorCode.from(error);
|
||||||
return String.format("%s,%d/%s/%s",
|
return String.format("%s,%d/%s/%s/%s",
|
||||||
super.toString(),
|
super.toString(),
|
||||||
lastStreamId,
|
lastStreamId,
|
||||||
errorCode != null ? errorCode.toString() : String.valueOf(error),
|
errorCode != null ? errorCode.toString() : String.valueOf(error),
|
||||||
tryConvertPayload());
|
tryConvertPayload(),
|
||||||
|
closeState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,7 @@ public class HpackContextTest
|
||||||
assertNull(ctx.get("name"));
|
assertNull(ctx.get("name"));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
public void testGetAddStatic()
|
public void testGetAddStatic()
|
||||||
{
|
{
|
||||||
HpackContext ctx = new HpackContext(4096);
|
HpackContext ctx = new HpackContext(4096);
|
||||||
|
|
|
@ -120,4 +120,13 @@ public class HttpChannelOverHTTP2 extends HttpChannel
|
||||||
super.exchangeTerminated(exchange, result);
|
super.exchangeTerminated(exchange, result);
|
||||||
release();
|
release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return String.format("%s[send=%s,recv=%s]",
|
||||||
|
super.toString(),
|
||||||
|
sender,
|
||||||
|
receiver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,14 +124,17 @@ public class HttpClientTransportOverHTTP2 extends AbstractHttpClientTransport
|
||||||
@Override
|
@Override
|
||||||
public void connect(InetSocketAddress address, Map<String, Object> context)
|
public void connect(InetSocketAddress address, Map<String, Object> context)
|
||||||
{
|
{
|
||||||
client.setConnectTimeout(getHttpClient().getConnectTimeout());
|
HttpClient httpClient = getHttpClient();
|
||||||
|
client.setConnectTimeout(httpClient.getConnectTimeout());
|
||||||
|
client.setConnectBlocking(httpClient.isConnectBlocking());
|
||||||
|
client.setBindAddress(httpClient.getBindAddress());
|
||||||
|
|
||||||
SessionListenerPromise listenerPromise = new SessionListenerPromise(context);
|
SessionListenerPromise listenerPromise = new SessionListenerPromise(context);
|
||||||
|
|
||||||
HttpDestinationOverHTTP2 destination = (HttpDestinationOverHTTP2)context.get(HTTP_DESTINATION_CONTEXT_KEY);
|
HttpDestinationOverHTTP2 destination = (HttpDestinationOverHTTP2)context.get(HTTP_DESTINATION_CONTEXT_KEY);
|
||||||
SslContextFactory sslContextFactory = null;
|
SslContextFactory sslContextFactory = null;
|
||||||
if (HttpScheme.HTTPS.is(destination.getScheme()))
|
if (HttpScheme.HTTPS.is(destination.getScheme()))
|
||||||
sslContextFactory = getHttpClient().getSslContextFactory();
|
sslContextFactory = httpClient.getSslContextFactory();
|
||||||
|
|
||||||
client.connect(sslContextFactory, address, listenerPromise, listenerPromise, context);
|
client.connect(sslContextFactory, address, listenerPromise, listenerPromise, context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.jetty.http.HttpFields;
|
||||||
import org.eclipse.jetty.http.HttpURI;
|
import org.eclipse.jetty.http.HttpURI;
|
||||||
import org.eclipse.jetty.http.HttpVersion;
|
import org.eclipse.jetty.http.HttpVersion;
|
||||||
import org.eclipse.jetty.http.MetaData;
|
import org.eclipse.jetty.http.MetaData;
|
||||||
|
import org.eclipse.jetty.http2.IStream;
|
||||||
import org.eclipse.jetty.http2.api.Stream;
|
import org.eclipse.jetty.http2.api.Stream;
|
||||||
import org.eclipse.jetty.http2.frames.DataFrame;
|
import org.eclipse.jetty.http2.frames.DataFrame;
|
||||||
import org.eclipse.jetty.http2.frames.HeadersFrame;
|
import org.eclipse.jetty.http2.frames.HeadersFrame;
|
||||||
|
@ -64,7 +65,8 @@ public class HttpSenderOverHTTP2 extends HttpSender
|
||||||
@Override
|
@Override
|
||||||
public void succeeded(Stream stream)
|
public void succeeded(Stream stream)
|
||||||
{
|
{
|
||||||
getHttpChannel().setStream(stream);
|
channel.setStream(stream);
|
||||||
|
((IStream)stream).setAttachment(channel);
|
||||||
stream.setIdleTimeout(request.getIdleTimeout());
|
stream.setIdleTimeout(request.getIdleTimeout());
|
||||||
|
|
||||||
if (content.hasContent() && !expects100Continue(request))
|
if (content.hasContent() && !expects100Continue(request))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||||
#org.eclipse.jetty.client.LEVEL=DEBUG
|
org.eclipse.jetty.client.LEVEL=DEBUG
|
||||||
org.eclipse.jetty.http2.hpack.LEVEL=INFO
|
org.eclipse.jetty.http2.hpack.LEVEL=INFO
|
||||||
#org.eclipse.jetty.http2.LEVEL=DEBUG
|
#org.eclipse.jetty.http2.LEVEL=DEBUG
|
||||||
#org.eclipse.jetty.io.ssl.LEVEL=DEBUG
|
#org.eclipse.jetty.io.ssl.LEVEL=DEBUG
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
@ -172,7 +173,7 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Processing {} on {}", frame, stream);
|
LOG.debug("Processing {} on {}", frame, stream);
|
||||||
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
|
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttachment();
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
{
|
{
|
||||||
Runnable task = channel.onRequestContent(frame, callback);
|
Runnable task = channel.onRequestContent(frame, callback);
|
||||||
|
@ -189,7 +190,7 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Processing trailers {} on {}", frame, stream);
|
LOG.debug("Processing trailers {} on {}", frame, stream);
|
||||||
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
|
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttachment();
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
{
|
{
|
||||||
Runnable task = channel.onRequestTrailers(frame);
|
Runnable task = channel.onRequestTrailers(frame);
|
||||||
|
@ -200,7 +201,7 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
|
||||||
|
|
||||||
public boolean onStreamTimeout(IStream stream, Throwable failure)
|
public boolean onStreamTimeout(IStream stream, Throwable failure)
|
||||||
{
|
{
|
||||||
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
|
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttachment();
|
||||||
boolean result = channel != null && channel.onStreamTimeout(failure, task -> offerTask(task, true));
|
boolean result = channel != null && channel.onStreamTimeout(failure, task -> offerTask(task, true));
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("{} idle timeout on {}: {}", result ? "Processed" : "Ignored", stream, failure);
|
LOG.debug("{} idle timeout on {}: {}", result ? "Processed" : "Ignored", stream, failure);
|
||||||
|
@ -211,7 +212,7 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Processing failure on {}: {}", stream, failure);
|
LOG.debug("Processing failure on {}: {}", stream, failure);
|
||||||
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
|
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttachment();
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
{
|
{
|
||||||
Runnable task = channel.onFailure(failure, callback);
|
Runnable task = channel.onFailure(failure, callback);
|
||||||
|
@ -227,13 +228,13 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
|
||||||
public boolean onSessionTimeout(Throwable failure)
|
public boolean onSessionTimeout(Throwable failure)
|
||||||
{
|
{
|
||||||
ISession session = getSession();
|
ISession session = getSession();
|
||||||
boolean result = true;
|
// Compute whether all requests are idle.
|
||||||
for (Stream stream : session.getStreams())
|
boolean result = session.getStreams().stream()
|
||||||
{
|
.map(stream -> (IStream)stream)
|
||||||
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
|
.map(stream -> (HttpChannelOverHTTP2)stream.getAttachment())
|
||||||
if (channel != null)
|
.filter(Objects::nonNull)
|
||||||
result &= channel.isRequestIdle();
|
.map(HttpChannelOverHTTP2::isRequestIdle)
|
||||||
}
|
.reduce(true, Boolean::logicalAnd);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("{} idle timeout on {}: {}", result ? "Processed" : "Ignored", session, failure);
|
LOG.debug("{} idle timeout on {}: {}", result ? "Processed" : "Ignored", session, failure);
|
||||||
return result;
|
return result;
|
||||||
|
@ -284,7 +285,7 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Creating channel {} for {}", channel, this);
|
LOG.debug("Creating channel {} for {}", channel, this);
|
||||||
}
|
}
|
||||||
stream.setAttribute(IStream.CHANNEL_ATTRIBUTE, channel);
|
stream.setAttachment(channel);
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +380,7 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
|
||||||
@Override
|
@Override
|
||||||
public void recycle()
|
public void recycle()
|
||||||
{
|
{
|
||||||
getStream().removeAttribute(IStream.CHANNEL_ATTRIBUTE);
|
getStream().setAttachment(null);
|
||||||
super.recycle();
|
super.recycle();
|
||||||
offerHttpChannel(this);
|
offerHttpChannel(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ public class HttpTransportOverHTTP2 implements HttpTransport
|
||||||
|
|
||||||
// Consume the existing queued data frames to
|
// Consume the existing queued data frames to
|
||||||
// avoid stalling the session flow control.
|
// avoid stalling the session flow control.
|
||||||
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttribute(IStream.CHANNEL_ATTRIBUTE);
|
HttpChannelOverHTTP2 channel = (HttpChannelOverHTTP2)stream.getAttachment();
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
channel.consumeInput();
|
channel.consumeInput();
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
||||||
throw new ClosedChannelException();
|
throw new ClosedChannelException();
|
||||||
|
|
||||||
ByteBuffer in = _inQ.peek();
|
ByteBuffer in = _inQ.peek();
|
||||||
if (BufferUtil.hasContent(in) || in==EOF)
|
if (BufferUtil.hasContent(in) || isEOF(in))
|
||||||
execute(_runFillable);
|
execute(_runFillable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
||||||
boolean fillable=false;
|
boolean fillable=false;
|
||||||
try(Locker.Lock lock = _locker.lock())
|
try(Locker.Lock lock = _locker.lock())
|
||||||
{
|
{
|
||||||
if (_inQ.peek()==EOF)
|
if (isEOF(_inQ.peek()))
|
||||||
throw new RuntimeIOException(new EOFException());
|
throw new RuntimeIOException(new EOFException());
|
||||||
boolean was_empty=_inQ.isEmpty();
|
boolean was_empty=_inQ.isEmpty();
|
||||||
if (in==null)
|
if (in==null)
|
||||||
|
@ -248,7 +248,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
||||||
boolean fillable=false;
|
boolean fillable=false;
|
||||||
try(Locker.Lock lock = _locker.lock())
|
try(Locker.Lock lock = _locker.lock())
|
||||||
{
|
{
|
||||||
if (_inQ.peek()==EOF)
|
if (isEOF(_inQ.peek()))
|
||||||
throw new RuntimeIOException(new EOFException());
|
throw new RuntimeIOException(new EOFException());
|
||||||
boolean was_empty=_inQ.isEmpty();
|
boolean was_empty=_inQ.isEmpty();
|
||||||
if (in==null)
|
if (in==null)
|
||||||
|
@ -415,7 +415,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ByteBuffer in= _inQ.peek();
|
ByteBuffer in= _inQ.peek();
|
||||||
if (in==EOF)
|
if (isEOF(in))
|
||||||
{
|
{
|
||||||
filled=-1;
|
filled=-1;
|
||||||
break;
|
break;
|
||||||
|
@ -550,4 +550,16 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
||||||
return String.format("%s[q=%d,q[0]=%s,o=%s]",super.toString(),q,b,o);
|
return String.format("%s[q=%d,q[0]=%s,o=%s]",super.toString(),q,b,o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* Compares a ByteBuffer Object to EOF by Reference
|
||||||
|
* @param buffer the input ByteBuffer to be compared to EOF
|
||||||
|
* @return Whether the reference buffer is equal to that of EOF
|
||||||
|
*/
|
||||||
|
private static boolean isEOF(ByteBuffer buffer)
|
||||||
|
{
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean is_EOF = (buffer==EOF);
|
||||||
|
return is_EOF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class ConnectionStatistics extends AbstractLifeCycle implements Connectio
|
||||||
_connections.decrement();
|
_connections.decrement();
|
||||||
|
|
||||||
long elapsed = System.currentTimeMillis() - connection.getCreatedTimeStamp();
|
long elapsed = System.currentTimeMillis() - connection.getCreatedTimeStamp();
|
||||||
_connectionsDuration.set(elapsed);
|
_connectionsDuration.record(elapsed);
|
||||||
|
|
||||||
long bytesIn = connection.getBytesIn();
|
long bytesIn = connection.getBytesIn();
|
||||||
if (bytesIn > 0)
|
if (bytesIn > 0)
|
||||||
|
|
|
@ -42,6 +42,7 @@ import java.util.concurrent.RejectedExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.io.ManagedSelector.Connect;
|
||||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||||
import org.eclipse.jetty.util.component.Dumpable;
|
import org.eclipse.jetty.util.component.Dumpable;
|
||||||
import org.eclipse.jetty.util.component.DumpableCollection;
|
import org.eclipse.jetty.util.component.DumpableCollection;
|
||||||
|
@ -185,24 +186,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
|
||||||
if (connect.timeout.cancel())
|
if (connect.timeout.cancel())
|
||||||
{
|
{
|
||||||
key.interestOps(0);
|
key.interestOps(0);
|
||||||
execute(new Runnable()
|
execute(new CreateEndPoint(connect,key));
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
createEndPoint(channel,key);
|
|
||||||
}
|
|
||||||
catch(Throwable failure)
|
|
||||||
{
|
|
||||||
closeNoExceptions(channel);
|
|
||||||
LOG.warn(String.valueOf(failure));
|
|
||||||
LOG.debug(failure);
|
|
||||||
connect.failed(failure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -730,6 +714,12 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
|
||||||
ManagedSelector.this._selectorManager.connectionFailed(channel, failure, attachment);
|
ManagedSelector.this._selectorManager.connectionFailed(channel, failure, attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return String.format("Connect@%x{%s,%s}",hashCode(),channel,attachment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CloseConnections implements SelectorUpdate
|
private class CloseConnections implements SelectorUpdate
|
||||||
|
@ -816,6 +806,39 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final class CreateEndPoint implements Runnable
|
||||||
|
{
|
||||||
|
private final Connect _connect;
|
||||||
|
private final SelectionKey _key;
|
||||||
|
|
||||||
|
private CreateEndPoint(Connect connect, SelectionKey key)
|
||||||
|
{
|
||||||
|
_connect = connect;
|
||||||
|
_key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
createEndPoint(_connect.channel,_key);
|
||||||
|
}
|
||||||
|
catch(Throwable failure)
|
||||||
|
{
|
||||||
|
closeNoExceptions(_connect.channel);
|
||||||
|
LOG.warn(String.valueOf(failure));
|
||||||
|
LOG.debug(failure);
|
||||||
|
_connect.failed(failure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return String.format("CreateEndPoint@%x{%s,%s}",hashCode(),_connect,_key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class DestroyEndPoint implements Runnable, Closeable
|
private class DestroyEndPoint implements Runnable, Closeable
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.IntUnaryOperator;
|
import java.util.function.IntUnaryOperator;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||||
|
@ -68,10 +69,10 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
|
||||||
if (executor instanceof ThreadPool.SizedThreadPool)
|
if (executor instanceof ThreadPool.SizedThreadPool)
|
||||||
{
|
{
|
||||||
int threads = ((ThreadPool.SizedThreadPool)executor).getMaxThreads();
|
int threads = ((ThreadPool.SizedThreadPool)executor).getMaxThreads();
|
||||||
int cpus = Runtime.getRuntime().availableProcessors();
|
int cpus = ProcessorUtils.availableProcessors();
|
||||||
return Math.max(1,Math.min(cpus/2,threads/16));
|
return Math.max(1,Math.min(cpus/2,threads/16));
|
||||||
}
|
}
|
||||||
return Math.max(1,Runtime.getRuntime().availableProcessors()/2);
|
return Math.max(1,ProcessorUtils.availableProcessors()/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SelectorManager(Executor executor, Scheduler scheduler)
|
protected SelectorManager(Executor executor, Scheduler scheduler)
|
||||||
|
|
|
@ -627,8 +627,12 @@ public class SslConnection extends AbstractConnection
|
||||||
|
|
||||||
// We also need an app buffer, but can use the passed buffer if it is big enough
|
// We also need an app buffer, but can use the passed buffer if it is big enough
|
||||||
ByteBuffer app_in;
|
ByteBuffer app_in;
|
||||||
|
boolean used_passed_buffer = false;
|
||||||
if (BufferUtil.space(buffer) > _sslEngine.getSession().getApplicationBufferSize())
|
if (BufferUtil.space(buffer) > _sslEngine.getSession().getApplicationBufferSize())
|
||||||
|
{
|
||||||
app_in = buffer;
|
app_in = buffer;
|
||||||
|
used_passed_buffer = true;
|
||||||
|
}
|
||||||
else if (_decryptedInput == null)
|
else if (_decryptedInput == null)
|
||||||
app_in = _decryptedInput = _bufferPool.acquire(_sslEngine.getSession().getApplicationBufferSize(), _decryptedDirectBuffers);
|
app_in = _decryptedInput = _bufferPool.acquire(_sslEngine.getSession().getApplicationBufferSize(), _decryptedDirectBuffers);
|
||||||
else
|
else
|
||||||
|
@ -730,7 +734,7 @@ public class SslConnection extends AbstractConnection
|
||||||
// another call to fill() or flush().
|
// another call to fill() or flush().
|
||||||
if (unwrapResult.bytesProduced() > 0)
|
if (unwrapResult.bytesProduced() > 0)
|
||||||
{
|
{
|
||||||
if (app_in == buffer)
|
if (used_passed_buffer)
|
||||||
return unwrapResult.bytesProduced();
|
return unwrapResult.bytesProduced();
|
||||||
return BufferUtil.append(buffer,_decryptedInput);
|
return BufferUtil.append(buffer,_decryptedInput);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Arrays;
|
||||||
import org.eclipse.jetty.io.ByteBufferPool.Bucket;
|
import org.eclipse.jetty.io.ByteBufferPool.Bucket;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
public class ArrayByteBufferPoolTest
|
public class ArrayByteBufferPoolTest
|
||||||
{
|
{
|
||||||
@Test
|
@Test
|
||||||
|
@ -113,6 +114,7 @@ public class ArrayByteBufferPoolTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
public void testAcquireReleaseAcquire() throws Exception
|
public void testAcquireReleaseAcquire() throws Exception
|
||||||
{
|
{
|
||||||
ArrayByteBufferPool bufferPool = new ArrayByteBufferPool(10,100,1000);
|
ArrayByteBufferPool bufferPool = new ArrayByteBufferPool(10,100,1000);
|
||||||
|
|
|
@ -317,8 +317,8 @@ public class ByteArrayEndPointTest
|
||||||
|
|
||||||
// Write more than the output capacity, then wait for idle timeout.
|
// Write more than the output capacity, then wait for idle timeout.
|
||||||
fcb = new FutureCallback();
|
fcb = new FutureCallback();
|
||||||
endp.write(fcb, BufferUtil.toBuffer("This is too long"));
|
|
||||||
start = System.nanoTime();
|
start = System.nanoTime();
|
||||||
|
endp.write(fcb, BufferUtil.toBuffer("This is too long"));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fcb.get();
|
fcb.get();
|
||||||
|
|
|
@ -446,6 +446,7 @@ public class SelectChannelEndPointTest
|
||||||
_manager.accept(server);
|
_manager.accept(server);
|
||||||
|
|
||||||
// Write client to server
|
// Write client to server
|
||||||
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
client.getOutputStream().write("HelloWorld".getBytes(StandardCharsets.UTF_8));
|
client.getOutputStream().write("HelloWorld".getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
// Verify echo server to client
|
// Verify echo server to client
|
||||||
|
@ -457,7 +458,6 @@ public class SelectChannelEndPointTest
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertTrue(_lastEndPointLatch.await(1, TimeUnit.SECONDS));
|
Assert.assertTrue(_lastEndPointLatch.await(1, TimeUnit.SECONDS));
|
||||||
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
|
||||||
_lastEndPoint.setIdleTimeout(idleTimeout);
|
_lastEndPoint.setIdleTimeout(idleTimeout);
|
||||||
|
|
||||||
// read until idle shutdown received
|
// read until idle shutdown received
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
<mavenVersion>3.5.0</mavenVersion>
|
<mavenVersion>3.5.0</mavenVersion>
|
||||||
<pluginToolsVersion>3.5</pluginToolsVersion>
|
<pluginToolsVersion>3.5</pluginToolsVersion>
|
||||||
<bundle-symbolic-name>${project.groupId}.maven.plugin</bundle-symbolic-name>
|
<bundle-symbolic-name>${project.groupId}.maven.plugin</bundle-symbolic-name>
|
||||||
<surefireVersion>2.20.1</surefireVersion>
|
|
||||||
<it.debug>false</it.debug>
|
<it.debug>false</it.debug>
|
||||||
<jetty.stopKey>FREEBEER</jetty.stopKey>
|
<jetty.stopKey>FREEBEER</jetty.stopKey>
|
||||||
<jetty.jvmArgs></jetty.jvmArgs>
|
<jetty.jvmArgs></jetty.jvmArgs>
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.20</version>
|
<version>@surefireVersion@</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.20</version>
|
<version>@surefireVersion@</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.20</version>
|
<version>@surefireVersion@</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.20</version>
|
<version>@surefireVersion@</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import javax.servlet.ServletContainerInitializer;
|
import javax.servlet.ServletContainerInitializer;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationParser.Handler;
|
import org.eclipse.jetty.annotations.AnnotationParser.Handler;
|
||||||
import org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration;
|
import org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration;
|
||||||
import org.eclipse.jetty.osgi.boot.OSGiWebappConstants;
|
import org.eclipse.jetty.osgi.boot.OSGiWebappConstants;
|
||||||
|
@ -117,6 +116,7 @@ public class AnnotationConfiguration extends org.eclipse.jetty.annotations.Annot
|
||||||
_webInfLibStats = new CounterStatistic();
|
_webInfLibStats = new CounterStatistic();
|
||||||
|
|
||||||
Bundle webbundle = (Bundle) context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE);
|
Bundle webbundle = (Bundle) context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Set<Bundle> fragAndRequiredBundles = (Set<Bundle>)context.getAttribute(OSGiWebInfConfiguration.FRAGMENT_AND_REQUIRED_BUNDLES);
|
Set<Bundle> fragAndRequiredBundles = (Set<Bundle>)context.getAttribute(OSGiWebInfConfiguration.FRAGMENT_AND_REQUIRED_BUNDLES);
|
||||||
if (fragAndRequiredBundles != null)
|
if (fragAndRequiredBundles != null)
|
||||||
{
|
{
|
||||||
|
@ -230,7 +230,7 @@ public class AnnotationConfiguration extends org.eclipse.jetty.annotations.Annot
|
||||||
{
|
{
|
||||||
|
|
||||||
Resource bundleRes = parser.getResource(bundle);
|
Resource bundleRes = parser.getResource(bundle);
|
||||||
Set<Handler> handlers = new HashSet<Handler>();
|
Set<Handler> handlers = new HashSet<>();
|
||||||
handlers.addAll(_discoverableAnnotationHandlers);
|
handlers.addAll(_discoverableAnnotationHandlers);
|
||||||
if (_classInheritanceHandler != null)
|
if (_classInheritanceHandler != null)
|
||||||
handlers.add(_classInheritanceHandler);
|
handlers.add(_classInheritanceHandler);
|
||||||
|
|
|
@ -42,10 +42,10 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa
|
||||||
{
|
{
|
||||||
private Set<URI> _alreadyParsed = ConcurrentHashMap.newKeySet();
|
private Set<URI> _alreadyParsed = ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
private ConcurrentHashMap<URI,Bundle> _uriToBundle = new ConcurrentHashMap<URI, Bundle>();
|
private ConcurrentHashMap<URI,Bundle> _uriToBundle = new ConcurrentHashMap<>();
|
||||||
private ConcurrentHashMap<Bundle,Resource> _bundleToResource = new ConcurrentHashMap<Bundle,Resource>();
|
private ConcurrentHashMap<Bundle,Resource> _bundleToResource = new ConcurrentHashMap<>();
|
||||||
private ConcurrentHashMap<Resource, Bundle> _resourceToBundle = new ConcurrentHashMap<Resource, Bundle>();
|
private ConcurrentHashMap<Resource, Bundle> _resourceToBundle = new ConcurrentHashMap<>();
|
||||||
private ConcurrentHashMap<Bundle,URI> _bundleToUri = new ConcurrentHashMap<Bundle, URI>();
|
private ConcurrentHashMap<Bundle,URI> _bundleToUri = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public AnnotationParser(int javaPlatform)
|
public AnnotationParser(int javaPlatform)
|
||||||
{
|
{
|
||||||
|
@ -126,7 +126,7 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa
|
||||||
bundleClasspath = ".";
|
bundleClasspath = ".";
|
||||||
}
|
}
|
||||||
//order the paths first by the number of tokens in the path second alphabetically.
|
//order the paths first by the number of tokens in the path second alphabetically.
|
||||||
TreeSet<String> paths = new TreeSet<String>(
|
TreeSet<String> paths = new TreeSet<>(
|
||||||
new Comparator<String>()
|
new Comparator<String>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -177,6 +177,7 @@ public class AnnotationParser extends org.eclipse.jetty.annotations.AnnotationPa
|
||||||
paths.add("/target/classes/");
|
paths.add("/target/classes/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
Enumeration classes = bundle.findEntries("/","*.class",true);
|
Enumeration classes = bundle.findEntries("/","*.class",true);
|
||||||
if (classes == null)
|
if (classes == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class BundleWebAppProvider extends AbstractWebAppProvider implements Bund
|
||||||
/**
|
/**
|
||||||
* Map of Bundle to App. Used when a Bundle contains a webapp.
|
* Map of Bundle to App. Used when a Bundle contains a webapp.
|
||||||
*/
|
*/
|
||||||
private Map<Bundle, App> _bundleMap = new HashMap<Bundle, App>();
|
private Map<Bundle, App> _bundleMap = new HashMap<>();
|
||||||
|
|
||||||
private ServiceRegistration _serviceRegForBundles;
|
private ServiceRegistration _serviceRegForBundles;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class BundleWebAppProvider extends AbstractWebAppProvider implements Bund
|
||||||
_webappTracker = new WebAppTracker(FrameworkUtil.getBundle(this.getClass()).getBundleContext(), getServerInstanceWrapper().getManagedServerName());
|
_webappTracker = new WebAppTracker(FrameworkUtil.getBundle(this.getClass()).getBundleContext(), getServerInstanceWrapper().getManagedServerName());
|
||||||
_webappTracker.open();
|
_webappTracker.open();
|
||||||
//register as an osgi service for deploying bundles, advertising the name of the jetty Server instance we are related to
|
//register as an osgi service for deploying bundles, advertising the name of the jetty Server instance we are related to
|
||||||
Dictionary<String,String> properties = new Hashtable<String,String>();
|
Dictionary<String,String> properties = new Hashtable<>();
|
||||||
properties.put(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME, getServerInstanceWrapper().getManagedServerName());
|
properties.put(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME, getServerInstanceWrapper().getManagedServerName());
|
||||||
_serviceRegForBundles = FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(BundleProvider.class.getName(), this, properties);
|
_serviceRegForBundles = FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(BundleProvider.class.getName(), this, properties);
|
||||||
super.doStart();
|
super.doStart();
|
||||||
|
@ -177,6 +177,7 @@ public class BundleWebAppProvider extends AbstractWebAppProvider implements Bund
|
||||||
String contextPath = null;
|
String contextPath = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Dictionary<String,String> headers = bundle.getHeaders();
|
Dictionary<String,String> headers = bundle.getHeaders();
|
||||||
|
|
||||||
//does the bundle have a OSGiWebappConstants.JETTY_WAR_FOLDER_PATH
|
//does the bundle have a OSGiWebappConstants.JETTY_WAR_FOLDER_PATH
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class JettyBootstrapActivator implements BundleActivator
|
||||||
_jettyServerServiceTracker.open();
|
_jettyServerServiceTracker.open();
|
||||||
|
|
||||||
// Create a default jetty instance right now.
|
// Create a default jetty instance right now.
|
||||||
Server defaultServer = DefaultJettyAtJettyHomeHelper.startJettyAtJettyHome(context);
|
DefaultJettyAtJettyHomeHelper.startJettyAtJettyHome(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
||||||
// 2. DeployerManager.setContextAttribute CONTAINER_BUNDLE_PATTERN
|
// 2. DeployerManager.setContextAttribute CONTAINER_BUNDLE_PATTERN
|
||||||
String tmp = (String)context.getAttribute(CONTAINER_BUNDLE_PATTERN);
|
String tmp = (String)context.getAttribute(CONTAINER_BUNDLE_PATTERN);
|
||||||
Pattern pattern = (tmp==null?null:Pattern.compile(tmp));
|
Pattern pattern = (tmp==null?null:Pattern.compile(tmp));
|
||||||
List<String> names = new ArrayList<String>();
|
List<String> names = new ArrayList<>();
|
||||||
tmp = System.getProperty(SYS_PROP_TLD_BUNDLES);
|
tmp = System.getProperty(SYS_PROP_TLD_BUNDLES);
|
||||||
if (tmp != null)
|
if (tmp != null)
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
||||||
while (tokenizer.hasMoreTokens())
|
while (tokenizer.hasMoreTokens())
|
||||||
names.add(tokenizer.nextToken());
|
names.add(tokenizer.nextToken());
|
||||||
}
|
}
|
||||||
HashSet<Resource> matchingResources = new HashSet<Resource>();
|
HashSet<Resource> matchingResources = new HashSet<>();
|
||||||
if ( !names.isEmpty() || pattern != null)
|
if ( !names.isEmpty() || pattern != null)
|
||||||
{
|
{
|
||||||
Bundle[] bundles = FrameworkUtil.getBundle(OSGiWebInfConfiguration.class).getBundleContext().getBundles();
|
Bundle[] bundles = FrameworkUtil.getBundle(OSGiWebInfConfiguration.class).getBundleContext().getBundles();
|
||||||
|
@ -153,7 +153,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
||||||
protected List<Resource> findJars (WebAppContext context)
|
protected List<Resource> findJars (WebAppContext context)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
List<Resource> mergedResources = new ArrayList<Resource>();
|
List<Resource> mergedResources = new ArrayList<>();
|
||||||
//get jars from WEB-INF/lib if there are any
|
//get jars from WEB-INF/lib if there are any
|
||||||
List<Resource> webInfJars = super.findJars(context);
|
List<Resource> webInfJars = super.findJars(context);
|
||||||
if (webInfJars != null)
|
if (webInfJars != null)
|
||||||
|
@ -163,17 +163,19 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
||||||
Bundle[] bundles = PackageAdminServiceTracker.INSTANCE.getFragmentsAndRequiredBundles((Bundle)context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE));
|
Bundle[] bundles = PackageAdminServiceTracker.INSTANCE.getFragmentsAndRequiredBundles((Bundle)context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE));
|
||||||
if (bundles != null && bundles.length > 0)
|
if (bundles != null && bundles.length > 0)
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Set<Bundle> fragsAndReqsBundles = (Set<Bundle>)context.getAttribute(FRAGMENT_AND_REQUIRED_BUNDLES);
|
Set<Bundle> fragsAndReqsBundles = (Set<Bundle>)context.getAttribute(FRAGMENT_AND_REQUIRED_BUNDLES);
|
||||||
if (fragsAndReqsBundles == null)
|
if (fragsAndReqsBundles == null)
|
||||||
{
|
{
|
||||||
fragsAndReqsBundles = new HashSet<Bundle>();
|
fragsAndReqsBundles = new HashSet<>();
|
||||||
context.setAttribute(FRAGMENT_AND_REQUIRED_BUNDLES, fragsAndReqsBundles);
|
context.setAttribute(FRAGMENT_AND_REQUIRED_BUNDLES, fragsAndReqsBundles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Set<Resource> fragsAndReqsResources = (Set<Resource>)context.getAttribute(FRAGMENT_AND_REQUIRED_RESOURCES);
|
Set<Resource> fragsAndReqsResources = (Set<Resource>)context.getAttribute(FRAGMENT_AND_REQUIRED_RESOURCES);
|
||||||
if (fragsAndReqsResources == null)
|
if (fragsAndReqsResources == null)
|
||||||
{
|
{
|
||||||
fragsAndReqsResources = new HashSet<Resource>();
|
fragsAndReqsResources = new HashSet<>();
|
||||||
context.setAttribute(FRAGMENT_AND_REQUIRED_RESOURCES, fragsAndReqsResources);
|
context.setAttribute(FRAGMENT_AND_REQUIRED_RESOURCES, fragsAndReqsResources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,12 +209,13 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
||||||
@Override
|
@Override
|
||||||
public void configure(WebAppContext context) throws Exception
|
public void configure(WebAppContext context) throws Exception
|
||||||
{
|
{
|
||||||
TreeMap<String, Resource> prependedResourcesPath = new TreeMap<String, Resource>();
|
TreeMap<String, Resource> prependedResourcesPath = new TreeMap<>();
|
||||||
TreeMap<String, Resource> appendedResourcesPath = new TreeMap<String, Resource>();
|
TreeMap<String, Resource> appendedResourcesPath = new TreeMap<>();
|
||||||
|
|
||||||
Bundle bundle = (Bundle)context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE);
|
Bundle bundle = (Bundle)context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE);
|
||||||
if (bundle != null)
|
if (bundle != null)
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Set<Bundle> fragments = (Set<Bundle>)context.getAttribute(FRAGMENT_AND_REQUIRED_BUNDLES);
|
Set<Bundle> fragments = (Set<Bundle>)context.getAttribute(FRAGMENT_AND_REQUIRED_BUNDLES);
|
||||||
if (fragments != null && !fragments.isEmpty())
|
if (fragments != null && !fragments.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -238,8 +241,9 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
||||||
}
|
}
|
||||||
if (!appendedResourcesPath.isEmpty())
|
if (!appendedResourcesPath.isEmpty())
|
||||||
{
|
{
|
||||||
LinkedHashSet<Resource> resources = new LinkedHashSet<Resource>();
|
LinkedHashSet<Resource> resources = new LinkedHashSet<>();
|
||||||
//Add in any existing setting of extra resource dirs
|
//Add in any existing setting of extra resource dirs
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Set<Resource> resourceDirs = (Set<Resource>)context.getAttribute(WebInfConfiguration.RESOURCE_DIRS);
|
Set<Resource> resourceDirs = (Set<Resource>)context.getAttribute(WebInfConfiguration.RESOURCE_DIRS);
|
||||||
if (resourceDirs != null && !resourceDirs.isEmpty())
|
if (resourceDirs != null && !resourceDirs.isEmpty())
|
||||||
resources.addAll(resourceDirs);
|
resources.addAll(resourceDirs);
|
||||||
|
@ -272,7 +276,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
||||||
private List<Resource> getBundleAsResource(Bundle bundle)
|
private List<Resource> getBundleAsResource(Bundle bundle)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
List<Resource> resources = new ArrayList<Resource>();
|
List<Resource> resources = new ArrayList<>();
|
||||||
|
|
||||||
File file = BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(bundle);
|
File file = BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(bundle);
|
||||||
if (file.isDirectory())
|
if (file.isDirectory())
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.eclipse.jetty.deploy.DeploymentManager;
|
||||||
import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
|
import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
|
||||||
import org.eclipse.jetty.osgi.boot.utils.Util;
|
import org.eclipse.jetty.osgi.boot.utils.Util;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
@ -52,7 +51,7 @@ public class ServiceContextProvider extends AbstractContextProvider implements S
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(AbstractContextProvider.class);
|
private static final Logger LOG = Log.getLogger(AbstractContextProvider.class);
|
||||||
|
|
||||||
private Map<ServiceReference, App> _serviceMap = new HashMap<ServiceReference, App>();
|
private Map<ServiceReference, App> _serviceMap = new HashMap<>();
|
||||||
|
|
||||||
private ServiceRegistration _serviceRegForServices;
|
private ServiceRegistration _serviceRegForServices;
|
||||||
|
|
||||||
|
@ -169,7 +168,7 @@ public class ServiceContextProvider extends AbstractContextProvider implements S
|
||||||
contextFile = (String)serviceRef.getProperty(OSGiWebappConstants.SERVICE_PROP_CONTEXT_FILE_PATH);
|
contextFile = (String)serviceRef.getProperty(OSGiWebappConstants.SERVICE_PROP_CONTEXT_FILE_PATH);
|
||||||
|
|
||||||
String[] keys = serviceRef.getPropertyKeys();
|
String[] keys = serviceRef.getPropertyKeys();
|
||||||
Dictionary properties = new Hashtable<String, Object>();
|
Dictionary<String,Object> properties = new Hashtable<>();
|
||||||
if (keys != null)
|
if (keys != null)
|
||||||
{
|
{
|
||||||
for (String key:keys)
|
for (String key:keys)
|
||||||
|
@ -228,7 +227,7 @@ public class ServiceContextProvider extends AbstractContextProvider implements S
|
||||||
|
|
||||||
|
|
||||||
//register as an osgi service for deploying contexts defined in a bundle, advertising the name of the jetty Server instance we are related to
|
//register as an osgi service for deploying contexts defined in a bundle, advertising the name of the jetty Server instance we are related to
|
||||||
Dictionary<String,String> properties = new Hashtable<String,String>();
|
Dictionary<String,String> properties = new Hashtable<>();
|
||||||
properties.put(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME, getServerInstanceWrapper().getManagedServerName());
|
properties.put(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME, getServerInstanceWrapper().getManagedServerName());
|
||||||
|
|
||||||
//register as an osgi service for deploying contexts, advertising the name of the jetty Server instance we are related to
|
//register as an osgi service for deploying contexts, advertising the name of the jetty Server instance we are related to
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.eclipse.jetty.deploy.DeploymentManager;
|
||||||
import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
|
import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
|
||||||
import org.eclipse.jetty.osgi.boot.utils.Util;
|
import org.eclipse.jetty.osgi.boot.utils.Util;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
@ -53,7 +52,7 @@ public class ServiceWebAppProvider extends AbstractWebAppProvider implements Ser
|
||||||
/**
|
/**
|
||||||
* Map of ServiceRef to App. Used when it is an osgi service that is a WebAppContext.
|
* Map of ServiceRef to App. Used when it is an osgi service that is a WebAppContext.
|
||||||
*/
|
*/
|
||||||
private Map<ServiceReference, App> _serviceMap = new HashMap<ServiceReference, App>();
|
private Map<ServiceReference, App> _serviceMap = new HashMap<>();
|
||||||
|
|
||||||
private ServiceRegistration _serviceRegForServices;
|
private ServiceRegistration _serviceRegForServices;
|
||||||
|
|
||||||
|
@ -117,7 +116,7 @@ public class ServiceWebAppProvider extends AbstractWebAppProvider implements Ser
|
||||||
public class ServiceApp extends OSGiApp
|
public class ServiceApp extends OSGiApp
|
||||||
{
|
{
|
||||||
|
|
||||||
public ServiceApp(DeploymentManager manager, AppProvider provider, Bundle bundle, Dictionary properties, String originId)
|
public ServiceApp(DeploymentManager manager, AppProvider provider, Bundle bundle, Dictionary<String,String> properties, String originId)
|
||||||
{
|
{
|
||||||
super(manager, provider, bundle, properties, originId);
|
super(manager, provider, bundle, properties, originId);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +167,7 @@ public class ServiceWebAppProvider extends AbstractWebAppProvider implements Ser
|
||||||
|
|
||||||
|
|
||||||
WebAppContext webApp = (WebAppContext)context;
|
WebAppContext webApp = (WebAppContext)context;
|
||||||
Dictionary properties = new Hashtable<String,String>();
|
Dictionary<String,String> properties = new Hashtable<>();
|
||||||
|
|
||||||
String contextPath = (String)serviceRef.getProperty(OSGiWebappConstants.RFC66_WEB_CONTEXTPATH);
|
String contextPath = (String)serviceRef.getProperty(OSGiWebappConstants.RFC66_WEB_CONTEXTPATH);
|
||||||
if (contextPath == null)
|
if (contextPath == null)
|
||||||
|
@ -275,7 +274,7 @@ public class ServiceWebAppProvider extends AbstractWebAppProvider implements Ser
|
||||||
webappTracker.open();
|
webappTracker.open();
|
||||||
|
|
||||||
//register as an osgi service for deploying bundles, advertising the name of the jetty Server instance we are related to
|
//register as an osgi service for deploying bundles, advertising the name of the jetty Server instance we are related to
|
||||||
Dictionary<String,String> properties = new Hashtable<String,String>();
|
Dictionary<String,String> properties = new Hashtable<>();
|
||||||
properties.put(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME, getServerInstanceWrapper().getManagedServerName());
|
properties.put(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME, getServerInstanceWrapper().getManagedServerName());
|
||||||
|
|
||||||
//register as an osgi service for deploying contexts (discovered as osgi services), advertising the name of the jetty Server instance we are related to
|
//register as an osgi service for deploying contexts (discovered as osgi services), advertising the name of the jetty Server instance we are related to
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class DefaultJettyAtJettyHomeHelper
|
||||||
File jettyHomeDir = null;
|
File jettyHomeDir = null;
|
||||||
Bundle jettyHomeBundle = null;
|
Bundle jettyHomeBundle = null;
|
||||||
|
|
||||||
Dictionary<String,String> properties = new Hashtable<String,String>();
|
Dictionary<String, Object> properties = new Hashtable<>();
|
||||||
if (jettyHomeSysProp != null)
|
if (jettyHomeSysProp != null)
|
||||||
{
|
{
|
||||||
jettyHomeSysProp = Util.resolvePropertyValue(jettyHomeSysProp);
|
jettyHomeSysProp = Util.resolvePropertyValue(jettyHomeSysProp);
|
||||||
|
@ -157,8 +157,8 @@ public class DefaultJettyAtJettyHomeHelper
|
||||||
List<URL> configURLs = jettyHomeDir != null ? getJettyConfigurationURLs(jettyHomeDir) : getJettyConfigurationURLs(jettyHomeBundle, properties);
|
List<URL> configURLs = jettyHomeDir != null ? getJettyConfigurationURLs(jettyHomeDir) : getJettyConfigurationURLs(jettyHomeBundle, properties);
|
||||||
|
|
||||||
LOG.info("Configuring the default jetty server with {}",configURLs);
|
LOG.info("Configuring the default jetty server with {}",configURLs);
|
||||||
String home=properties.get(OSGiServerConstants.JETTY_HOME);
|
String home=(String)properties.get(OSGiServerConstants.JETTY_HOME);
|
||||||
String base=properties.get(OSGiServerConstants.JETTY_BASE);
|
String base=(String)properties.get(OSGiServerConstants.JETTY_BASE);
|
||||||
if (base==null)
|
if (base==null)
|
||||||
base=home;
|
base=home;
|
||||||
LOG.info("JETTY.HOME="+home);
|
LOG.info("JETTY.HOME="+home);
|
||||||
|
@ -178,7 +178,6 @@ public class DefaultJettyAtJettyHomeHelper
|
||||||
Util.setProperty(properties, OSGiServerConstants.JETTY_BASE, base);
|
Util.setProperty(properties, OSGiServerConstants.JETTY_BASE, base);
|
||||||
Server server = ServerInstanceWrapper.configure(null, configURLs, properties);
|
Server server = ServerInstanceWrapper.configure(null, configURLs, properties);
|
||||||
|
|
||||||
|
|
||||||
//Register the default Server instance as an OSGi service.
|
//Register the default Server instance as an OSGi service.
|
||||||
//The JettyServerServiceTracker will notice it and set it up to deploy bundles as wars etc
|
//The JettyServerServiceTracker will notice it and set it up to deploy bundles as wars etc
|
||||||
bundleContext.registerService(Server.class.getName(), server, properties);
|
bundleContext.registerService(Server.class.getName(), server, properties);
|
||||||
|
@ -213,7 +212,7 @@ public class DefaultJettyAtJettyHomeHelper
|
||||||
private static List<URL> getJettyConfigurationURLs(File jettyhome)
|
private static List<URL> getJettyConfigurationURLs(File jettyhome)
|
||||||
throws MalformedURLException
|
throws MalformedURLException
|
||||||
{
|
{
|
||||||
List<URL> configURLs = new ArrayList<URL>();
|
List<URL> configURLs = new ArrayList<>();
|
||||||
String jettyetc = System.getProperty(JETTY_ETC_FILES, DEFAULT_JETTY_ETC_FILES);
|
String jettyetc = System.getProperty(JETTY_ETC_FILES, DEFAULT_JETTY_ETC_FILES);
|
||||||
StringTokenizer tokenizer = new StringTokenizer(jettyetc, ";,", false);
|
StringTokenizer tokenizer = new StringTokenizer(jettyetc, ";,", false);
|
||||||
while (tokenizer.hasMoreTokens())
|
while (tokenizer.hasMoreTokens())
|
||||||
|
@ -241,7 +240,7 @@ public class DefaultJettyAtJettyHomeHelper
|
||||||
private static List<URL> getJettyConfigurationURLs(Bundle configurationBundle, Dictionary properties)
|
private static List<URL> getJettyConfigurationURLs(Bundle configurationBundle, Dictionary properties)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
List<URL> configURLs = new ArrayList<URL>();
|
List<URL> configURLs = new ArrayList<>();
|
||||||
String files = System.getProperty(JETTY_ETC_FILES, DEFAULT_JETTY_ETC_FILES);
|
String files = System.getProperty(JETTY_ETC_FILES, DEFAULT_JETTY_ETC_FILES);
|
||||||
StringTokenizer tokenizer = new StringTokenizer(files, ";,", false);
|
StringTokenizer tokenizer = new StringTokenizer(files, ";,", false);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.osgi.boot.internal.serverfactory;
|
package org.eclipse.jetty.osgi.boot.internal.serverfactory;
|
||||||
|
|
||||||
|
import java.util.Dictionary;
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.eclipse.jetty.osgi.boot.OSGiServerConstants;
|
import org.eclipse.jetty.osgi.boot.OSGiServerConstants;
|
||||||
|
@ -52,11 +54,10 @@ public class JettyServerServiceTracker implements ServiceTrackerCustomizer
|
||||||
if (name == null) { throw new IllegalArgumentException("The property " + OSGiServerConstants.MANAGED_JETTY_SERVER_NAME + " is mandatory"); }
|
if (name == null) { throw new IllegalArgumentException("The property " + OSGiServerConstants.MANAGED_JETTY_SERVER_NAME + " is mandatory"); }
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Adding Server {}", name);
|
if (LOG.isDebugEnabled()) LOG.debug("Adding Server {}", name);
|
||||||
ServerInstanceWrapper wrapper = new ServerInstanceWrapper(name);
|
ServerInstanceWrapper wrapper = new ServerInstanceWrapper(name);
|
||||||
Properties props = new Properties();
|
Dictionary<String,Object> props = new Hashtable<>();
|
||||||
for (String key : sr.getPropertyKeys())
|
for (String key : sr.getPropertyKeys())
|
||||||
{
|
{
|
||||||
Object value = sr.getProperty(key);
|
props.put(key, sr.getProperty(key));
|
||||||
props.put(key, value);
|
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class ServerInstanceWrapper
|
||||||
public static final String PROPERTY_THIS_JETTY_XML_FOLDER_URL = "this.jetty.xml.parent.folder.url";
|
public static final String PROPERTY_THIS_JETTY_XML_FOLDER_URL = "this.jetty.xml.parent.folder.url";
|
||||||
|
|
||||||
|
|
||||||
private static Collection<TldBundleDiscoverer> __containerTldBundleDiscoverers = new ArrayList<TldBundleDiscoverer>();
|
private static Collection<TldBundleDiscoverer> __containerTldBundleDiscoverers = new ArrayList<>();
|
||||||
|
|
||||||
private static Logger LOG = Log.getLogger(ServerInstanceWrapper.class.getName());
|
private static Logger LOG = Log.getLogger(ServerInstanceWrapper.class.getName());
|
||||||
|
|
||||||
|
@ -114,12 +114,12 @@ public class ServerInstanceWrapper
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public static Server configure(Server server, List<URL> jettyConfigurations, Dictionary props) throws Exception
|
public static Server configure(Server server, List<URL> jettyConfigurations, Dictionary<String, Object> props) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
if (jettyConfigurations == null || jettyConfigurations.isEmpty()) { return server; }
|
if (jettyConfigurations == null || jettyConfigurations.isEmpty()) { return server; }
|
||||||
|
|
||||||
Map<String, Object> id_map = new HashMap<String, Object>();
|
Map<String, Object> id_map = new HashMap<>();
|
||||||
if (server != null)
|
if (server != null)
|
||||||
{
|
{
|
||||||
//Put in a mapping for the id "Server" and the name of the server as the instance being configured
|
//Put in a mapping for the id "Server" and the name of the server as the instance being configured
|
||||||
|
@ -127,18 +127,16 @@ public class ServerInstanceWrapper
|
||||||
id_map.put((String)props.get(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME), server);
|
id_map.put((String)props.get(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME), server);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> properties = new HashMap<String, String>();
|
Map<String, String> properties = new HashMap<>();
|
||||||
if (props != null)
|
if (props != null)
|
||||||
{
|
{
|
||||||
Enumeration<Object> en = props.keys();
|
Enumeration<String> en = props.keys();
|
||||||
while (en.hasMoreElements())
|
while (en.hasMoreElements())
|
||||||
{
|
{
|
||||||
Object key = en.nextElement();
|
String key = en.nextElement();
|
||||||
Object value = props.get(key);
|
Object value = props.get(key);
|
||||||
String keyStr = String.valueOf(key);
|
properties.put(key, value.toString());
|
||||||
String valStr = String.valueOf(value);
|
if (server != null) server.setAttribute(key, value);
|
||||||
properties.put(keyStr, valStr);
|
|
||||||
if (server != null) server.setAttribute(keyStr, valStr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +151,7 @@ public class ServerInstanceWrapper
|
||||||
throw new IllegalStateException("No such jetty server config file: "+r);
|
throw new IllegalStateException("No such jetty server config file: "+r);
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlConfiguration config = new XmlConfiguration(r.getURL());
|
XmlConfiguration config = new XmlConfiguration(r.getURI().toURL());
|
||||||
|
|
||||||
config.getIdMap().putAll(id_map);
|
config.getIdMap().putAll(id_map);
|
||||||
config.getProperties().putAll(properties);
|
config.getProperties().putAll(properties);
|
||||||
|
@ -243,7 +241,7 @@ public class ServerInstanceWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public void start(Server server, Dictionary props) throws Exception
|
public void start(Server server, Dictionary<String,Object> props) throws Exception
|
||||||
{
|
{
|
||||||
_server = server;
|
_server = server;
|
||||||
ClassLoader contextCl = Thread.currentThread().getContextClassLoader();
|
ClassLoader contextCl = Thread.currentThread().getContextClassLoader();
|
||||||
|
@ -274,7 +272,7 @@ public class ServerInstanceWrapper
|
||||||
//as on the webapp classpath.
|
//as on the webapp classpath.
|
||||||
if (!__containerTldBundleDiscoverers.isEmpty())
|
if (!__containerTldBundleDiscoverers.isEmpty())
|
||||||
{
|
{
|
||||||
Set<URL> urls = new HashSet<URL>();
|
Set<URL> urls = new HashSet<>();
|
||||||
//discover bundles with tlds that need to be on the container's classpath as URLs
|
//discover bundles with tlds that need to be on the container's classpath as URLs
|
||||||
for (TldBundleDiscoverer d:__containerTldBundleDiscoverers)
|
for (TldBundleDiscoverer d:__containerTldBundleDiscoverers)
|
||||||
{
|
{
|
||||||
|
@ -350,7 +348,7 @@ public class ServerInstanceWrapper
|
||||||
if (_ctxtCollection == null)
|
if (_ctxtCollection == null)
|
||||||
throw new IllegalStateException("ERROR: No ContextHandlerCollection configured in Server");
|
throw new IllegalStateException("ERROR: No ContextHandlerCollection configured in Server");
|
||||||
|
|
||||||
List<String> providerClassNames = new ArrayList<String>();
|
List<String> providerClassNames = new ArrayList<>();
|
||||||
|
|
||||||
// get a deployerManager and some providers
|
// get a deployerManager and some providers
|
||||||
Collection<DeploymentManager> deployers = _server.getBeans(DeploymentManager.class);
|
Collection<DeploymentManager> deployers = _server.getBeans(DeploymentManager.class);
|
||||||
|
@ -372,7 +370,7 @@ public class ServerInstanceWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
_deploymentManager.setUseStandardBindings(false);
|
_deploymentManager.setUseStandardBindings(false);
|
||||||
List<AppLifeCycle.Binding> deploymentLifeCycleBindings = new ArrayList<AppLifeCycle.Binding>();
|
List<AppLifeCycle.Binding> deploymentLifeCycleBindings = new ArrayList<>();
|
||||||
deploymentLifeCycleBindings.add(new OSGiDeployer(this));
|
deploymentLifeCycleBindings.add(new OSGiDeployer(this));
|
||||||
deploymentLifeCycleBindings.add(new StandardStarter());
|
deploymentLifeCycleBindings.add(new StandardStarter());
|
||||||
deploymentLifeCycleBindings.add(new StandardStopper());
|
deploymentLifeCycleBindings.add(new StandardStopper());
|
||||||
|
@ -446,7 +444,7 @@ public class ServerInstanceWrapper
|
||||||
private List<File> extractFiles(String propertyValue)
|
private List<File> extractFiles(String propertyValue)
|
||||||
{
|
{
|
||||||
StringTokenizer tokenizer = new StringTokenizer(propertyValue, ",;", false);
|
StringTokenizer tokenizer = new StringTokenizer(propertyValue, ",;", false);
|
||||||
List<File> files = new ArrayList<File>();
|
List<File> files = new ArrayList<>();
|
||||||
while (tokenizer.hasMoreTokens())
|
while (tokenizer.hasMoreTokens())
|
||||||
{
|
{
|
||||||
String tok = tokenizer.nextToken();
|
String tok = tokenizer.nextToken();
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class LibExtClassLoaderHelper
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final Set<IFilesInJettyHomeResourcesProcessor> registeredFilesInJettyHomeResourcesProcessors = new HashSet<IFilesInJettyHomeResourcesProcessor>();
|
public static final Set<IFilesInJettyHomeResourcesProcessor> registeredFilesInJettyHomeResourcesProcessors = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -83,12 +83,12 @@ public class LibExtClassLoaderHelper
|
||||||
public static ClassLoader createLibEtcClassLoader(File jettyHome, ClassLoader parentClassLoader) throws MalformedURLException
|
public static ClassLoader createLibEtcClassLoader(File jettyHome, ClassLoader parentClassLoader) throws MalformedURLException
|
||||||
{
|
{
|
||||||
if (jettyHome == null) { return parentClassLoader; }
|
if (jettyHome == null) { return parentClassLoader; }
|
||||||
ArrayList<URL> urls = new ArrayList<URL>();
|
ArrayList<URL> urls = new ArrayList<>();
|
||||||
File jettyResources = new File(jettyHome, "resources");
|
File jettyResources = new File(jettyHome, "resources");
|
||||||
if (jettyResources.exists())
|
if (jettyResources.exists())
|
||||||
{
|
{
|
||||||
// make sure it contains something else than README:
|
// make sure it contains something else than README:
|
||||||
Map<String, File> jettyResFiles = new HashMap<String, File>();
|
Map<String, File> jettyResFiles = new HashMap<>();
|
||||||
for (File f : jettyResources.listFiles())
|
for (File f : jettyResources.listFiles())
|
||||||
{
|
{
|
||||||
jettyResFiles.put(f.getName(), f);
|
jettyResFiles.put(f.getName(), f);
|
||||||
|
@ -143,7 +143,7 @@ public class LibExtClassLoaderHelper
|
||||||
throws MalformedURLException
|
throws MalformedURLException
|
||||||
{
|
{
|
||||||
if (jarsContainerOrJars == null && otherJarsOrFolder == null) { return parentClassLoader; }
|
if (jarsContainerOrJars == null && otherJarsOrFolder == null) { return parentClassLoader; }
|
||||||
List<URL> urls = new ArrayList<URL>();
|
List<URL> urls = new ArrayList<>();
|
||||||
if (otherJarsOrFolder != null)
|
if (otherJarsOrFolder != null)
|
||||||
{
|
{
|
||||||
urls.addAll(otherJarsOrFolder);
|
urls.addAll(otherJarsOrFolder);
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class OSGiWebappClassLoader extends WebAppClassLoader implements BundleRe
|
||||||
* when a logging framework is setup in the osgi classloaders, it can access
|
* when a logging framework is setup in the osgi classloaders, it can access
|
||||||
* this and register the classes that must not be found in the jar.
|
* this and register the classes that must not be found in the jar.
|
||||||
*/
|
*/
|
||||||
public static final Set<String> JAR_WITH_SUCH_CLASS_MUST_BE_EXCLUDED = new HashSet<String>();
|
public static final Set<String> JAR_WITH_SUCH_CLASS_MUST_BE_EXCLUDED = new HashSet<>();
|
||||||
|
|
||||||
public static void addClassThatIdentifiesAJarThatMustBeRejected(Class<?> zclass)
|
public static void addClassThatIdentifiesAJarThatMustBeRejected(Class<?> zclass)
|
||||||
{
|
{
|
||||||
|
@ -150,7 +150,7 @@ public class OSGiWebappClassLoader extends WebAppClassLoader implements BundleRe
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
private List<URL> toList(Enumeration<URL> e, Enumeration<URL> e2)
|
private List<URL> toList(Enumeration<URL> e, Enumeration<URL> e2)
|
||||||
{
|
{
|
||||||
List<URL> list = new ArrayList<URL>();
|
List<URL> list = new ArrayList<>();
|
||||||
while (e != null && e.hasMoreElements())
|
while (e != null && e.hasMoreElements())
|
||||||
list.add(e.nextElement());
|
list.add(e.nextElement());
|
||||||
while (e2 != null && e2.hasMoreElements())
|
while (e2 != null && e2.hasMoreElements())
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.eclipse.jetty.osgi.boot.utils;
|
package org.eclipse.jetty.osgi.boot.utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Hashtable;
|
||||||
|
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
import org.osgi.framework.FrameworkUtil;
|
import org.osgi.framework.FrameworkUtil;
|
||||||
import org.osgi.framework.ServiceReference;
|
|
||||||
import org.osgi.service.event.Event;
|
import org.osgi.service.event.Event;
|
||||||
import org.osgi.service.event.EventAdmin;
|
import org.osgi.service.event.EventAdmin;
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
import org.osgi.util.tracker.ServiceTracker;
|
||||||
|
@ -68,7 +67,7 @@ public class EventSender
|
||||||
{
|
{
|
||||||
EventAdmin service = (EventAdmin)_serviceTracker.getService();
|
EventAdmin service = (EventAdmin)_serviceTracker.getService();
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
Dictionary<String,Object> props = new Hashtable<String,Object>();
|
Dictionary<String,Object> props = new Hashtable<>();
|
||||||
props.put("bundle.symbolicName", wab.getSymbolicName());
|
props.put("bundle.symbolicName", wab.getSymbolicName());
|
||||||
props.put("bundle.id", wab.getBundleId());
|
props.put("bundle.id", wab.getBundleId());
|
||||||
props.put("bundle", wab);
|
props.put("bundle", wab);
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class OSGiClassLoader extends URLClassLoader
|
||||||
*/
|
*/
|
||||||
private List<URL> toList(Enumeration<URL> e, Enumeration<URL> e2)
|
private List<URL> toList(Enumeration<URL> e, Enumeration<URL> e2)
|
||||||
{
|
{
|
||||||
List<URL> list = new ArrayList<URL>();
|
List<URL> list = new ArrayList<>();
|
||||||
while (e != null && e.hasMoreElements())
|
while (e != null && e.hasMoreElements())
|
||||||
list.add(e.nextElement());
|
list.add(e.nextElement());
|
||||||
while (e2 != null && e2.hasMoreElements())
|
while (e2 != null && e2.hasMoreElements())
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class Util
|
||||||
* @param manifest the dictionary
|
* @param manifest the dictionary
|
||||||
* @return the value from the manifest
|
* @return the value from the manifest
|
||||||
*/
|
*/
|
||||||
public static String getManifestHeaderValue (String name, String altName, Dictionary manifest)
|
public static String getManifestHeaderValue (String name, String altName, Dictionary<String,String> manifest)
|
||||||
{
|
{
|
||||||
if (manifest == null)
|
if (manifest == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -103,7 +103,7 @@ public class Util
|
||||||
delims = separators;
|
delims = separators;
|
||||||
|
|
||||||
StringTokenizer tokenizer = new StringTokenizer(val, delims, false);
|
StringTokenizer tokenizer = new StringTokenizer(val, delims, false);
|
||||||
List<URL> urls = new ArrayList<URL>();
|
List<URL> urls = new ArrayList<>();
|
||||||
while (tokenizer.hasMoreTokens())
|
while (tokenizer.hasMoreTokens())
|
||||||
{
|
{
|
||||||
urls.add(BundleFileLocatorHelperFactory.getFactory().getHelper().getLocalURL(new URL(tokenizer.nextToken())));
|
urls.add(BundleFileLocatorHelperFactory.getFactory().getHelper().getLocalURL(new URL(tokenizer.nextToken())));
|
||||||
|
@ -113,7 +113,7 @@ public class Util
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public static void setProperty(Dictionary<String,String> properties, String key, String value)
|
public static void setProperty(Dictionary<String,Object> properties, String key, Object value)
|
||||||
{
|
{
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,10 +38,10 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
|
||||||
private static final Logger LOG = Log.getLogger(BundleClassLoaderHelper.class);
|
private static final Logger LOG = Log.getLogger(BundleClassLoaderHelper.class);
|
||||||
private static enum OSGiContainerType {EquinoxOld, EquinoxLuna, FelixOld, Felix403, Concierge};
|
private static enum OSGiContainerType {EquinoxOld, EquinoxLuna, FelixOld, Felix403, Concierge};
|
||||||
private static OSGiContainerType osgiContainer;
|
private static OSGiContainerType osgiContainer;
|
||||||
private static Class Equinox_BundleHost_Class;
|
private static Class<?> Equinox_BundleHost_Class;
|
||||||
private static Class Equinox_EquinoxBundle_Class;
|
private static Class<?> Equinox_EquinoxBundle_Class;
|
||||||
private static Class Felix_BundleImpl_Class;
|
private static Class<?> Felix_BundleImpl_Class;
|
||||||
private static Class Felix_BundleWiring_Class;
|
private static Class<?> Felix_BundleWiring_Class;
|
||||||
//old equinox
|
//old equinox
|
||||||
private static Method Equinox_BundleHost_getBundleLoader_method;
|
private static Method Equinox_BundleHost_getBundleLoader_method;
|
||||||
private static Method Equinox_BundleLoader_createClassLoader_method;
|
private static Method Equinox_BundleLoader_createClassLoader_method;
|
||||||
|
@ -56,8 +56,8 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
|
||||||
private static Method Felix_BundleWiring_getClassLoader_Method;
|
private static Method Felix_BundleWiring_getClassLoader_Method;
|
||||||
|
|
||||||
// Concierge
|
// Concierge
|
||||||
private static Class Concierge_BundleImpl_Class;
|
private static Class<?> Concierge_BundleImpl_Class;
|
||||||
private static Class Concierge_BundleWiring_Class;
|
private static Class<?> Concierge_BundleWiring_Class;
|
||||||
private static Method Concierge_BundleImpl_Adapt_Method;
|
private static Method Concierge_BundleImpl_Adapt_Method;
|
||||||
private static Method Concierge_BundleWiring_getClassLoader_Method;
|
private static Method Concierge_BundleWiring_getClassLoader_Method;
|
||||||
|
|
||||||
|
@ -268,6 +268,7 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
|
||||||
* @param bundle
|
* @param bundle
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static ClassLoader internalGetFelixBundleClassLoader(Bundle bundle)
|
private static ClassLoader internalGetFelixBundleClassLoader(Bundle bundle)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.eclipse.jetty.osgi.boot.utils.internal;
|
package org.eclipse.jetty.osgi.boot.utils.internal;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -88,7 +87,7 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
|
||||||
* @return Its installation location as a file.
|
* @return Its installation location as a file.
|
||||||
* @throws Exception if unable to get the bundle install location
|
* @throws Exception if unable to get the bundle install location
|
||||||
*/
|
*/
|
||||||
@Override
|
@SuppressWarnings("resource")
|
||||||
public File getBundleInstallLocation(Bundle bundle) throws Exception
|
public File getBundleInstallLocation(Bundle bundle) throws Exception
|
||||||
{
|
{
|
||||||
// String installedBundles = System.getProperty("osgi.bundles");
|
// String installedBundles = System.getProperty("osgi.bundles");
|
||||||
|
@ -252,6 +251,7 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
|
||||||
path = "/" + path;
|
path = "/" + path;
|
||||||
}
|
}
|
||||||
String pattern = last != -1 && last < entryPath.length() - 2 ? entryPath.substring(last + 1) : entryPath;
|
String pattern = last != -1 && last < entryPath.length() - 2 ? entryPath.substring(last + 1) : entryPath;
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Enumeration<URL> enUrls = bundle.findEntries(path, pattern, false);
|
Enumeration<URL> enUrls = bundle.findEntries(path, pattern, false);
|
||||||
return enUrls;
|
return enUrls;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
|
||||||
if (jasperLocation.isDirectory())
|
if (jasperLocation.isDirectory())
|
||||||
{
|
{
|
||||||
// try to find the jar files inside this folder
|
// try to find the jar files inside this folder
|
||||||
ArrayList<File> urls = new ArrayList<File>();
|
ArrayList<File> urls = new ArrayList<>();
|
||||||
for (File f : jasperLocation.listFiles())
|
for (File f : jasperLocation.listFiles())
|
||||||
{
|
{
|
||||||
if (f.getName().endsWith(".jar") && f.isFile())
|
if (f.getName().endsWith(".jar") && f.isFile())
|
||||||
|
@ -332,10 +332,10 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
|
||||||
conn.setDefaultUseCaches(Resource.getDefaultUseCaches());
|
conn.setDefaultUseCaches(Resource.getDefaultUseCaches());
|
||||||
if (BUNDLE_URL_CONNECTION_getLocalURL == null && match(conn.getClass().getName(), BUNDLE_URL_CONNECTION_CLASSES))
|
if (BUNDLE_URL_CONNECTION_getLocalURL == null && match(conn.getClass().getName(), BUNDLE_URL_CONNECTION_CLASSES))
|
||||||
{
|
{
|
||||||
BUNDLE_URL_CONNECTION_getLocalURL = conn.getClass().getMethod("getLocalURL", null);
|
BUNDLE_URL_CONNECTION_getLocalURL = conn.getClass().getMethod("getLocalURL");
|
||||||
BUNDLE_URL_CONNECTION_getLocalURL.setAccessible(true);
|
BUNDLE_URL_CONNECTION_getLocalURL.setAccessible(true);
|
||||||
}
|
}
|
||||||
if (BUNDLE_URL_CONNECTION_getLocalURL != null) { return (URL) BUNDLE_URL_CONNECTION_getLocalURL.invoke(conn, null); }
|
if (BUNDLE_URL_CONNECTION_getLocalURL != null) { return (URL) BUNDLE_URL_CONNECTION_getLocalURL.invoke(conn); }
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -366,10 +366,10 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
|
||||||
&&
|
&&
|
||||||
match (conn.getClass().getName(), BUNDLE_URL_CONNECTION_CLASSES))
|
match (conn.getClass().getName(), BUNDLE_URL_CONNECTION_CLASSES))
|
||||||
{
|
{
|
||||||
BUNDLE_URL_CONNECTION_getFileURL = conn.getClass().getMethod("getFileURL", null);
|
BUNDLE_URL_CONNECTION_getFileURL = conn.getClass().getMethod("getFileURL");
|
||||||
BUNDLE_URL_CONNECTION_getFileURL.setAccessible(true);
|
BUNDLE_URL_CONNECTION_getFileURL.setAccessible(true);
|
||||||
}
|
}
|
||||||
if (BUNDLE_URL_CONNECTION_getFileURL != null) { return (URL) BUNDLE_URL_CONNECTION_getFileURL.invoke(conn, null); }
|
if (BUNDLE_URL_CONNECTION_getFileURL != null) { return (URL) BUNDLE_URL_CONNECTION_getFileURL.invoke(conn); }
|
||||||
|
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class PackageAdminServiceTracker implements ServiceListener
|
||||||
{
|
{
|
||||||
private BundleContext _context;
|
private BundleContext _context;
|
||||||
|
|
||||||
private List<BundleActivator> _activatedFragments = new ArrayList<BundleActivator>();
|
private List<BundleActivator> _activatedFragments = new ArrayList<>();
|
||||||
|
|
||||||
private boolean _fragmentsWereActivated = false;
|
private boolean _fragmentsWereActivated = false;
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ public class PackageAdminServiceTracker implements ServiceListener
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
PackageAdmin admin = (PackageAdmin) _context.getService(sr);
|
PackageAdmin admin = (PackageAdmin) _context.getService(sr);
|
||||||
LinkedHashMap<String, Bundle> deps = new LinkedHashMap<String, Bundle>();
|
LinkedHashMap<String, Bundle> deps = new LinkedHashMap<>();
|
||||||
collectFragmentsAndRequiredBundles(bundle, admin, deps, false);
|
collectFragmentsAndRequiredBundles(bundle, admin, deps, false);
|
||||||
return deps.values().toArray(new Bundle[deps.size()]);
|
return deps.values().toArray(new Bundle[deps.size()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ public class TestJettyOSGiBootContextAsService
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
|
||||||
public void assertAllBundlesActiveOrResolved()
|
public void assertAllBundlesActiveOrResolved()
|
||||||
{
|
{
|
||||||
TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext);
|
TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext);
|
||||||
|
|
|
@ -50,6 +50,7 @@ import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||||
import org.eclipse.jetty.http.HttpStatus;
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.util.HttpCookieStore;
|
import org.eclipse.jetty.util.HttpCookieStore;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
|
@ -352,7 +353,7 @@ public abstract class AbstractProxyServlet extends HttpServlet
|
||||||
*/
|
*/
|
||||||
protected HttpClient newHttpClient()
|
protected HttpClient newHttpClient()
|
||||||
{
|
{
|
||||||
int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
|
int selectors = Math.max(1,ProcessorUtils.availableProcessors()/2);
|
||||||
String value = getServletConfig().getInitParameter("selectors");
|
String value = getServletConfig().getInitParameter("selectors");
|
||||||
if (value != null)
|
if (value != null)
|
||||||
selectors = Integer.parseInt(value);
|
selectors = Integer.parseInt(value);
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.eclipse.jetty.util.IO;
|
import org.eclipse.jetty.util.IO;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
|
@ -149,7 +150,7 @@ public class ProxyServletLoadTest
|
||||||
startClient();
|
startClient();
|
||||||
|
|
||||||
// Number of clients to simulate
|
// Number of clients to simulate
|
||||||
int clientCount = Runtime.getRuntime().availableProcessors();
|
int clientCount = ProcessorUtils.availableProcessors();
|
||||||
|
|
||||||
// Latch for number of clients still active (used to terminate test)
|
// Latch for number of clients still active (used to terminate test)
|
||||||
final CountDownLatch activeClientLatch = new CountDownLatch(clientCount);
|
final CountDownLatch activeClientLatch = new CountDownLatch(clientCount);
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class ValidUrlRule extends Rule
|
||||||
|
|
||||||
LOG.debug("{} {} {} {}", Character.charCount(codepoint), codepoint, block, Character.isISOControl(codepoint));
|
LOG.debug("{} {} {} {}", Character.charCount(codepoint), codepoint, block, Character.isISOControl(codepoint));
|
||||||
|
|
||||||
return (!Character.isISOControl(codepoint)) && block != null && block != Character.UnicodeBlock.SPECIALS;
|
return (!Character.isISOControl(codepoint)) && block != null && !Character.UnicodeBlock.SPECIALS.equals(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||||
import org.eclipse.jetty.util.FutureCallback;
|
import org.eclipse.jetty.util.FutureCallback;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
@ -196,7 +197,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
||||||
for (ConnectionFactory factory:factories)
|
for (ConnectionFactory factory:factories)
|
||||||
addConnectionFactory(factory);
|
addConnectionFactory(factory);
|
||||||
|
|
||||||
int cores = Runtime.getRuntime().availableProcessors();
|
int cores = ProcessorUtils.availableProcessors();
|
||||||
if (acceptors < 0)
|
if (acceptors < 0)
|
||||||
acceptors=Math.max(1, Math.min(4,cores/8));
|
acceptors=Math.max(1, Math.min(4,cores/8));
|
||||||
if (acceptors > cores)
|
if (acceptors > cores)
|
||||||
|
|
|
@ -80,10 +80,10 @@ public class ConnectorStatistics extends AbstractLifeCycle implements Dumpable,
|
||||||
{
|
{
|
||||||
long msgsIn=connection.getMessagesIn();
|
long msgsIn=connection.getMessagesIn();
|
||||||
long msgsOut=connection.getMessagesOut();
|
long msgsOut=connection.getMessagesOut();
|
||||||
_messagesIn.set(msgsIn);
|
_messagesIn.record(msgsIn);
|
||||||
_messagesOut.set(msgsOut);
|
_messagesOut.record(msgsOut);
|
||||||
_connectionStats.decrement();
|
_connectionStats.decrement();
|
||||||
_connectionDurationStats.set(System.currentTimeMillis()-connection.getCreatedTimeStamp());
|
_connectionDurationStats.record(System.currentTimeMillis()-connection.getCreatedTimeStamp());
|
||||||
|
|
||||||
Sample sample=_samples.remove(connection);
|
Sample sample=_samples.remove(connection);
|
||||||
if (sample!=null)
|
if (sample!=null)
|
||||||
|
|
|
@ -428,7 +428,10 @@ public class HttpChannelOverHttp extends HttpChannel implements HttpParser.Reque
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("upgrade {} {}", this, _upgrade);
|
LOG.debug("upgrade {} {}", this, _upgrade);
|
||||||
|
|
||||||
if (_upgrade != PREAMBLE_UPGRADE_H2C && (_connection == null || !_connection.contains("upgrade")))
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean isUpgraded_H2C = (_upgrade == PREAMBLE_UPGRADE_H2C);
|
||||||
|
|
||||||
|
if (!isUpgraded_H2C && (_connection == null || !_connection.contains("upgrade")))
|
||||||
throw new BadMessageException(HttpStatus.BAD_REQUEST_400);
|
throw new BadMessageException(HttpStatus.BAD_REQUEST_400);
|
||||||
|
|
||||||
// Find the upgrade factory
|
// Find the upgrade factory
|
||||||
|
@ -465,7 +468,7 @@ public class HttpChannelOverHttp extends HttpChannel implements HttpParser.Reque
|
||||||
// Send 101 if needed
|
// Send 101 if needed
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_upgrade != PREAMBLE_UPGRADE_H2C)
|
if (!isUpgraded_H2C)
|
||||||
sendResponse(new MetaData.Response(HttpVersion.HTTP_1_1, HttpStatus.SWITCHING_PROTOCOLS_101, response101, 0), null, true);
|
sendResponse(new MetaData.Response(HttpVersion.HTTP_1_1, HttpStatus.SWITCHING_PROTOCOLS_101, response101, 0), null, true);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
|
|
@ -143,6 +143,18 @@ public class Request implements HttpServletRequest
|
||||||
|
|
||||||
private static final MultiMap<String> NO_PARAMS = new MultiMap<>();
|
private static final MultiMap<String> NO_PARAMS = new MultiMap<>();
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* Compare inputParameters to NO_PARAMS by Reference
|
||||||
|
* @param inputParameters The parameters to compare to NO_PARAMS
|
||||||
|
* @return True if the inputParameters reference is equal to NO_PARAMS otherwise False
|
||||||
|
*/
|
||||||
|
private static boolean isNoParams(MultiMap<String> inputParameters) {
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean is_no_params = (inputParameters==NO_PARAMS);
|
||||||
|
return is_no_params;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* Obtain the base {@link Request} instance of a {@link ServletRequest}, by
|
* Obtain the base {@link Request} instance of a {@link ServletRequest}, by
|
||||||
|
@ -397,9 +409,9 @@ public class Request implements HttpServletRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do parameters need to be combined?
|
// Do parameters need to be combined?
|
||||||
if (_queryParameters==NO_PARAMS || _queryParameters.size()==0)
|
if (isNoParams(_queryParameters) || _queryParameters.size()==0)
|
||||||
_parameters=_contentParameters;
|
_parameters=_contentParameters;
|
||||||
else if (_contentParameters==NO_PARAMS || _contentParameters.size()==0)
|
else if (isNoParams(_contentParameters) || _contentParameters.size()==0)
|
||||||
_parameters=_queryParameters;
|
_parameters=_queryParameters;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -452,16 +452,30 @@ public class ResponseWriter extends PrintWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PrintWriter format(Locale l, String format, Object... args)
|
public PrintWriter format(Locale locale, String format, Object... args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* If the passed locale is null then
|
||||||
|
use any locale set on the response as the default. */
|
||||||
|
if(locale == null)
|
||||||
|
locale = _locale;
|
||||||
|
|
||||||
synchronized (lock)
|
synchronized (lock)
|
||||||
{
|
{
|
||||||
isOpen();
|
isOpen();
|
||||||
if ((_formatter == null) || (_formatter.locale() != l))
|
|
||||||
_formatter = new Formatter(this, l);
|
if(_formatter == null)
|
||||||
_formatter.format(l, format, args);
|
{
|
||||||
|
_formatter = new Formatter(this, locale);
|
||||||
|
}
|
||||||
|
else if (!_formatter.locale().equals(locale))
|
||||||
|
{
|
||||||
|
_formatter = new Formatter(this, locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
_formatter.format(locale, format, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (InterruptedIOException ex)
|
catch (InterruptedIOException ex)
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful
|
||||||
final long elapsed = System.currentTimeMillis()-request.getTimeStamp();
|
final long elapsed = System.currentTimeMillis()-request.getTimeStamp();
|
||||||
|
|
||||||
long d=_requestStats.decrement();
|
long d=_requestStats.decrement();
|
||||||
_requestTimeStats.set(elapsed);
|
_requestTimeStats.record(elapsed);
|
||||||
|
|
||||||
updateResponse(request);
|
updateResponse(request);
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful
|
||||||
final long dispatched=now-start;
|
final long dispatched=now-start;
|
||||||
|
|
||||||
_dispatchedStats.decrement();
|
_dispatchedStats.decrement();
|
||||||
_dispatchedTimeStats.set(dispatched);
|
_dispatchedTimeStats.record(dispatched);
|
||||||
|
|
||||||
if (state.isSuspended())
|
if (state.isSuspended())
|
||||||
{
|
{
|
||||||
|
@ -197,7 +197,7 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful
|
||||||
else if (state.isInitial())
|
else if (state.isInitial())
|
||||||
{
|
{
|
||||||
long d=_requestStats.decrement();
|
long d=_requestStats.decrement();
|
||||||
_requestTimeStats.set(dispatched);
|
_requestTimeStats.record(dispatched);
|
||||||
updateResponse(baseRequest);
|
updateResponse(baseRequest);
|
||||||
|
|
||||||
// If we have no more dispatches, should we signal shutdown?
|
// If we have no more dispatches, should we signal shutdown?
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.server.session;
|
package org.eclipse.jetty.server.session;
|
||||||
|
|
||||||
import static java.lang.Math.round;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -63,9 +61,11 @@ import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.statistic.CounterStatistic;
|
import org.eclipse.jetty.util.statistic.CounterStatistic;
|
||||||
import org.eclipse.jetty.util.statistic.SampleStatistic;
|
import org.eclipse.jetty.util.statistic.SampleStatistic;
|
||||||
|
import org.eclipse.jetty.util.thread.Locker.Lock;
|
||||||
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
|
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
|
||||||
import org.eclipse.jetty.util.thread.Scheduler;
|
import org.eclipse.jetty.util.thread.Scheduler;
|
||||||
import org.eclipse.jetty.util.thread.Locker.Lock;
|
|
||||||
|
import static java.lang.Math.round;
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
|
@ -1235,7 +1235,7 @@ public class SessionHandler extends ScopedHandler
|
||||||
|
|
||||||
if (session != null)
|
if (session != null)
|
||||||
{
|
{
|
||||||
_sessionTimeStats.set(round((System.currentTimeMillis() - session.getSessionData().getCreated())/1000.0));
|
_sessionTimeStats.record(round((System.currentTimeMillis() - session.getSessionData().getCreated())/1000.0));
|
||||||
session.finishInvalidate();
|
session.finishInvalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ import org.eclipse.jetty.server.session.Session;
|
||||||
import org.eclipse.jetty.server.session.SessionData;
|
import org.eclipse.jetty.server.session.SessionData;
|
||||||
import org.eclipse.jetty.server.session.SessionHandler;
|
import org.eclipse.jetty.server.session.SessionHandler;
|
||||||
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
||||||
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
import org.eclipse.jetty.util.Callback;
|
import org.eclipse.jetty.util.Callback;
|
||||||
import org.eclipse.jetty.util.thread.Scheduler;
|
import org.eclipse.jetty.util.thread.Scheduler;
|
||||||
import org.eclipse.jetty.util.thread.TimerScheduler;
|
import org.eclipse.jetty.util.thread.TimerScheduler;
|
||||||
|
@ -112,10 +113,13 @@ public class ResponseTest
|
||||||
|
|
||||||
private Server _server;
|
private Server _server;
|
||||||
private HttpChannel _channel;
|
private HttpChannel _channel;
|
||||||
|
private ByteBuffer _content = BufferUtil.allocate(16*1024);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception
|
public void init() throws Exception
|
||||||
{
|
{
|
||||||
|
BufferUtil.clear(_content);
|
||||||
|
|
||||||
_server = new Server();
|
_server = new Server();
|
||||||
Scheduler _scheduler = new TimerScheduler();
|
Scheduler _scheduler = new TimerScheduler();
|
||||||
HttpConfiguration config = new HttpConfiguration();
|
HttpConfiguration config = new HttpConfiguration();
|
||||||
|
@ -139,6 +143,12 @@ public class ResponseTest
|
||||||
@Override
|
@Override
|
||||||
public void send(MetaData.Response info, boolean head, ByteBuffer content, boolean lastContent, Callback callback)
|
public void send(MetaData.Response info, boolean head, ByteBuffer content, boolean lastContent, Callback callback)
|
||||||
{
|
{
|
||||||
|
if(BufferUtil.hasContent(content))
|
||||||
|
{
|
||||||
|
BufferUtil.append(_content, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_channelError==null)
|
if (_channelError==null)
|
||||||
callback.succeeded();
|
callback.succeeded();
|
||||||
else
|
else
|
||||||
|
@ -172,6 +182,7 @@ public class ResponseTest
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,6 +375,54 @@ public class ResponseTest
|
||||||
assertTrue(response.toString().indexOf("charset=utf-8") > 0);
|
assertTrue(response.toString().indexOf("charset=utf-8") > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLocaleFormat() throws Exception
|
||||||
|
{
|
||||||
|
Response response = getResponse();
|
||||||
|
|
||||||
|
ContextHandler context = new ContextHandler();
|
||||||
|
context.addLocaleEncoding(Locale.ENGLISH.toString(), "ISO-8859-1");
|
||||||
|
context.addLocaleEncoding(Locale.ITALIAN.toString(), "ISO-8859-2");
|
||||||
|
response.getHttpChannel().getRequest().setContext(context.getServletContext());
|
||||||
|
|
||||||
|
response.setLocale(java.util.Locale.ITALIAN);
|
||||||
|
|
||||||
|
PrintWriter out = response.getWriter();
|
||||||
|
|
||||||
|
out.format("TestA1 %,.2f%n", 1234567.89);
|
||||||
|
out.format("TestA2 %,.2f%n", 1234567.89);
|
||||||
|
|
||||||
|
out.format((java.util.Locale)null,"TestB1 %,.2f%n", 1234567.89);
|
||||||
|
out.format((java.util.Locale)null,"TestB2 %,.2f%n", 1234567.89);
|
||||||
|
|
||||||
|
out.format(Locale.ENGLISH,"TestC1 %,.2f%n", 1234567.89);
|
||||||
|
out.format(Locale.ENGLISH,"TestC2 %,.2f%n", 1234567.89);
|
||||||
|
|
||||||
|
out.format(Locale.ITALIAN,"TestD1 %,.2f%n", 1234567.89);
|
||||||
|
out.format(Locale.ITALIAN,"TestD2 %,.2f%n", 1234567.89);
|
||||||
|
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
/* Test A */
|
||||||
|
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestA1 1.234.567,89"));
|
||||||
|
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestA2 1.234.567,89"));
|
||||||
|
|
||||||
|
/* Test B */
|
||||||
|
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestB1 1.234.567,89"));
|
||||||
|
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestB2 1.234.567,89"));
|
||||||
|
|
||||||
|
/* Test C */
|
||||||
|
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestC1 1,234,567.89"));
|
||||||
|
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestC2 1,234,567.89"));
|
||||||
|
|
||||||
|
/* Test D */
|
||||||
|
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestD1 1.234.567,89"));
|
||||||
|
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestD2 1.234.567,89"));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContentTypeCharacterEncoding() throws Exception
|
public void testContentTypeCharacterEncoding() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -255,7 +255,7 @@ public class ServerConnectorTest
|
||||||
try (StacklessLogging stackless = new StacklessLogging(AbstractConnector.class))
|
try (StacklessLogging stackless = new StacklessLogging(AbstractConnector.class))
|
||||||
{
|
{
|
||||||
AtomicLong spins = new AtomicLong();
|
AtomicLong spins = new AtomicLong();
|
||||||
ServerConnector connector = new ServerConnector(server)
|
ServerConnector connector = new ServerConnector(server,1,1)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void accept(int acceptorID) throws IOException
|
public void accept(int acceptorID) throws IOException
|
||||||
|
@ -267,7 +267,7 @@ public class ServerConnectorTest
|
||||||
server.addConnector(connector);
|
server.addConnector(connector);
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1500);
|
||||||
assertThat(spins.get(), Matchers.lessThan(5L));
|
assertThat(spins.get(), Matchers.lessThan(5L));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
@ -325,6 +325,8 @@ public class ThreadStarvationTest
|
||||||
|
|
||||||
byte buf[] = new byte[1024];
|
byte buf[] = new byte[1024];
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while((len = in.read(buf,0,buf.length)) != -1)
|
while((len = in.read(buf,0,buf.length)) != -1)
|
||||||
{
|
{
|
||||||
for(int x=0; x<len; x++)
|
for(int x=0; x<len; x++)
|
||||||
|
@ -332,6 +334,12 @@ public class ThreadStarvationTest
|
||||||
if(buf[x] == '!') bodyCount++;
|
if(buf[x] == '!') bodyCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(Throwable th)
|
||||||
|
{
|
||||||
|
_server.dumpStdErr();
|
||||||
|
throw th;
|
||||||
|
}
|
||||||
return bodyCount;
|
return bodyCount;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -514,7 +514,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc
|
||||||
if ((_welcomeServlets || _welcomeExactServlets) && welcome_servlet==null)
|
if ((_welcomeServlets || _welcomeExactServlets) && welcome_servlet==null)
|
||||||
{
|
{
|
||||||
MappedResource<ServletHolder> entry=_servletHandler.getMappedServlet(welcome_in_context);
|
MappedResource<ServletHolder> entry=_servletHandler.getMappedServlet(welcome_in_context);
|
||||||
if (entry!=null && entry.getResource()!=_defaultHolder &&
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean isDefaultHolder = (entry.getResource()!=_defaultHolder);
|
||||||
|
if (entry!=null && isDefaultHolder &&
|
||||||
(_welcomeServlets || (_welcomeExactServlets && entry.getPathSpec().getDeclaration().equals(welcome_in_context))))
|
(_welcomeServlets || (_welcomeExactServlets && entry.getPathSpec().getDeclaration().equals(welcome_in_context))))
|
||||||
welcome_servlet=welcome_in_context;
|
welcome_servlet=welcome_in_context;
|
||||||
|
|
||||||
|
|
|
@ -1513,7 +1513,9 @@ public class ServletHandler extends ScopedHandler
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (ServletHolder s:_servlets)
|
for (ServletHolder s:_servlets)
|
||||||
{
|
{
|
||||||
if (s == holder)
|
@SuppressWarnings("ReferenceEquality")
|
||||||
|
boolean foundServletHolder = (s == holder);
|
||||||
|
if (foundServletHolder)
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
|
|
|
@ -54,7 +54,8 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
* <dt>allowedOrigins</dt>
|
* <dt>allowedOrigins</dt>
|
||||||
* <dd>a comma separated list of origins that are
|
* <dd>a comma separated list of origins that are
|
||||||
* allowed to access the resources. Default value is <b>*</b>, meaning all
|
* allowed to access the resources. Default value is <b>*</b>, meaning all
|
||||||
* origins.
|
* origins. Note that using wild cards can result in security problems
|
||||||
|
* for requests identifying hosts that do not exist.
|
||||||
* <p>
|
* <p>
|
||||||
* If an allowed origin contains one or more * characters (for example
|
* If an allowed origin contains one or more * characters (for example
|
||||||
* http://*.domain.com), then "*" characters are converted to ".*", "."
|
* http://*.domain.com), then "*" characters are converted to ".*", "."
|
||||||
|
|
|
@ -37,6 +37,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.HttpOutput;
|
import org.eclipse.jetty.server.HttpOutput;
|
||||||
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A servlet that uses the Servlet 3.1 asynchronous IO API to server
|
* A servlet that uses the Servlet 3.1 asynchronous IO API to server
|
||||||
|
@ -78,7 +79,7 @@ public class DataRateLimitedServlet extends HttpServlet
|
||||||
if (tmp!=null)
|
if (tmp!=null)
|
||||||
pauseNS=TimeUnit.MILLISECONDS.toNanos(Integer.parseInt(tmp));
|
pauseNS=TimeUnit.MILLISECONDS.toNanos(Integer.parseInt(tmp));
|
||||||
tmp = getInitParameter("pool");
|
tmp = getInitParameter("pool");
|
||||||
int pool=tmp==null?Runtime.getRuntime().availableProcessors():Integer.parseInt(tmp);
|
int pool=tmp==null?ProcessorUtils.availableProcessors():Integer.parseInt(tmp);
|
||||||
|
|
||||||
// Create and start a shared scheduler.
|
// Create and start a shared scheduler.
|
||||||
scheduler=new ScheduledThreadPoolExecutor(pool);
|
scheduler=new ScheduledThreadPoolExecutor(pool);
|
||||||
|
|
|
@ -383,7 +383,7 @@ public class DoSFilter implements Filter
|
||||||
// or if we were woken up we insist or we fail.
|
// or if we were woken up we insist or we fail.
|
||||||
Boolean throttled = (Boolean)request.getAttribute(__THROTTLED);
|
Boolean throttled = (Boolean)request.getAttribute(__THROTTLED);
|
||||||
long throttleMs = getThrottleMs();
|
long throttleMs = getThrottleMs();
|
||||||
if (throttled != Boolean.TRUE && throttleMs > 0)
|
if (!Boolean.TRUE.equals(throttled) && throttleMs > 0)
|
||||||
{
|
{
|
||||||
int priority = getPriority(request, tracker);
|
int priority = getPriority(request, tracker);
|
||||||
request.setAttribute(__THROTTLED, Boolean.TRUE);
|
request.setAttribute(__THROTTLED, Boolean.TRUE);
|
||||||
|
@ -401,7 +401,7 @@ public class DoSFilter implements Filter
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean resumed = (Boolean)request.getAttribute(_resumed);
|
Boolean resumed = (Boolean)request.getAttribute(_resumed);
|
||||||
if (resumed == Boolean.TRUE)
|
if (Boolean.TRUE.equals(resumed))
|
||||||
{
|
{
|
||||||
// We were resumed, we wait for the next pass.
|
// We were resumed, we wait for the next pass.
|
||||||
_passes.acquire();
|
_passes.acquire();
|
||||||
|
@ -446,7 +446,7 @@ public class DoSFilter implements Filter
|
||||||
{
|
{
|
||||||
ServletRequest candidate = asyncContext.getRequest();
|
ServletRequest candidate = asyncContext.getRequest();
|
||||||
Boolean suspended = (Boolean)candidate.getAttribute(_suspended);
|
Boolean suspended = (Boolean)candidate.getAttribute(_suspended);
|
||||||
if (suspended == Boolean.TRUE)
|
if (Boolean.TRUE.equals(suspended))
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Resuming {}", request);
|
LOG.debug("Resuming {}", request);
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class QoSFilter implements Filter
|
||||||
{
|
{
|
||||||
request.setAttribute(_suspended, Boolean.FALSE);
|
request.setAttribute(_suspended, Boolean.FALSE);
|
||||||
Boolean resumed = (Boolean)request.getAttribute(_resumed);
|
Boolean resumed = (Boolean)request.getAttribute(_resumed);
|
||||||
if (resumed == Boolean.TRUE)
|
if (Boolean.TRUE.equals(resumed))
|
||||||
{
|
{
|
||||||
_passes.acquire();
|
_passes.acquire();
|
||||||
accepted = true;
|
accepted = true;
|
||||||
|
@ -224,7 +224,7 @@ public class QoSFilter implements Filter
|
||||||
{
|
{
|
||||||
ServletRequest candidate = asyncContext.getRequest();
|
ServletRequest candidate = asyncContext.getRequest();
|
||||||
Boolean suspended = (Boolean)candidate.getAttribute(_suspended);
|
Boolean suspended = (Boolean)candidate.getAttribute(_suspended);
|
||||||
if (suspended == Boolean.TRUE)
|
if (Boolean.TRUE.equals(suspended))
|
||||||
{
|
{
|
||||||
candidate.setAttribute(_resumed, Boolean.TRUE);
|
candidate.setAttribute(_resumed, Boolean.TRUE);
|
||||||
asyncContext.dispatch();
|
asyncContext.dispatch();
|
||||||
|
|
|
@ -39,7 +39,6 @@ import java.net.SocketTimeoutException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.start.Props.Prop;
|
import org.eclipse.jetty.start.Props.Prop;
|
||||||
import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
||||||
|
@ -295,18 +294,18 @@ public class Main
|
||||||
args.parse(baseHome.getConfigSources());
|
args.parse(baseHome.getConfigSources());
|
||||||
|
|
||||||
Props props = baseHome.getConfigSources().getProps();
|
Props props = baseHome.getConfigSources().getProps();
|
||||||
Props.Prop home = props.getProp(BaseHome.JETTY_HOME);
|
Prop home = props.getProp(BaseHome.JETTY_HOME);
|
||||||
if (!args.getProperties().containsKey(BaseHome.JETTY_HOME))
|
if (!args.getProperties().containsKey(BaseHome.JETTY_HOME))
|
||||||
args.getProperties().setProperty(home);
|
args.getProperties().setProperty(home);
|
||||||
args.getProperties().setProperty(BaseHome.JETTY_HOME+".uri",
|
args.getProperties().setProperty(BaseHome.JETTY_HOME+".uri",
|
||||||
normalizeURI(baseHome.getHomePath().toUri().toString()),
|
normalizeURI(baseHome.getHomePath().toUri().toString()),
|
||||||
home.origin);
|
home.source);
|
||||||
Props.Prop base = props.getProp(BaseHome.JETTY_BASE);
|
Prop base = props.getProp(BaseHome.JETTY_BASE);
|
||||||
if (!args.getProperties().containsKey(BaseHome.JETTY_BASE))
|
if (!args.getProperties().containsKey(BaseHome.JETTY_BASE))
|
||||||
args.getProperties().setProperty(base);
|
args.getProperties().setProperty(base);
|
||||||
args.getProperties().setProperty(BaseHome.JETTY_BASE+".uri",
|
args.getProperties().setProperty(BaseHome.JETTY_BASE+".uri",
|
||||||
normalizeURI(baseHome.getBasePath().toUri().toString()),
|
normalizeURI(baseHome.getBasePath().toUri().toString()),
|
||||||
base.origin);
|
base.source);
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// 3) Module Registration
|
// 3) Module Registration
|
||||||
|
@ -426,25 +425,8 @@ public class Main
|
||||||
{
|
{
|
||||||
for (ConfigSource config : baseHome.getConfigSources())
|
for (ConfigSource config : baseHome.getConfigSources())
|
||||||
{
|
{
|
||||||
System.out.printf("ConfigSource %s%n",config.getId());
|
|
||||||
for (StartIni ini : config.getStartInis())
|
for (StartIni ini : config.getStartInis())
|
||||||
{
|
|
||||||
for (String line : ini.getAllLines())
|
|
||||||
{
|
|
||||||
Matcher m = Module.SET_PROPERTY.matcher(line);
|
|
||||||
if (m.matches() && m.groupCount()==3)
|
|
||||||
{
|
|
||||||
String name = m.group(2);
|
|
||||||
String value = m.group(3);
|
|
||||||
Prop p = args.getProperties().getProp(name);
|
|
||||||
if (p!=null && ("#".equals(m.group(1)) || !value.equals(p.value)))
|
|
||||||
{
|
|
||||||
ini.update(baseHome,args.getProperties());
|
ini.update(baseHome,args.getProperties());
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,10 +494,10 @@ public class Main
|
||||||
|
|
||||||
private void doStop(StartArgs args)
|
private void doStop(StartArgs args)
|
||||||
{
|
{
|
||||||
Props.Prop stopHostProp = args.getProperties().getProp("STOP.HOST", true);
|
Prop stopHostProp = args.getProperties().getProp("STOP.HOST", true);
|
||||||
Props.Prop stopPortProp = args.getProperties().getProp("STOP.PORT", true);
|
Prop stopPortProp = args.getProperties().getProp("STOP.PORT", true);
|
||||||
Props.Prop stopKeyProp = args.getProperties().getProp("STOP.KEY", true);
|
Prop stopKeyProp = args.getProperties().getProp("STOP.KEY", true);
|
||||||
Props.Prop stopWaitProp = args.getProperties().getProp("STOP.WAIT", true);
|
Prop stopWaitProp = args.getProperties().getProp("STOP.WAIT", true);
|
||||||
|
|
||||||
String stopHost = "127.0.0.1";
|
String stopHost = "127.0.0.1";
|
||||||
int stopPort = -1;
|
int stopPort = -1;
|
||||||
|
|
|
@ -37,7 +37,6 @@ import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.jetty.start.Props.Prop;
|
import org.eclipse.jetty.start.Props.Prop;
|
||||||
import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Module metadata, as defined in Jetty.
|
* Represents a Module metadata, as defined in Jetty.
|
||||||
|
@ -527,9 +526,12 @@ public class Module implements Comparable<Module>
|
||||||
if (m.matches() && m.groupCount()==3)
|
if (m.matches() && m.groupCount()==3)
|
||||||
{
|
{
|
||||||
String name = m.group(2);
|
String name = m.group(2);
|
||||||
|
String value = m.group(3);
|
||||||
Prop p = props.getProp(name);
|
Prop p = props.getProp(name);
|
||||||
if (p!=null && p.origin.startsWith(CommandLineConfigSource.ORIGIN_CMD_LINE))
|
|
||||||
|
if (p!=null && (p.source==null || !p.source.endsWith("?=")) && ("#".equals(m.group(1)) || !value.equals(p.value)))
|
||||||
{
|
{
|
||||||
|
System.err.printf("%s == %s :: %s%n",name,value,p.source);
|
||||||
StartLog.info("%-15s property set %s=%s",this._name,name,p.value);
|
StartLog.info("%-15s property set %s=%s",this._name,name,p.value);
|
||||||
out.printf("%s=%s%n",name,p.value);
|
out.printf("%s=%s%n",name,p.value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,7 +305,7 @@ public class Modules implements Iterable<Module>
|
||||||
{
|
{
|
||||||
for (Module p:providers)
|
for (Module p:providers)
|
||||||
{
|
{
|
||||||
if (p!=module && p.isEnabled())
|
if (!p.equals(module) && p.isEnabled())
|
||||||
{
|
{
|
||||||
// If the already enabled module is transitive and this enable is not
|
// If the already enabled module is transitive and this enable is not
|
||||||
if (p.isTransitive() && !transitive)
|
if (p.isTransitive() && !transitive)
|
||||||
|
@ -364,8 +364,8 @@ public class Modules implements Iterable<Module>
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a provider is already enabled, then add a transitive enable
|
// If a provider is already enabled, then add a transitive enable
|
||||||
if (providers.stream().filter(Module::isEnabled).count()!=0)
|
if (providers.stream().filter(Module::isEnabled).count()>0)
|
||||||
providers.stream().filter(m->m.isEnabled()&&m!=module).forEach(m->enable(newlyEnabled,m,"transitive provider of "+dependsOn+" for "+module.getName(),true));
|
providers.stream().filter(m->m.isEnabled()&&!m.equals(module)).forEach(m->enable(newlyEnabled,m,"transitive provider of "+dependsOn+" for "+module.getName(),true));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Is there an obvious default?
|
// Is there an obvious default?
|
||||||
|
|
|
@ -48,20 +48,13 @@ public final class Props implements Iterable<Prop>
|
||||||
{
|
{
|
||||||
public String key;
|
public String key;
|
||||||
public String value;
|
public String value;
|
||||||
public String origin;
|
public String source;
|
||||||
public Prop overrides;
|
|
||||||
|
|
||||||
public Prop(String key, String value, String origin)
|
public Prop(String key, String value, String source)
|
||||||
{
|
{
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.origin = origin;
|
this.source = source;
|
||||||
}
|
|
||||||
|
|
||||||
public Prop(String key, String value, String origin, Prop overrides)
|
|
||||||
{
|
|
||||||
this(key,value,origin);
|
|
||||||
this.overrides = overrides;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,15 +65,12 @@ public final class Props implements Iterable<Prop>
|
||||||
builder.append(key);
|
builder.append(key);
|
||||||
builder.append(", value=");
|
builder.append(", value=");
|
||||||
builder.append(value);
|
builder.append(value);
|
||||||
builder.append(", origin=");
|
builder.append(", source=");
|
||||||
builder.append(origin);
|
builder.append(source);
|
||||||
builder.append(", overrides=");
|
|
||||||
builder.append(overrides);
|
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String ORIGIN_SYSPROP = "<system-property>";
|
public static final String ORIGIN_SYSPROP = "<system-property>";
|
||||||
|
|
||||||
public static String getValue(String arg)
|
public static String getValue(String arg)
|
||||||
|
@ -342,16 +332,7 @@ public final class Props implements Iterable<Prop>
|
||||||
|
|
||||||
public void setProperty(String key, String value, String origin)
|
public void setProperty(String key, String value, String origin)
|
||||||
{
|
{
|
||||||
Prop prop = props.get(key);
|
props.put(key,new Prop(key,value,origin));
|
||||||
if (prop == null)
|
|
||||||
{
|
|
||||||
prop = new Prop(key,value,origin);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
prop = new Prop(key,value,origin,prop);
|
|
||||||
}
|
|
||||||
props.put(key,prop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size()
|
public int size()
|
||||||
|
|
|
@ -35,7 +35,6 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.start.Props.Prop;
|
import org.eclipse.jetty.start.Props.Prop;
|
||||||
import org.eclipse.jetty.start.config.ConfigSource;
|
import org.eclipse.jetty.start.config.ConfigSource;
|
||||||
|
@ -123,9 +122,6 @@ public class StartArgs
|
||||||
/** Map of enabled modules to the source of where that activation occurred */
|
/** Map of enabled modules to the source of where that activation occurred */
|
||||||
Map<String, List<String>> sources = new HashMap<>();
|
Map<String, List<String>> sources = new HashMap<>();
|
||||||
|
|
||||||
/** Map of properties to where that property was declared */
|
|
||||||
private Map<String, String> propertySource = new HashMap<>();
|
|
||||||
|
|
||||||
/** List of all active [files] sections from enabled modules */
|
/** List of all active [files] sections from enabled modules */
|
||||||
private List<FileArg> files = new ArrayList<>();
|
private List<FileArg> files = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -148,7 +144,7 @@ public class StartArgs
|
||||||
private List<Path> propertyFiles = new ArrayList<>();
|
private List<Path> propertyFiles = new ArrayList<>();
|
||||||
|
|
||||||
private Props properties = new Props();
|
private Props properties = new Props();
|
||||||
private Set<String> systemPropertyKeys = new HashSet<>();
|
private Map<String,String> systemPropertySource = new HashMap<>();
|
||||||
private List<String> rawLibs = new ArrayList<>();
|
private List<String> rawLibs = new ArrayList<>();
|
||||||
|
|
||||||
// jetty.base - build out commands
|
// jetty.base - build out commands
|
||||||
|
@ -205,12 +201,6 @@ public class StartArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSystemProperty(String key, String value)
|
|
||||||
{
|
|
||||||
this.systemPropertyKeys.add(key);
|
|
||||||
System.setProperty(key,value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addUniqueXmlFile(String xmlRef, Path xmlfile) throws IOException
|
private void addUniqueXmlFile(String xmlRef, Path xmlfile) throws IOException
|
||||||
{
|
{
|
||||||
if (!FS.canReadFile(xmlfile))
|
if (!FS.canReadFile(xmlfile))
|
||||||
|
@ -337,7 +327,7 @@ public class StartArgs
|
||||||
List<String> sortedKeys = new ArrayList<>();
|
List<String> sortedKeys = new ArrayList<>();
|
||||||
for (Prop prop : properties)
|
for (Prop prop : properties)
|
||||||
{
|
{
|
||||||
if (prop.origin.equals(Props.ORIGIN_SYSPROP))
|
if (prop.source.equals(Props.ORIGIN_SYSPROP))
|
||||||
{
|
{
|
||||||
continue; // skip
|
continue; // skip
|
||||||
}
|
}
|
||||||
|
@ -369,16 +359,7 @@ public class StartArgs
|
||||||
{
|
{
|
||||||
System.out.printf(" %s = %s%n",key,prop.value);
|
System.out.printf(" %s = %s%n",key,prop.value);
|
||||||
if (StartLog.isDebugEnabled())
|
if (StartLog.isDebugEnabled())
|
||||||
{
|
System.out.printf(" origin: %s%n",prop.source);
|
||||||
System.out.printf(" origin: %s%n",prop.origin);
|
|
||||||
while (prop.overrides != null)
|
|
||||||
{
|
|
||||||
prop = prop.overrides;
|
|
||||||
System.out.printf(" (overrides)%n");
|
|
||||||
System.out.printf(" %s = %s%n",key,prop.value);
|
|
||||||
System.out.printf(" origin: %s%n",prop.origin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,26 +369,25 @@ public class StartArgs
|
||||||
System.out.println("System Properties:");
|
System.out.println("System Properties:");
|
||||||
System.out.println("------------------");
|
System.out.println("------------------");
|
||||||
|
|
||||||
if (systemPropertyKeys.isEmpty())
|
if (systemPropertySource.keySet().isEmpty())
|
||||||
{
|
{
|
||||||
System.out.println(" (no system properties specified)");
|
System.out.println(" (no system properties specified)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> sortedKeys = new ArrayList<>();
|
List<String> sortedKeys = new ArrayList<>();
|
||||||
sortedKeys.addAll(systemPropertyKeys);
|
sortedKeys.addAll(systemPropertySource.keySet());
|
||||||
Collections.sort(sortedKeys);
|
Collections.sort(sortedKeys);
|
||||||
|
|
||||||
for (String key : sortedKeys)
|
for (String key : sortedKeys)
|
||||||
{
|
dumpSystemProperty(key);
|
||||||
String value = System.getProperty(key);
|
|
||||||
System.out.printf(" %s = %s%n",key,value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dumpSystemProperty(String key)
|
private void dumpSystemProperty(String key)
|
||||||
{
|
{
|
||||||
System.out.printf(" %s = %s%n",key,System.getProperty(key));
|
String value = System.getProperty(key);
|
||||||
|
String source = systemPropertySource.get(key);
|
||||||
|
System.out.printf(" %s = %s (%s)%n",key,value,source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -418,20 +398,20 @@ public class StartArgs
|
||||||
*/
|
*/
|
||||||
private void ensureSystemPropertySet(String key)
|
private void ensureSystemPropertySet(String key)
|
||||||
{
|
{
|
||||||
if (systemPropertyKeys.contains(key))
|
if (systemPropertySource.containsKey(key))
|
||||||
{
|
{
|
||||||
return; // done
|
return; // done
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.containsKey(key))
|
if (properties.containsKey(key))
|
||||||
{
|
{
|
||||||
String val = properties.expand(properties.getString(key));
|
Prop prop = properties.getProp(key);
|
||||||
if (val == null)
|
if (prop==null)
|
||||||
{
|
return; // no value set;
|
||||||
return; // no value to set
|
|
||||||
}
|
String val = properties.expand(prop.value);
|
||||||
// setup system property
|
// setup system property
|
||||||
systemPropertyKeys.add(key);
|
systemPropertySource.put(key,"property:"+prop.source);
|
||||||
System.setProperty(key,val);
|
System.setProperty(key,val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -446,7 +426,7 @@ public class StartArgs
|
||||||
{
|
{
|
||||||
StartLog.debug("Expanding System Properties");
|
StartLog.debug("Expanding System Properties");
|
||||||
|
|
||||||
for (String key : systemPropertyKeys)
|
for (String key : systemPropertySource.keySet())
|
||||||
{
|
{
|
||||||
String value = properties.getString(key);
|
String value = properties.getString(key);
|
||||||
if (value!=null)
|
if (value!=null)
|
||||||
|
@ -588,12 +568,9 @@ public class StartArgs
|
||||||
String key = assign[0];
|
String key = assign[0];
|
||||||
String value = assign.length==1?"":assign[1];
|
String value = assign.length==1?"":assign[1];
|
||||||
|
|
||||||
Property p = processProperty(key,value,"modules",k->{return System.getProperty(k);});
|
Prop p = processSystemProperty(key,value,null);
|
||||||
if (p!=null)
|
|
||||||
{
|
|
||||||
cmd.addRawArg("-D"+p.key+"="+getProperties().expand(p.value));
|
cmd.addRawArg("-D"+p.key+"="+getProperties().expand(p.value));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmd.addRawArg(x);
|
cmd.addRawArg(x);
|
||||||
|
@ -601,7 +578,7 @@ public class StartArgs
|
||||||
}
|
}
|
||||||
|
|
||||||
// System Properties
|
// System Properties
|
||||||
for (String propKey : systemPropertyKeys)
|
for (String propKey : systemPropertySource.keySet())
|
||||||
{
|
{
|
||||||
String value = System.getProperty(propKey);
|
String value = System.getProperty(propKey);
|
||||||
cmd.addEqualsArg("-D" + propKey,value);
|
cmd.addEqualsArg("-D" + propKey,value);
|
||||||
|
@ -737,7 +714,7 @@ public class StartArgs
|
||||||
|
|
||||||
public boolean hasSystemProperties()
|
public boolean hasSystemProperties()
|
||||||
{
|
{
|
||||||
for (String key : systemPropertyKeys)
|
for (String key : systemPropertySource.keySet())
|
||||||
{
|
{
|
||||||
// ignored keys
|
// ignored keys
|
||||||
if ("jetty.home".equals(key) || "jetty.base".equals(key) || "main.class".equals(key))
|
if ("jetty.home".equals(key) || "jetty.base".equals(key) || "main.class".equals(key))
|
||||||
|
@ -1096,13 +1073,10 @@ public class StartArgs
|
||||||
String key = assign[0];
|
String key = assign[0];
|
||||||
String value = assign.length==1?"":assign[1];
|
String value = assign.length==1?"":assign[1];
|
||||||
|
|
||||||
Property p = processProperty(key,value,source,k->{return System.getProperty(k);});
|
Prop p = processSystemProperty(key,value,source);
|
||||||
if (p!=null)
|
systemPropertySource.put(p.key,p.source);
|
||||||
{
|
|
||||||
systemPropertyKeys.add(p.key);
|
|
||||||
setProperty(p.key,p.value,p.source);
|
setProperty(p.key,p.value,p.source);
|
||||||
System.setProperty(p.key,p.value);
|
System.setProperty(p.key,p.value);
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,11 +1098,8 @@ public class StartArgs
|
||||||
String key = arg.substring(0,equals);
|
String key = arg.substring(0,equals);
|
||||||
String value = arg.substring(equals + 1);
|
String value = arg.substring(equals + 1);
|
||||||
|
|
||||||
Property p = processProperty(key,value,source,k->{return getProperties().getString(k);});
|
processAndSetProperty(key,value,source);
|
||||||
if (p!=null)
|
|
||||||
{
|
|
||||||
setProperty(p.key,p.value,p.source);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,12 +1128,12 @@ public class StartArgs
|
||||||
throw new UsageException(UsageException.ERR_BAD_ARG,"Unrecognized argument: \"%s\" in %s",arg,source);
|
throw new UsageException(UsageException.ERR_BAD_ARG,"Unrecognized argument: \"%s\" in %s",arg,source);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Property processProperty(String key,String value,String source, Function<String, String> getter)
|
protected Prop processSystemProperty(String key, String value, String source)
|
||||||
{
|
{
|
||||||
if (key.endsWith("+"))
|
if (key.endsWith("+"))
|
||||||
{
|
{
|
||||||
key = key.substring(0,key.length() - 1);
|
key = key.substring(0,key.length() - 1);
|
||||||
String orig = getter.apply(key);
|
String orig = System.getProperty(key);
|
||||||
if (orig == null || orig.isEmpty())
|
if (orig == null || orig.isEmpty())
|
||||||
{
|
{
|
||||||
if (value.startsWith(","))
|
if (value.startsWith(","))
|
||||||
|
@ -1171,27 +1142,55 @@ public class StartArgs
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = orig + value;
|
value = orig + value;
|
||||||
source = propertySource.get(key) + "," + source;
|
if (source!=null && systemPropertySource.containsKey(key))
|
||||||
|
source = systemPropertySource.get(key) + "," + source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (key.endsWith("?"))
|
else if (key.endsWith("?"))
|
||||||
{
|
{
|
||||||
key = key.substring(0,key.length() - 1);
|
key = key.substring(0,key.length() - 1);
|
||||||
String preset = getter.apply(key);
|
String preset = System.getProperty(key);
|
||||||
if (preset!=null)
|
if (preset!=null)
|
||||||
{
|
{
|
||||||
source = source+"?=";
|
|
||||||
value = preset;
|
value = preset;
|
||||||
|
source = systemPropertySource.get(key);
|
||||||
}
|
}
|
||||||
}
|
else if (source!=null)
|
||||||
else if (propertySource.containsKey(key))
|
source = source+"?=";
|
||||||
{
|
|
||||||
if (!propertySource.get(key).endsWith("[ini]"))
|
|
||||||
StartLog.warn("Property %s in %s already set in %s",key,source,propertySource.get(key));
|
|
||||||
propertySource.put(key,source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Property(key,value,source);
|
return new Prop(key, value, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void processAndSetProperty(String key,String value,String source)
|
||||||
|
{
|
||||||
|
if (key.endsWith("+"))
|
||||||
|
{
|
||||||
|
key = key.substring(0,key.length() - 1);
|
||||||
|
Prop orig = getProperties().getProp(key);
|
||||||
|
if (orig == null)
|
||||||
|
{
|
||||||
|
if (value.startsWith(","))
|
||||||
|
value = value.substring(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = orig.value + value;
|
||||||
|
source = orig.source + "," + source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (key.endsWith("?"))
|
||||||
|
{
|
||||||
|
key = key.substring(0,key.length() - 1);
|
||||||
|
Prop preset = getProperties().getProp(key);
|
||||||
|
if (preset!=null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (source!=null)
|
||||||
|
source = source+"?=";
|
||||||
|
}
|
||||||
|
|
||||||
|
setProperty(key,value,source);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableModules(String source, List<String> moduleNames)
|
private void enableModules(String source, List<String> moduleNames)
|
||||||
|
@ -1303,22 +1302,4 @@ public class StartArgs
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Property
|
|
||||||
{
|
|
||||||
String key;
|
|
||||||
String value;
|
|
||||||
String source;
|
|
||||||
public Property(String key, String value, String source)
|
|
||||||
{
|
|
||||||
this.key = key;
|
|
||||||
this.value = value;
|
|
||||||
this.source = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return String.format("%s=%s(%s)",key,value,source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,9 @@ public class StartIni extends TextFile
|
||||||
update = update.substring(0,update.lastIndexOf("."));
|
update = update.substring(0,update.lastIndexOf("."));
|
||||||
String source = baseHome.toShortForm(getFile());
|
String source = baseHome.toShortForm(getFile());
|
||||||
|
|
||||||
try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(getFile(),StandardCharsets.UTF_8,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.CREATE)))
|
PrintWriter writer = null;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
for (String line : getAllLines())
|
for (String line : getAllLines())
|
||||||
{
|
{
|
||||||
|
@ -102,23 +104,42 @@ public class StartIni extends TextFile
|
||||||
String name = m.group(2);
|
String name = m.group(2);
|
||||||
String value = m.group(3);
|
String value = m.group(3);
|
||||||
Prop p = props.getProp(name);
|
Prop p = props.getProp(name);
|
||||||
if (p!=null && ("#".equals(m.group(1)) || !value.equals(p.value)))
|
|
||||||
|
if (p!=null && (p.source==null || !p.source.endsWith("?=")) && ("#".equals(m.group(1)) || !value.equals(p.value)))
|
||||||
{
|
{
|
||||||
StartLog.info("%-15s property updated %s=%s",update,name,p.value);
|
if (writer==null)
|
||||||
writer.printf("%s=%s%n",name,p.value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
writer.println(line);
|
writer = new PrintWriter(Files.newBufferedWriter(getFile(),StandardCharsets.UTF_8,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.CREATE));
|
||||||
}
|
for (String l : getAllLines())
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
writer.println(line);
|
if (line.equals(l))
|
||||||
}
|
break;
|
||||||
|
writer.println(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StartLog.info("%-15s property updated %s=%s",update,name,p.value);
|
||||||
|
writer.printf("%s=%s%n",name,p.value);
|
||||||
|
}
|
||||||
|
else if (writer!=null)
|
||||||
|
{
|
||||||
|
writer.println(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (writer!=null)
|
||||||
|
{
|
||||||
|
writer.println(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (writer!=null)
|
||||||
|
{
|
||||||
StartLog.info("%-15s updated %s",update,source);
|
StartLog.info("%-15s updated %s",update,source);
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class ConfigurationAssert
|
||||||
"jetty.home.uri".equals(name) ||
|
"jetty.home.uri".equals(name) ||
|
||||||
"jetty.base.uri".equals(name) ||
|
"jetty.base.uri".equals(name) ||
|
||||||
"user.dir".equals(name) ||
|
"user.dir".equals(name) ||
|
||||||
prop.origin.equals(Props.ORIGIN_SYSPROP) ||
|
prop.source.equals(Props.ORIGIN_SYSPROP) ||
|
||||||
name.startsWith("java."))
|
name.startsWith("java."))
|
||||||
{
|
{
|
||||||
// strip these out from assertion, to make assertions easier.
|
// strip these out from assertion, to make assertions easier.
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.start;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@ public class PropsTest
|
||||||
assertThat(prefix,prop,notNullValue());
|
assertThat(prefix,prop,notNullValue());
|
||||||
assertThat(prefix + ".key",prop.key,is(expectedKey));
|
assertThat(prefix + ".key",prop.key,is(expectedKey));
|
||||||
assertThat(prefix + ".value",prop.value,is(expectedValue));
|
assertThat(prefix + ".value",prop.value,is(expectedValue));
|
||||||
assertThat(prefix + ".origin",prop.origin,is(expectedOrigin));
|
assertThat(prefix + ".origin",prop.source,is(expectedOrigin));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -49,7 +48,6 @@ public class PropsTest
|
||||||
|
|
||||||
Prop prop = props.getProp("java.io.tmpdir");
|
Prop prop = props.getProp("java.io.tmpdir");
|
||||||
assertProp("System Prop",prop,"java.io.tmpdir",expected,Props.ORIGIN_SYSPROP);
|
assertProp("System Prop",prop,"java.io.tmpdir",expected,Props.ORIGIN_SYSPROP);
|
||||||
assertThat("System Prop.overrides",prop.overrides,nullValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -63,25 +61,6 @@ public class PropsTest
|
||||||
|
|
||||||
Prop prop = props.getProp("name");
|
Prop prop = props.getProp("name");
|
||||||
assertProp(prefix,prop,"name","jetty",FROM_TEST);
|
assertProp(prefix,prop,"name","jetty",FROM_TEST);
|
||||||
assertThat(prefix + ".overrides",prop.overrides,nullValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testOverride()
|
|
||||||
{
|
|
||||||
Props props = new Props();
|
|
||||||
props.setProperty("name","jetty",FROM_TEST);
|
|
||||||
props.setProperty("name","altjetty","(Alt-Jetty)");
|
|
||||||
|
|
||||||
String prefix = "Overriden";
|
|
||||||
assertThat(prefix,props.getString("name"),is("altjetty"));
|
|
||||||
|
|
||||||
Prop prop = props.getProp("name");
|
|
||||||
assertProp(prefix,prop,"name","altjetty","(Alt-Jetty)");
|
|
||||||
Prop older = prop.overrides;
|
|
||||||
assertThat(prefix + ".overrides",older,notNullValue());
|
|
||||||
assertProp(prefix + ".overridden",older,"name","jetty",FROM_TEST);
|
|
||||||
assertThat(prefix + ".overridden",older.overrides,nullValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue