jetty-9 lots of code cleanups from findbugs, warnings and TODOs
This commit is contained in:
parent
f8ca13c3b3
commit
8101b67ce8
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.jetty.continuation;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletRequestWrapper;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.continuation;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
|
|
|
@ -14,18 +14,17 @@
|
|||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.eclipse.jetty.http.HttpGenerator.Action;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class HttpGeneratorClientTest
|
||||
{
|
||||
public final static String CONTENT="The quick brown fox jumped over the lazy dog.\nNow is the time for all good men to come to the aid of the party\nThe moon is blue to a fish in love.\n";
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.either;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
@ -31,7 +31,6 @@ import org.eclipse.jetty.http.HttpGenerator.Action;
|
|||
import org.eclipse.jetty.http.HttpGenerator.ResponseInfo;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
@ -12,8 +15,13 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
|
||||
public class AsyncByteArrayEndPoint extends ByteArrayEndPoint implements AsyncEndPoint
|
||||
{
|
||||
private static final int TICK=Integer.getInteger("org.eclipse.jetty.io.AsyncByteArrayEndPoint.TICK",100);
|
||||
public static final Logger LOG=Log.getLogger(AsyncByteArrayEndPoint.class);
|
||||
private volatile AsyncConnection _connection;
|
||||
private final Timer _timer;
|
||||
private AsyncConnection _connection;
|
||||
|
||||
private final TimerTask _checkTimeout=new TimeoutTask(this);
|
||||
|
||||
private final ReadInterest _readInterest = new ReadInterest()
|
||||
{
|
||||
@Override
|
||||
|
@ -24,6 +32,7 @@ public class AsyncByteArrayEndPoint extends ByteArrayEndPoint implements AsyncEn
|
|||
return _in==null || BufferUtil.hasContent(_in);
|
||||
}
|
||||
};
|
||||
|
||||
private final WriteFlusher _writeFlusher = new WriteFlusher(this)
|
||||
{
|
||||
@Override
|
||||
|
@ -33,18 +42,25 @@ public class AsyncByteArrayEndPoint extends ByteArrayEndPoint implements AsyncEn
|
|||
}
|
||||
};
|
||||
|
||||
public AsyncByteArrayEndPoint()
|
||||
public AsyncByteArrayEndPoint(Timer timer)
|
||||
{
|
||||
super();
|
||||
_timer=timer;
|
||||
_timer.schedule(_checkTimeout,TICK,TICK);
|
||||
}
|
||||
|
||||
public AsyncByteArrayEndPoint(byte[] input, int outputSize)
|
||||
public AsyncByteArrayEndPoint(Timer timer, byte[] input, int outputSize)
|
||||
{
|
||||
super(input,outputSize);
|
||||
_timer=timer;
|
||||
_timer.schedule(_checkTimeout,TICK,TICK);
|
||||
}
|
||||
|
||||
public AsyncByteArrayEndPoint(String input, int outputSize)
|
||||
public AsyncByteArrayEndPoint(Timer timer, String input, int outputSize)
|
||||
{
|
||||
super(input, outputSize);
|
||||
super(input,outputSize);
|
||||
_timer=timer;
|
||||
_timer.schedule(_checkTimeout,TICK,TICK);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,4 +156,25 @@ public class AsyncByteArrayEndPoint extends ByteArrayEndPoint implements AsyncEn
|
|||
public void onClose()
|
||||
{
|
||||
}
|
||||
|
||||
private static class TimeoutTask extends TimerTask
|
||||
{
|
||||
final WeakReference<AsyncByteArrayEndPoint> _endp;
|
||||
|
||||
TimeoutTask(AsyncByteArrayEndPoint endp)
|
||||
{
|
||||
_endp=new WeakReference<AsyncByteArrayEndPoint>(endp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
AsyncByteArrayEndPoint endp = _endp.get();
|
||||
if (endp==null)
|
||||
cancel();
|
||||
else
|
||||
endp.checkTimeout(System.currentTimeMillis());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -118,4 +118,5 @@ public interface AsyncEndPoint extends EndPoint
|
|||
void onClose();
|
||||
|
||||
void checkTimeout(long now);
|
||||
|
||||
}
|
||||
|
|
|
@ -66,10 +66,10 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable,
|
|||
}
|
||||
};
|
||||
|
||||
public SelectChannelEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey key, long idleTimeout) throws IOException
|
||||
public SelectChannelEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey key, long idleTimeout) throws IOException
|
||||
{
|
||||
super(channel);
|
||||
_selector = selectSet;
|
||||
_selector = selector;
|
||||
_key = key;
|
||||
setIdleTimeout(idleTimeout);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
|
||||
private final ManagedSelector[] _selectors;
|
||||
private volatile long _selectorIndex;
|
||||
private volatile long _idleTimeout;
|
||||
private volatile long _idleCheckPeriod;
|
||||
|
||||
protected SelectorManager()
|
||||
|
@ -65,26 +64,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
protected SelectorManager(@Name("selectors") int selectors)
|
||||
{
|
||||
_selectors = new ManagedSelector[selectors];
|
||||
setIdleTimeout(60000);
|
||||
setIdleCheckPeriod(1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the idle timeout, in milliseconds, after which a connection is closed
|
||||
*/
|
||||
protected long getIdleTimeout()
|
||||
{
|
||||
return _idleTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param idleTimeout the idle timeout, in milliseconds, after which a connection is closed
|
||||
*/
|
||||
public void setIdleTimeout(long idleTimeout)
|
||||
{
|
||||
_idleTimeout = idleTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the period, in milliseconds, a background thread checks for idle expiration
|
||||
*/
|
||||
|
@ -256,11 +238,13 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
LOG.warn(String.format("%s - %s", channel, attachment), ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String dump()
|
||||
{
|
||||
return AggregateLifeCycle.dump(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
AggregateLifeCycle.dumpObject(out, this);
|
||||
|
@ -476,7 +460,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
runChanges();
|
||||
}
|
||||
|
||||
private void processKey(SelectionKey key) throws IOException
|
||||
private void processKey(SelectionKey key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -549,12 +533,14 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
endPoint.getAsyncConnection().onClose();
|
||||
endPointClosed(endPoint);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String dump()
|
||||
{
|
||||
return AggregateLifeCycle.dump(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
out.append(String.valueOf(this)).append(" id=").append(String.valueOf(_id)).append("\n");
|
||||
|
@ -601,6 +587,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
Selector selector = _selector;
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.jetty.io.ssl;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
|
@ -393,7 +394,14 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
if (!_flushUnwrap)
|
||||
{
|
||||
_fillWrap = true;
|
||||
flush(BufferUtil.EMPTY_BUFFER);
|
||||
try
|
||||
{
|
||||
flush(BufferUtil.EMPTY_BUFFER);
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (BufferUtil.hasContent(_netOut))
|
||||
return 0;
|
||||
_fillWrap = false;
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -17,12 +7,22 @@ import static org.junit.Assert.assertThat;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Timer;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AsyncByteArrayEndPointTest
|
||||
{
|
||||
@Test
|
||||
public void testReadable() throws Exception
|
||||
{
|
||||
AsyncByteArrayEndPoint endp = new AsyncByteArrayEndPoint();
|
||||
AsyncByteArrayEndPoint endp = new AsyncByteArrayEndPoint(new Timer());
|
||||
endp.setInput("test input");
|
||||
|
||||
ByteBuffer buffer = BufferUtil.allocate(1024);
|
||||
|
@ -81,7 +81,7 @@ public class AsyncByteArrayEndPointTest
|
|||
@Test
|
||||
public void testWrite() throws Exception
|
||||
{
|
||||
AsyncByteArrayEndPoint endp = new AsyncByteArrayEndPoint((byte[])null,15);
|
||||
AsyncByteArrayEndPoint endp = new AsyncByteArrayEndPoint(new Timer(),(byte[])null,15);
|
||||
endp.setGrowOutput(false);
|
||||
endp.setOutput(BufferUtil.allocate(10));
|
||||
|
||||
|
@ -106,12 +106,10 @@ public class AsyncByteArrayEndPointTest
|
|||
assertEquals(" more.",endp.getOutputString());
|
||||
}
|
||||
|
||||
// TODO: idle timeout testing should be done with a SelectorManager
|
||||
@Ignore
|
||||
@Test
|
||||
public void testIdle() throws Exception
|
||||
{
|
||||
AsyncByteArrayEndPoint endp = new AsyncByteArrayEndPoint();
|
||||
AsyncByteArrayEndPoint endp = new AsyncByteArrayEndPoint(new Timer());
|
||||
endp.setIdleTimeout(500);
|
||||
endp.setInput("test");
|
||||
endp.setGrowOutput(false);
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
|
||||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -33,11 +38,6 @@ import org.eclipse.jetty.util.IO;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class IOTest
|
||||
{
|
||||
@Test
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
|
@ -20,12 +27,6 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
|
||||
{
|
||||
|
@ -70,11 +71,10 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
|
|||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Ignore // SSL does not do half closes
|
||||
@Override
|
||||
public void testShutdown() throws Exception
|
||||
{
|
||||
// SSL does not do half closes
|
||||
}
|
||||
|
||||
|
||||
|
@ -268,7 +268,6 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
|
|||
ByteBuffer serverIn = ByteBuffer.allocate(server.getSession().getApplicationBufferSize());
|
||||
ByteBuffer serverOut = ByteBuffer.allocate(server.getSession().getApplicationBufferSize());
|
||||
ByteBuffer clientIn = ByteBuffer.allocate(client.getSession().getApplicationBufferSize());
|
||||
ByteBuffer clientOut = ByteBuffer.allocate(client.getSession().getApplicationBufferSize());
|
||||
|
||||
SSLEngineResult result;
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -24,12 +30,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SelectChannelEndPointTest
|
||||
{
|
||||
protected volatile AsyncEndPoint _lastEndp;
|
||||
|
@ -52,14 +52,11 @@ public class SelectChannelEndPointTest
|
|||
@Override
|
||||
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey selectionKey) throws IOException
|
||||
{
|
||||
SelectChannelEndPoint endp = new SelectChannelEndPoint(channel,selectSet, selectionKey, getIdleTimeout());
|
||||
SelectChannelEndPoint endp = new SelectChannelEndPoint(channel,selectSet, selectionKey, 60000);
|
||||
_lastEndp=endp;
|
||||
return endp;
|
||||
}
|
||||
};
|
||||
{
|
||||
_manager.setIdleTimeout(600000); // TODO: use smaller value
|
||||
}
|
||||
|
||||
// Must be volatile or the test may fail spuriously
|
||||
protected volatile int _blockAt=0;
|
||||
|
@ -328,7 +325,9 @@ public class SelectChannelEndPointTest
|
|||
clientOutputStream.write("12345678".getBytes("UTF-8"));
|
||||
clientOutputStream.flush();
|
||||
|
||||
while(_lastEndp==null);
|
||||
long wait=System.currentTimeMillis()+1000;
|
||||
while(_lastEndp==null && System.currentTimeMillis()<wait)
|
||||
Thread.yield();
|
||||
|
||||
_lastEndp.setIdleTimeout(10 * specifiedTimeout);
|
||||
Thread.sleep((11*specifiedTimeout)/10);
|
||||
|
@ -393,7 +392,7 @@ public class SelectChannelEndPointTest
|
|||
assertTrue(idle<2000);
|
||||
|
||||
// But endpoint may still be open for a little bit.
|
||||
if (_lastEndp.isOpen());
|
||||
if (_lastEndp.isOpen())
|
||||
Thread.sleep(2000);
|
||||
|
||||
// endpoint is closed.
|
||||
|
@ -487,6 +486,7 @@ public class SelectChannelEndPointTest
|
|||
|
||||
new Thread()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Thread.currentThread().setPriority(MAX_PRIORITY);
|
||||
|
|
|
@ -1,25 +1,32 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
|
@ -49,7 +56,6 @@ public class SslConnectionTest
|
|||
AsyncConnection appConnection = new TestConnection(sslConnection.getSslEndPoint());
|
||||
sslConnection.getSslEndPoint().setAsyncConnection(appConnection);
|
||||
|
||||
// System.err.println("New Connection "+sslConnection);
|
||||
return sslConnection;
|
||||
|
||||
}
|
||||
|
@ -57,20 +63,14 @@ public class SslConnectionTest
|
|||
@Override
|
||||
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey selectionKey) throws IOException
|
||||
{
|
||||
SelectChannelEndPoint endp = new SelectChannelEndPoint(channel,selectSet, selectionKey, getIdleTimeout());
|
||||
SelectChannelEndPoint endp = new SelectChannelEndPoint(channel,selectSet, selectionKey, 60000);
|
||||
_lastEndp=endp;
|
||||
// System.err.println("newEndPoint "+endp);
|
||||
return endp;
|
||||
}
|
||||
};
|
||||
{
|
||||
_manager.setIdleTimeout(600000); // TODO: use smaller value
|
||||
}
|
||||
|
||||
// Must be volatile or the test may fail spuriously
|
||||
protected volatile int _blockAt=0;
|
||||
private volatile int _writeCount=1;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void initSslEngine() throws Exception
|
||||
|
@ -85,7 +85,6 @@ public class SslConnectionTest
|
|||
@Before
|
||||
public void startManager() throws Exception
|
||||
{
|
||||
_writeCount=1;
|
||||
_lastEndp=null;
|
||||
_connector = ServerSocketChannel.open();
|
||||
_connector.socket().bind(null);
|
||||
|
@ -115,21 +114,18 @@ public class SslConnectionTest
|
|||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
// System.err.println("onOpen");
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
// System.err.println("onClose");
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onFillable()
|
||||
{
|
||||
AsyncEndPoint endp = getEndPoint();
|
||||
// System.err.println("onReadable "+endp);
|
||||
try
|
||||
{
|
||||
boolean progress=true;
|
||||
|
@ -139,16 +135,12 @@ public class SslConnectionTest
|
|||
|
||||
// Fill the input buffer with everything available
|
||||
int filled=endp.fill(_in);
|
||||
// System.err.println("filled="+filled);
|
||||
while (filled>0)
|
||||
{
|
||||
progress=true;
|
||||
filled=endp.fill(_in);
|
||||
// System.err.println("filled="+filled);
|
||||
}
|
||||
|
||||
// System.err.println(BufferUtil.toDetailString(_in));
|
||||
|
||||
// Write everything
|
||||
int l=_in.remaining();
|
||||
if (l>0)
|
||||
|
@ -156,13 +148,11 @@ public class SslConnectionTest
|
|||
FutureCallback<Void> blockingWrite= new FutureCallback<>();
|
||||
endp.write(null,blockingWrite,_in);
|
||||
blockingWrite.get();
|
||||
// System.err.println("wrote "+l);
|
||||
}
|
||||
|
||||
// are we done?
|
||||
if (endp.isInputShutdown())
|
||||
{
|
||||
// System.err.println("shutdown");
|
||||
endp.shutdownOutput();
|
||||
}
|
||||
}
|
||||
|
@ -192,60 +182,52 @@ public class SslConnectionTest
|
|||
@Test
|
||||
public void testHelloWorld() throws Exception
|
||||
{
|
||||
//Log.getRootLogger().setDebugEnabled(true);
|
||||
|
||||
// Log.getRootLogger().setDebugEnabled(true);
|
||||
Socket client = newClient();
|
||||
// System.err.println("client="+client);
|
||||
client.setSoTimeout(600000); // TODO: restore to smaller value
|
||||
client.setSoTimeout(60000);
|
||||
|
||||
SocketChannel server = _connector.accept();
|
||||
server.configureBlocking(false);
|
||||
_manager.accept(server);
|
||||
|
||||
client.getOutputStream().write("HelloWorld".getBytes("UTF-8"));
|
||||
// System.err.println("wrote");
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = client.getInputStream().read(buffer);
|
||||
// System.err.println(new String(buffer,0,len,"UTF-8"));
|
||||
|
||||
int len=client.getInputStream().read(buffer);
|
||||
Assert.assertEquals(10,len);
|
||||
Assert.assertEquals("HelloWorld",new String(buffer,0,len,StringUtil.__UTF8_CHARSET));
|
||||
|
||||
client.close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testNasty() throws Exception
|
||||
public void testManyLines() throws Exception
|
||||
{
|
||||
//Log.getRootLogger().setDebugEnabled(true);
|
||||
|
||||
// Log.getRootLogger().setDebugEnabled(true);
|
||||
final Socket client = newClient();
|
||||
// System.err.println("client="+client);
|
||||
client.setSoTimeout(600000); // TODO: restore to smaller value
|
||||
client.setSoTimeout(60000);
|
||||
|
||||
SocketChannel server = _connector.accept();
|
||||
server.configureBlocking(false);
|
||||
_manager.accept(server);
|
||||
|
||||
final int LINES=20;
|
||||
final CountDownLatch count=new CountDownLatch(LINES);
|
||||
|
||||
|
||||
new Thread()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
while(true)
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream(),StringUtil.__UTF8_CHARSET));
|
||||
while(count.getCount()>0)
|
||||
{
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = client.getInputStream().read(buffer);
|
||||
if (len<0)
|
||||
{
|
||||
System.err.println("===");
|
||||
return;
|
||||
}
|
||||
// System.err.println(new String(buffer,0,len,"UTF-8"));
|
||||
|
||||
String line=in.readLine();
|
||||
if (line==null)
|
||||
break;
|
||||
// System.err.println(line);
|
||||
count.countDown();
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
|
@ -255,15 +237,18 @@ public class SslConnectionTest
|
|||
}
|
||||
}.start();
|
||||
|
||||
for (int i=0;i<100000;i++)
|
||||
for (int i=0;i<LINES;i++)
|
||||
{
|
||||
client.getOutputStream().write(("HelloWorld "+i+"\n").getBytes("UTF-8"));
|
||||
// System.err.println("wrote");
|
||||
if (i%1000==0)
|
||||
{
|
||||
client.getOutputStream().flush();
|
||||
Thread.sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
Thread.sleep(20000);
|
||||
Assert.assertTrue(count.await(20,TimeUnit.SECONDS));
|
||||
client.close();
|
||||
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ public class Dispatcher implements RequestDispatcher
|
|||
final String old_query=baseRequest.getQueryString();
|
||||
final Attributes old_attr=baseRequest.getAttributes();
|
||||
final DispatcherType old_type=baseRequest.getDispatcherType();
|
||||
MultiMap<String> old_params=baseRequest.getParameters();
|
||||
MultiMap old_params=baseRequest.getParameters();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
|
||||
import org.eclipse.jetty.http.HttpContent;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.util.ByteArrayOutputStream2;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Timer;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
|
@ -32,6 +33,7 @@ public class LocalHttpConnector extends HttpConnector
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(LocalHttpConnector.class);
|
||||
private final BlockingQueue<LocalEndPoint> _connects = new LinkedBlockingQueue<LocalEndPoint>();
|
||||
private Timer _timer;
|
||||
private LocalExecutor _executor;
|
||||
|
||||
public LocalHttpConnector()
|
||||
|
@ -107,6 +109,7 @@ public class LocalHttpConnector extends HttpConnector
|
|||
protected void doStart() throws Exception
|
||||
{
|
||||
super.doStart();
|
||||
_timer=new Timer(String.format("LocalHttpConnector@%x:Timer",hashCode()),true);
|
||||
_executor=new LocalExecutor(findExecutor());
|
||||
}
|
||||
|
||||
|
@ -114,6 +117,7 @@ public class LocalHttpConnector extends HttpConnector
|
|||
protected void doStop() throws Exception
|
||||
{
|
||||
super.doStop();
|
||||
_timer.cancel();
|
||||
_executor=null;
|
||||
}
|
||||
|
||||
|
@ -169,6 +173,7 @@ public class LocalHttpConnector extends HttpConnector
|
|||
|
||||
public LocalEndPoint()
|
||||
{
|
||||
super(_timer);
|
||||
setGrowOutput(true);
|
||||
setIdleTimeout(LocalHttpConnector.this.getIdleTimeout());
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.DispatcherType;
|
||||
|
@ -123,7 +124,7 @@ public class Request implements HttpServletRequest
|
|||
private boolean _asyncSupported = true;
|
||||
private volatile Attributes _attributes;
|
||||
private Authentication _authentication;
|
||||
private MultiMap<String> _baseParameters;
|
||||
private MultiMap _baseParameters;
|
||||
private String _characterEncoding;
|
||||
private ContextHandler.Context _context;
|
||||
private boolean _newContext;
|
||||
|
@ -135,7 +136,7 @@ public class Request implements HttpServletRequest
|
|||
private int _inputState = __NONE;
|
||||
private HttpMethod _httpMethod;
|
||||
private String _method;
|
||||
private MultiMap<String> _parameters;
|
||||
private MultiMap _parameters;
|
||||
private boolean _paramsExtracted;
|
||||
private String _pathInfo;
|
||||
private int _port;
|
||||
|
@ -190,7 +191,7 @@ public class Request implements HttpServletRequest
|
|||
public void extractParameters()
|
||||
{
|
||||
if (_baseParameters == null)
|
||||
_baseParameters = new MultiMap<String>(16);
|
||||
_baseParameters = new MultiMap();
|
||||
|
||||
if (_paramsExtracted)
|
||||
{
|
||||
|
@ -713,7 +714,7 @@ public class Request implements HttpServletRequest
|
|||
/**
|
||||
* @return Returns the parameters.
|
||||
*/
|
||||
public MultiMap<String> getParameters()
|
||||
public MultiMap getParameters()
|
||||
{
|
||||
return _parameters;
|
||||
}
|
||||
|
@ -1707,7 +1708,7 @@ public class Request implements HttpServletRequest
|
|||
* @param parameters
|
||||
* The parameters to set.
|
||||
*/
|
||||
public void setParameters(MultiMap<String> parameters)
|
||||
public void setParameters(MultiMap parameters)
|
||||
{
|
||||
_parameters = (parameters == null)?_baseParameters:parameters;
|
||||
if (_paramsExtracted && _parameters == null)
|
||||
|
@ -2033,7 +2034,7 @@ public class Request implements HttpServletRequest
|
|||
public void mergeQueryString(String query)
|
||||
{
|
||||
// extract parameters from dispatch query
|
||||
MultiMap<String> parameters = new MultiMap<String>();
|
||||
MultiMap parameters = new MultiMap();
|
||||
UrlEncoded.decodeTo(query,parameters,getCharacterEncoding());
|
||||
|
||||
boolean merge_old_query = false;
|
||||
|
@ -2068,10 +2069,10 @@ public class Request implements HttpServletRequest
|
|||
if (merge_old_query)
|
||||
{
|
||||
StringBuilder overridden_query_string = new StringBuilder();
|
||||
MultiMap<String> overridden_old_query = new MultiMap<String>();
|
||||
MultiMap overridden_old_query = new MultiMap();
|
||||
UrlEncoded.decodeTo(_queryString,overridden_old_query,getCharacterEncoding());
|
||||
|
||||
MultiMap<String> overridden_new_query = new MultiMap<String>();
|
||||
MultiMap overridden_new_query = new MultiMap();
|
||||
UrlEncoded.decodeTo(query,overridden_new_query,getCharacterEncoding());
|
||||
|
||||
Iterator<Entry<String, Object>> iter = overridden_old_query.entrySet().iterator();
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.eclipse.jetty.util.StringUtil;
|
|||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.omg.CORBA._PolicyStub;
|
||||
|
||||
/** Response.
|
||||
* <p>
|
||||
|
|
|
@ -210,13 +210,6 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
findExecutor().execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long getIdleTimeout()
|
||||
{
|
||||
// TODO: avoid override this method
|
||||
return SelectChannelConnector.this.getIdleTimeout();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointClosed(AsyncEndPoint endpoint)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -35,6 +35,7 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public Handler[] getChildHandlers()
|
||||
{
|
||||
Object list = expandChildren(null,null);
|
||||
|
@ -42,6 +43,7 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public Handler[] getChildHandlersByClass(Class<?> byclass)
|
||||
{
|
||||
Object list = expandChildren(null,byclass);
|
||||
|
@ -49,6 +51,7 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public <T extends Handler> T getChildHandlerByClass(Class<T> byclass)
|
||||
{
|
||||
// TODO this can be more efficient?
|
||||
|
@ -65,7 +68,7 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected Object expandHandler(Handler handler, Object list, Class<Handler> byClass)
|
||||
protected Object expandHandler(Handler handler, Object list, Class<?> byClass)
|
||||
{
|
||||
if (handler==null)
|
||||
return list;
|
||||
|
@ -91,7 +94,7 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement
|
|||
if (root==null || handler==null)
|
||||
return null;
|
||||
|
||||
Handler[] branches=root.getChildHandlersByClass(type);
|
||||
Handler[] branches=root.getChildHandlersByClass((Class<Handler>)type);
|
||||
if (branches!=null)
|
||||
{
|
||||
for (Handler h:branches)
|
||||
|
@ -110,6 +113,7 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void dump(Appendable out,String indent) throws IOException
|
||||
{
|
||||
dumpThis(out);
|
||||
|
|
|
@ -68,12 +68,12 @@ import org.eclipse.jetty.util.Loader;
|
|||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.annotation.Managed;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.annotation.Managed;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ContextHandlerCollection extends HandlerCollection
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(ContextHandlerCollection.class);
|
||||
|
||||
private volatile PathMap _contextMap;
|
||||
private volatile PathMap<Object> _contextMap;
|
||||
private Class<? extends ContextHandler> _contextClass = ContextHandler.class;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -62,7 +62,7 @@ public class ContextHandlerCollection extends HandlerCollection
|
|||
*/
|
||||
public void mapContexts()
|
||||
{
|
||||
PathMap contextMap = new PathMap();
|
||||
PathMap<Object> contextMap = new PathMap<Object>();
|
||||
Handler[] branches = getHandlers();
|
||||
|
||||
|
||||
|
@ -107,13 +107,13 @@ public class ContextHandlerCollection extends HandlerCollection
|
|||
|
||||
if (vhosts!=null && vhosts.length>0)
|
||||
{
|
||||
Map hosts;
|
||||
Map<String, Object> hosts;
|
||||
|
||||
if (contexts instanceof Map)
|
||||
hosts=(Map)contexts;
|
||||
hosts=(Map<String, Object>)contexts;
|
||||
else
|
||||
{
|
||||
hosts=new HashMap();
|
||||
hosts=new HashMap<String, Object>();
|
||||
hosts.put("*",contexts);
|
||||
contextMap.put(contextPath, hosts);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class ContextHandlerCollection extends HandlerCollection
|
|||
}
|
||||
else if (contexts instanceof Map)
|
||||
{
|
||||
Map hosts=(Map)contexts;
|
||||
Map<String, Object> hosts=(Map<String, Object>)contexts;
|
||||
contexts=hosts.get("*");
|
||||
contexts= LazyList.add(contexts, branches[b]);
|
||||
hosts.put("*",contexts);
|
||||
|
@ -194,7 +194,7 @@ public class ContextHandlerCollection extends HandlerCollection
|
|||
// { context path =>
|
||||
// { virtual host => context }
|
||||
// }
|
||||
PathMap map = _contextMap;
|
||||
PathMap<Object> map = _contextMap;
|
||||
if (map!=null && target!=null && target.startsWith("/"))
|
||||
{
|
||||
// first, get all contexts matched by context path
|
||||
|
@ -295,7 +295,7 @@ public class ContextHandlerCollection extends HandlerCollection
|
|||
/**
|
||||
* @return The class to use to add new Contexts
|
||||
*/
|
||||
public Class getContextClass()
|
||||
public Class<?> getContextClass()
|
||||
{
|
||||
return _contextClass;
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ public class ContextHandlerCollection extends HandlerCollection
|
|||
/**
|
||||
* @param contextClass The class to use to add new Contexts
|
||||
*/
|
||||
public void setContextClass(Class contextClass)
|
||||
public void setContextClass(Class<? extends ContextHandler> contextClass)
|
||||
{
|
||||
if (contextClass ==null || !(ContextHandler.class.isAssignableFrom(contextClass)))
|
||||
throw new IllegalArgumentException();
|
||||
|
|
|
@ -32,8 +32,8 @@ import org.eclipse.jetty.continuation.Continuation;
|
|||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.continuation.ContinuationSupport;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.gzip.CompressedResponseWrapper;
|
||||
import org.eclipse.jetty.http.gzip.AbstractCompressedStream;
|
||||
import org.eclipse.jetty.http.gzip.CompressedResponseWrapper;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -288,7 +288,7 @@ public class HandlerCollection extends AbstractHandlerContainer
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
protected Object expandChildren(Object list, Class byClass)
|
||||
protected Object expandChildren(Object list, Class<?> byClass)
|
||||
{
|
||||
Handler[] handlers = getHandlers();
|
||||
for (int i=0;handlers!=null && i<handlers.length;i++)
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.sql.Connection;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -21,6 +24,7 @@ import java.net.Socket;
|
|||
import java.util.Arrays;
|
||||
import java.util.concurrent.Exchanger;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -35,9 +39,6 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @version $Revision: 889 $ $Date: 2009-09-14 14:52:16 +1000 (Mon, 14 Sep 2009) $
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
|
@ -20,6 +22,7 @@ import java.net.Socket;
|
|||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
|
@ -39,8 +42,6 @@ import org.junit.Before;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class AsyncStressTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AsyncStressTest.class);
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.net.SocketException;
|
|||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.BrokenBarrierException;
|
||||
import java.util.concurrent.Exchanger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -39,13 +38,11 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.matchers.JUnitMatchers;
|
||||
|
|
|
@ -217,7 +217,7 @@ public class HttpURITest
|
|||
try
|
||||
{
|
||||
HttpURI huri=new HttpURI(uri);
|
||||
MultiMap<String> params = new MultiMap<String>();
|
||||
MultiMap params = new MultiMap();
|
||||
huri.decodeQueryTo(params);
|
||||
System.err.println(params);
|
||||
Assert.assertTrue(false);
|
||||
|
@ -229,7 +229,7 @@ public class HttpURITest
|
|||
try
|
||||
{
|
||||
HttpURI huri=new HttpURI(uri);
|
||||
MultiMap<String> params = new MultiMap<String>();
|
||||
MultiMap params = new MultiMap();
|
||||
huri.decodeQueryTo(params,"UTF-8");
|
||||
System.err.println(params);
|
||||
Assert.assertTrue(false);
|
||||
|
@ -247,7 +247,7 @@ public class HttpURITest
|
|||
{
|
||||
HttpURI uri = new HttpURI("/path?value="+URLEncoder.encode(value,"UTF-8"));
|
||||
|
||||
MultiMap<String> parameters = new MultiMap<String>();
|
||||
MultiMap parameters = new MultiMap();
|
||||
uri.decodeQueryTo(parameters,"UTF-8");
|
||||
assertEquals(value,parameters.get("value"));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -33,9 +35,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class LocalAsyncContextTest
|
||||
{
|
||||
protected Server _server = new Server();
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.eclipse.jetty.server;
|
|||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
*/
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
@ -31,11 +36,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -15,11 +15,11 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
@ -23,6 +28,7 @@ import java.util.Iterator;
|
|||
import java.util.Locale;
|
||||
import java.util.Timer;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -44,11 +50,6 @@ import org.junit.Before;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -67,7 +68,7 @@ public class ResponseTest
|
|||
_server.setHandler(new DumpHandler());
|
||||
_server.start();
|
||||
|
||||
AsyncByteArrayEndPoint endp = new AsyncByteArrayEndPoint();
|
||||
AsyncByteArrayEndPoint endp = new AsyncByteArrayEndPoint(new Timer(true));
|
||||
HttpInput input = new HttpInput();
|
||||
AsyncConnection connection = new AbstractAsyncConnection(endp,new Executor()
|
||||
{
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
@ -23,8 +25,6 @@ import org.eclipse.jetty.util.IO;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SelectChannelTimeoutTest extends ConnectorTimeoutTest
|
||||
{
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ package org.eclipse.jetty.server;
|
|||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -20,6 +22,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -32,8 +35,6 @@ import org.junit.Assert;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
|
||||
public class SlowClientWithPipelinedRequestTest
|
||||
{
|
||||
private final AtomicInteger handles = new AtomicInteger();
|
||||
|
|
|
@ -13,12 +13,17 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.Queue;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -35,10 +40,6 @@ import org.junit.Before;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
public class StressTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(StressTest.class);
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
|
|
|
@ -13,11 +13,17 @@
|
|||
|
||||
package org.eclipse.jetty.server.handler;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.CyclicBarrier;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -32,11 +38,6 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class StatisticsHandlerTest
|
||||
{
|
||||
private Server _server;
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.io.OutputStream;
|
|||
import java.net.Socket;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
@ -34,6 +35,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
|
|
|
@ -15,27 +15,20 @@ package org.eclipse.jetty.server.ssl;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.security.KeyStore;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.server.HttpServerTestBase;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
|
||||
/**
|
||||
* HttpServer Tester.
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.jetty.server.ssl;
|
|||
import java.io.FileInputStream;
|
||||
import java.net.Socket;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-project</artifactId>
|
||||
<version>9.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jetty-util-ajax</artifactId>
|
||||
<name>Jetty :: Utilities :: Ajax(JSON)</name>
|
||||
<description>JSON/Ajax Utility classes for Jetty</description>
|
||||
<properties>
|
||||
<bundle-symbolic-name>${project.groupId}.util.ajax</bundle-symbolic-name>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>manifest</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Import-Package>javax.servlet.*;version="2.6.0",org.slf4j;version="[1.5,2.0)";resolution:=optional,org.slf4j.impl;version="[1.5,2.0)";resolution:=optional,*</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!--
|
||||
Required for OSGI
|
||||
-->
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>config</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<onlyAnalyze>org.eclipse.jetty.util.ajax.*</onlyAnalyze>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -711,7 +711,7 @@ public class BufferUtil
|
|||
buf.append(buffer.getClass().getSimpleName());
|
||||
buf.append("@");
|
||||
if (buffer.hasArray())
|
||||
buf.append(Integer.toHexString(buffer.array().hashCode()));
|
||||
buf.append(Integer.toHexString(((Object)buffer.array()).hashCode()));
|
||||
else
|
||||
buf.append("?");
|
||||
buf.append("[p=");
|
||||
|
|
|
@ -289,7 +289,7 @@ public class DateCache
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
private volatile ByteBuffer _buffer;
|
||||
private volatile String _last;
|
||||
private volatile Object _last;
|
||||
public synchronized ByteBuffer formatBuffer(long date)
|
||||
{
|
||||
String d = format(date);
|
||||
|
|
|
@ -13,67 +13,36 @@
|
|||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** A multi valued Map.
|
||||
* This Map specializes HashMap and provides methods
|
||||
* that operate on multi valued items.
|
||||
* <P>
|
||||
* Implemented as a map of LazyList values
|
||||
* @param <K> The key type of the map.
|
||||
*
|
||||
* @see LazyList
|
||||
*
|
||||
*/
|
||||
public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
||||
public class MultiMap implements Map<String,Object>
|
||||
{
|
||||
private static final long serialVersionUID = -6878723138353851005L;
|
||||
Map<K,Object> _map;
|
||||
ConcurrentMap<K, Object> _cmap;
|
||||
Map<String,Object> _map;
|
||||
|
||||
public MultiMap()
|
||||
{
|
||||
_map=new HashMap<K, Object>();
|
||||
_map=new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public MultiMap(Map<K,Object> map)
|
||||
|
||||
public MultiMap(Map<String,Object> map)
|
||||
{
|
||||
if (map instanceof ConcurrentMap)
|
||||
_map=_cmap=new ConcurrentHashMap<K, Object>(map);
|
||||
else
|
||||
_map=new HashMap<K, Object>(map);
|
||||
_map=new HashMap<String, Object>(map);
|
||||
}
|
||||
|
||||
public MultiMap(MultiMap<K> map)
|
||||
|
||||
public MultiMap(MultiMap map)
|
||||
{
|
||||
if (map._cmap!=null)
|
||||
_map=_cmap=new ConcurrentHashMap<K, Object>(map._cmap);
|
||||
else
|
||||
_map=new HashMap<K,Object>(map._map);
|
||||
_map=new HashMap<String,Object>(map._map);
|
||||
}
|
||||
|
||||
public MultiMap(int capacity)
|
||||
{
|
||||
_map=new HashMap<K, Object>(capacity);
|
||||
}
|
||||
|
||||
public MultiMap(boolean concurrent)
|
||||
{
|
||||
if (concurrent)
|
||||
_map=_cmap=new ConcurrentHashMap<K, Object>();
|
||||
else
|
||||
_map=new HashMap<K, Object>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Get multiple values.
|
||||
|
@ -140,6 +109,7 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public Object get(Object name)
|
||||
{
|
||||
Object l=_map.get(name);
|
||||
|
@ -161,7 +131,8 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
* @param value The entry value.
|
||||
* @return The previous value or null.
|
||||
*/
|
||||
public Object put(K name, Object value)
|
||||
@Override
|
||||
public Object put(String name, Object value)
|
||||
{
|
||||
return _map.put(name,LazyList.add(null,value));
|
||||
}
|
||||
|
@ -172,7 +143,7 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
* @param values The List of multiple values.
|
||||
* @return The previous value or null.
|
||||
*/
|
||||
public Object putValues(K name, List<? extends Object> values)
|
||||
public Object putValues(String name, List<? extends Object> values)
|
||||
{
|
||||
return _map.put(name,values);
|
||||
}
|
||||
|
@ -183,7 +154,7 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
* @param values The String array of multiple values.
|
||||
* @return The previous value or null.
|
||||
*/
|
||||
public Object putValues(K name, String... values)
|
||||
public Object putValues(String name, String... values)
|
||||
{
|
||||
Object list=null;
|
||||
for (int i=0;i<values.length;i++)
|
||||
|
@ -199,7 +170,7 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
* @param name The entry key.
|
||||
* @param value The entry value.
|
||||
*/
|
||||
public void add(K name, Object value)
|
||||
public void add(String name, Object value)
|
||||
{
|
||||
Object lo = _map.get(name);
|
||||
Object ln = LazyList.add(lo,value);
|
||||
|
@ -214,7 +185,7 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
* @param name The entry key.
|
||||
* @param values The List of multiple values.
|
||||
*/
|
||||
public void addValues(K name, List<? extends Object> values)
|
||||
public void addValues(String name, List<? extends Object> values)
|
||||
{
|
||||
Object lo = _map.get(name);
|
||||
Object ln = LazyList.addCollection(lo,values);
|
||||
|
@ -229,7 +200,7 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
* @param name The entry key.
|
||||
* @param values The String array of multiple values.
|
||||
*/
|
||||
public void addValues(K name, String[] values)
|
||||
public void addValues(String name, String[] values)
|
||||
{
|
||||
Object lo = _map.get(name);
|
||||
Object ln = LazyList.addCollection(lo,Arrays.asList(values));
|
||||
|
@ -243,7 +214,7 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
* @param value The entry value.
|
||||
* @return true if it was removed.
|
||||
*/
|
||||
public boolean removeValue(K name,Object value)
|
||||
public boolean removeValue(String name,Object value)
|
||||
{
|
||||
Object lo = _map.get(name);
|
||||
Object ln=lo;
|
||||
|
@ -264,13 +235,14 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
/** Put all contents of map.
|
||||
* @param m Map
|
||||
*/
|
||||
public void putAll(Map<? extends K, ? extends Object> m)
|
||||
@Override
|
||||
public void putAll(Map<? extends String, ? extends Object> m)
|
||||
{
|
||||
boolean multi = (m instanceof MultiMap);
|
||||
|
||||
if (multi)
|
||||
{
|
||||
for (Map.Entry<? extends K, ? extends Object> entry : m.entrySet())
|
||||
for (Map.Entry<? extends String, ? extends Object> entry : m.entrySet())
|
||||
{
|
||||
_map.put(entry.getKey(),LazyList.clone(entry.getValue()));
|
||||
}
|
||||
|
@ -285,21 +257,22 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
/**
|
||||
* @return Map of String arrays
|
||||
*/
|
||||
public Map<K,String[]> toStringArrayMap()
|
||||
public Map<String,String[]> toStringArrayMap()
|
||||
{
|
||||
HashMap<K,String[]> map = new HashMap<K,String[]>(_map.size()*3/2)
|
||||
HashMap<String,String[]> map = new HashMap<String,String[]>(_map.size()*3/2)
|
||||
{
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder b=new StringBuilder();
|
||||
b.append('{');
|
||||
for (K k:keySet())
|
||||
for (String k:super.keySet())
|
||||
{
|
||||
if(b.length()>1)
|
||||
b.append(',');
|
||||
b.append(k);
|
||||
b.append('=');
|
||||
b.append(Arrays.asList(get(k)));
|
||||
b.append(Arrays.asList(super.get(k)));
|
||||
}
|
||||
|
||||
b.append('}');
|
||||
|
@ -307,7 +280,7 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
}
|
||||
};
|
||||
|
||||
for(Map.Entry<K,Object> entry: _map.entrySet())
|
||||
for(Map.Entry<String,Object> entry: _map.entrySet())
|
||||
{
|
||||
String[] a = LazyList.toStringArray(entry.getValue());
|
||||
map.put(entry.getKey(),a);
|
||||
|
@ -318,25 +291,29 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _cmap==null?_map.toString():_cmap.toString();
|
||||
return _map.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
_map.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key)
|
||||
{
|
||||
return _map.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value)
|
||||
{
|
||||
return _map.containsValue(value);
|
||||
}
|
||||
|
||||
public Set<Entry<K, Object>> entrySet()
|
||||
@Override
|
||||
public Set<Entry<String, Object>> entrySet()
|
||||
{
|
||||
return _map.entrySet();
|
||||
}
|
||||
|
@ -353,58 +330,33 @@ public class MultiMap<K> implements ConcurrentMap<K,Object>, Serializable
|
|||
return _map.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return _map.isEmpty();
|
||||
}
|
||||
|
||||
public Set<K> keySet()
|
||||
@Override
|
||||
public Set<String> keySet()
|
||||
{
|
||||
return _map.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(Object key)
|
||||
{
|
||||
return _map.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return _map.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> values()
|
||||
{
|
||||
return _map.values();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Object putIfAbsent(K key, Object value)
|
||||
{
|
||||
if (_cmap==null)
|
||||
throw new UnsupportedOperationException();
|
||||
return _cmap.putIfAbsent(key,value);
|
||||
}
|
||||
|
||||
public boolean remove(Object key, Object value)
|
||||
{
|
||||
if (_cmap==null)
|
||||
throw new UnsupportedOperationException();
|
||||
return _cmap.remove(key,value);
|
||||
}
|
||||
|
||||
public boolean replace(K key, Object oldValue, Object newValue)
|
||||
{
|
||||
if (_cmap==null)
|
||||
throw new UnsupportedOperationException();
|
||||
return _cmap.replace(key,oldValue,newValue);
|
||||
}
|
||||
|
||||
public Object replace(K key, Object value)
|
||||
{
|
||||
if (_cmap==null)
|
||||
throw new UnsupportedOperationException();
|
||||
return _cmap.replace(key,value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,8 @@ import java.io.BufferedInputStream;
|
|||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -48,7 +46,7 @@ public class MultiPartInputStream
|
|||
protected InputStream _in;
|
||||
protected MultipartConfigElement _config;
|
||||
protected String _contentType;
|
||||
protected MultiMap<String> _parts;
|
||||
protected MultiMap _parts;
|
||||
protected File _tmpDir;
|
||||
protected File _contextTmpDir;
|
||||
|
||||
|
@ -63,7 +61,7 @@ public class MultiPartInputStream
|
|||
protected OutputStream _out;
|
||||
protected ByteArrayOutputStream2 _bout;
|
||||
protected String _contentType;
|
||||
protected MultiMap<String> _headers;
|
||||
protected MultiMap _headers;
|
||||
protected long _size = 0;
|
||||
|
||||
public MultiPart (String name, String filename)
|
||||
|
@ -149,7 +147,7 @@ public class MultiPartInputStream
|
|||
|
||||
|
||||
|
||||
protected void setHeaders(MultiMap<String> headers)
|
||||
protected void setHeaders(MultiMap headers)
|
||||
{
|
||||
_headers = headers;
|
||||
}
|
||||
|
@ -344,7 +342,7 @@ public class MultiPartInputStream
|
|||
|
||||
//initialize
|
||||
long total = 0; //keep running total of size of bytes read from input and throw an exception if exceeds MultipartConfigElement._maxRequestSize
|
||||
_parts = new MultiMap<String>();
|
||||
_parts = new MultiMap();
|
||||
|
||||
//if its not a multipart request, don't parse it
|
||||
if (_contentType == null || !_contentType.startsWith("multipart/form-data"))
|
||||
|
@ -386,7 +384,7 @@ public class MultiPartInputStream
|
|||
String contentTransferEncoding=null;
|
||||
outer:while(!lastPart)
|
||||
{
|
||||
MultiMap<String> headers = new MultiMap<String>();
|
||||
MultiMap headers = new MultiMap();
|
||||
while(true)
|
||||
{
|
||||
bytes=TypeUtil.readLine(_in);
|
||||
|
|
|
@ -144,7 +144,7 @@ public class Scanner extends AbstractLifeCycle
|
|||
* Get the scan interval
|
||||
* @return interval between scans in seconds
|
||||
*/
|
||||
public int getScanInterval()
|
||||
public synchronized int getScanInterval()
|
||||
{
|
||||
return _scanInterval;
|
||||
}
|
||||
|
|
|
@ -14,10 +14,6 @@
|
|||
package org.eclipse.jetty.util;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.io.InputStreamReader;
|
|||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.util.Utf8Appendable.NotUtf8Exception;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -59,20 +58,19 @@ public class UrlEncoded extends MultiMap implements Cloneable
|
|||
/* ----------------------------------------------------------------- */
|
||||
public UrlEncoded()
|
||||
{
|
||||
super(6);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
public UrlEncoded(String s)
|
||||
{
|
||||
super(6);
|
||||
this();
|
||||
decode(s,ENCODING);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
public UrlEncoded(String s, String charset)
|
||||
{
|
||||
super(6);
|
||||
this();
|
||||
decode(s,charset);
|
||||
}
|
||||
|
||||
|
@ -126,10 +124,10 @@ public class UrlEncoded extends MultiMap implements Cloneable
|
|||
|
||||
StringBuilder result = new StringBuilder(128);
|
||||
|
||||
Iterator iter = map.entrySet().iterator();
|
||||
Iterator<Entry<String, Object>> iter = map.entrySet().iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
Entry<String, Object> entry = iter.next();
|
||||
|
||||
String key = entry.getKey().toString();
|
||||
Object list = entry.getValue();
|
||||
|
@ -275,7 +273,6 @@ public class UrlEncoded extends MultiMap implements Cloneable
|
|||
String key = null;
|
||||
String value = null;
|
||||
|
||||
// TODO cache of parameter names ???
|
||||
int end=offset+length;
|
||||
for (int i=offset;i<end;i++)
|
||||
{
|
||||
|
@ -360,7 +357,6 @@ public class UrlEncoded extends MultiMap implements Cloneable
|
|||
|
||||
int b;
|
||||
|
||||
// TODO cache of parameter names ???
|
||||
int totalLength=0;
|
||||
while ((b=in.read())>=0)
|
||||
{
|
||||
|
@ -445,7 +441,6 @@ public class UrlEncoded extends MultiMap implements Cloneable
|
|||
|
||||
int b;
|
||||
|
||||
// TODO cache of parameter names ???
|
||||
int totalLength=0;
|
||||
while ((b=in.read())>=0)
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ class JarFileResource extends JarResource
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
protected boolean checkConnection()
|
||||
protected synchronized boolean checkConnection()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -159,10 +159,10 @@ class JarFileResource extends JarResource
|
|||
if (jarFile!=null && _entry==null && !_directory)
|
||||
{
|
||||
// OK - we have a JarFile, lets look at the entries for our path
|
||||
Enumeration e=jarFile.entries();
|
||||
Enumeration<JarEntry> e=jarFile.entries();
|
||||
while(e.hasMoreElements())
|
||||
{
|
||||
JarEntry entry = (JarEntry) e.nextElement();
|
||||
JarEntry entry = e.nextElement();
|
||||
String name=entry.getName().replace('\\','/');
|
||||
|
||||
// Do we have a match
|
||||
|
@ -243,7 +243,7 @@ class JarFileResource extends JarResource
|
|||
|
||||
if(isDirectory() && _list==null)
|
||||
{
|
||||
ArrayList list = new ArrayList(32);
|
||||
ArrayList<String> list = new ArrayList<>(32);
|
||||
|
||||
checkConnection();
|
||||
|
||||
|
@ -260,14 +260,15 @@ class JarFileResource extends JarResource
|
|||
{
|
||||
LOG.ignore(e);
|
||||
}
|
||||
if(jarFile==null)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
Enumeration e=jarFile.entries();
|
||||
Enumeration<JarEntry> e=jarFile.entries();
|
||||
String dir=_urlString.substring(_urlString.indexOf("!/")+2);
|
||||
while(e.hasMoreElements())
|
||||
{
|
||||
|
||||
JarEntry entry = (JarEntry) e.nextElement();
|
||||
JarEntry entry = e.nextElement();
|
||||
String name=entry.getName().replace('\\','/');
|
||||
if(!name.startsWith(dir) || name.length()==dir.length())
|
||||
{
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
|
||||
package org.eclipse.jetty.util.security;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @deprecated use {@link org.eclipse.jetty.util.B64Code}
|
||||
*/
|
||||
@Deprecated
|
||||
public class B64Code extends org.eclipse.jetty.util.B64Code
|
||||
{
|
||||
public B64Code()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -14,7 +14,8 @@
|
|||
package org.eclipse.jetty.util;
|
||||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
|
|
|
@ -25,7 +25,7 @@ public class IPAddressMapTest
|
|||
@Test
|
||||
public void testOneAddress()
|
||||
{
|
||||
IPAddressMap<String> map = new IPAddressMap();
|
||||
IPAddressMap<String> map = new IPAddressMap<>();
|
||||
|
||||
map.put("10.5.2.1","1");
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class IPAddressMapTest
|
|||
@Test
|
||||
public void testOneRange()
|
||||
{
|
||||
IPAddressMap<String> map = new IPAddressMap();
|
||||
IPAddressMap<String> map = new IPAddressMap<>();
|
||||
|
||||
map.put("1-15.16-31.32-63.64-127","1");
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class IPAddressMapTest
|
|||
@Test
|
||||
public void testOneMissing()
|
||||
{
|
||||
IPAddressMap<String> map = new IPAddressMap();
|
||||
IPAddressMap<String> map = new IPAddressMap<>();
|
||||
|
||||
map.put("10.5.2.","1");
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class IPAddressMapTest
|
|||
@Test
|
||||
public void testTwoMissing()
|
||||
{
|
||||
IPAddressMap<String> map = new IPAddressMap();
|
||||
IPAddressMap<String> map = new IPAddressMap<>();
|
||||
|
||||
map.put("10.5.","1");
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class IPAddressMapTest
|
|||
@Test
|
||||
public void testThreeMissing()
|
||||
{
|
||||
IPAddressMap<String> map = new IPAddressMap();
|
||||
IPAddressMap<String> map = new IPAddressMap<>();
|
||||
|
||||
map.put("10.","1");
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class IPAddressMapTest
|
|||
@Test
|
||||
public void testOneMixed()
|
||||
{
|
||||
IPAddressMap<String> map = new IPAddressMap();
|
||||
IPAddressMap<String> map = new IPAddressMap<>();
|
||||
|
||||
map.put("0-15,21.10,16-31.0-15,32-63.-95,128-","1");
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class IPAddressMapTest
|
|||
@Test
|
||||
public void testManyMixed()
|
||||
{
|
||||
IPAddressMap<String> map = new IPAddressMap();
|
||||
IPAddressMap<String> map = new IPAddressMap<>();
|
||||
|
||||
map.put("10.5.2.1","1");
|
||||
map.put("1-15.16-31.32-63.64-127","2");
|
||||
|
|
|
@ -28,7 +28,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testPut()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testPut_Null()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testPut_Replace()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
Object ret;
|
||||
|
@ -83,7 +83,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testPutValues_List()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testPutValues_StringArray()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testPutValues_VarArgs()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testAdd()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testAddValues_List()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -183,7 +183,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testAddValues_List_Empty()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -206,7 +206,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testAddValues_StringArray()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -229,7 +229,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testAddValues_StringArray_Empty()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -252,7 +252,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testRemoveValue()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -274,7 +274,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testRemoveValue_InvalidItem()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -295,7 +295,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testRemoveValue_AllItems()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -325,7 +325,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testRemoveValue_FromEmpty()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
String key = "formats";
|
||||
|
||||
|
@ -346,7 +346,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testPutAll_Map()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
assertMapSize(mm,0); // Shouldn't have anything yet.
|
||||
|
||||
|
@ -369,11 +369,11 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testPutAll_MultiMap_Simple()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
assertMapSize(mm,0); // Shouldn't have anything yet.
|
||||
|
||||
MultiMap<String> input = new MultiMap<String>();
|
||||
MultiMap input = new MultiMap();
|
||||
input.put("food","apple");
|
||||
input.put("color","red");
|
||||
input.put("amount","bushel");
|
||||
|
@ -392,11 +392,11 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testPutAll_MultiMapComplex()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
|
||||
assertMapSize(mm,0); // Shouldn't have anything yet.
|
||||
|
||||
MultiMap<String> input = new MultiMap<String>();
|
||||
MultiMap input = new MultiMap();
|
||||
input.putValues("food","apple","cherry","raspberry");
|
||||
input.put("color","red");
|
||||
input.putValues("amount","bushel","pint");
|
||||
|
@ -415,7 +415,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testToStringArrayMap()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
mm.putValues("food","apple","cherry","raspberry");
|
||||
mm.put("color","red");
|
||||
mm.putValues("amount","bushel","pint");
|
||||
|
@ -436,7 +436,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testToString()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
mm.put("color","red");
|
||||
|
||||
Assert.assertEquals("{color=red}", mm.toString());
|
||||
|
@ -452,7 +452,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testClear()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
mm.putValues("food","apple","cherry","raspberry");
|
||||
mm.put("color","red");
|
||||
mm.putValues("amount","bushel","pint");
|
||||
|
@ -470,7 +470,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testContainsKey()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
mm.putValues("food","apple","cherry","raspberry");
|
||||
mm.put("color","red");
|
||||
mm.putValues("amount","bushel","pint");
|
||||
|
@ -485,7 +485,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testContainsValue()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
mm.putValues("food","apple","cherry","raspberry");
|
||||
mm.put("color","red");
|
||||
mm.putValues("amount","bushel","pint");
|
||||
|
@ -500,7 +500,7 @@ public class MultiMapTest
|
|||
@Test
|
||||
public void testContainsValue_LazyList()
|
||||
{
|
||||
MultiMap<String> mm = new MultiMap<String>();
|
||||
MultiMap mm = new MultiMap();
|
||||
mm.putValues("food","apple","cherry","raspberry");
|
||||
mm.put("color","red");
|
||||
mm.putValues("amount","bushel","pint");
|
||||
|
@ -521,9 +521,9 @@ public class MultiMapTest
|
|||
}
|
||||
}
|
||||
|
||||
private void assertValues(MultiMap<String> mm, String key, Object... expectedValues)
|
||||
private void assertValues(MultiMap mm, String key, Object... expectedValues)
|
||||
{
|
||||
List<Object> values = mm.getValues(key);
|
||||
List<String> values = mm.getValues(key);
|
||||
|
||||
String prefix = "MultiMap.getValues(" + key + ")";
|
||||
|
||||
|
@ -536,16 +536,16 @@ public class MultiMapTest
|
|||
}
|
||||
}
|
||||
|
||||
private void assertEmptyValues(MultiMap<String> mm, String key)
|
||||
private void assertEmptyValues(MultiMap mm, String key)
|
||||
{
|
||||
List<Object> values = mm.getValues(key);
|
||||
List<String> values = mm.getValues(key);
|
||||
|
||||
String prefix = "MultiMap.getValues(" + key + ")";
|
||||
|
||||
Assert.assertEquals(prefix + ".size",0,LazyList.size(values));
|
||||
}
|
||||
|
||||
private void assertMapSize(MultiMap<String> mm, int expectedSize)
|
||||
private void assertMapSize(MultiMap mm, int expectedSize)
|
||||
{
|
||||
Assert.assertEquals("MultiMap.size",expectedSize,mm.size());
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.junit.Test;
|
|||
*/
|
||||
public class TestIntrospectionUtil
|
||||
{
|
||||
public final static Class[] __INTEGER_ARG = new Class[] {Integer.class};
|
||||
public final static Class<?>[] __INTEGER_ARG = new Class[] {Integer.class};
|
||||
static Field privateAField;
|
||||
static Field protectedAField;
|
||||
static Field publicAField;
|
||||
|
|
|
@ -17,7 +17,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -43,7 +42,7 @@ public class URLEncodedTest
|
|||
|
||||
/* -------------------------------------------------------------- */
|
||||
@Test
|
||||
public void testUrlEncoded() throws UnsupportedEncodingException
|
||||
public void testUrlEncoded()
|
||||
{
|
||||
|
||||
UrlEncoded url_encoded = new UrlEncoded();
|
||||
|
@ -150,7 +149,7 @@ public class URLEncodedTest
|
|||
|
||||
/* -------------------------------------------------------------- */
|
||||
@Test
|
||||
public void testBadEncoding() throws UnsupportedEncodingException
|
||||
public void testBadEncoding()
|
||||
{
|
||||
UrlEncoded url_encoded = new UrlEncoded();
|
||||
url_encoded.decode("Name15=xx%zz", "UTF-8");
|
||||
|
@ -242,7 +241,7 @@ public class URLEncodedTest
|
|||
{
|
||||
String query="name=X%c0%afZ";
|
||||
|
||||
MultiMap<String> map = new MultiMap<String>();
|
||||
MultiMap map = new MultiMap();
|
||||
UrlEncoded.LOG.info("EXPECT 4 Not Valid UTF8 warnings...");
|
||||
UrlEncoded.decodeUtf8To(query.getBytes(StringUtil.__ISO_8859_1),0,query.length(),map);
|
||||
assertEquals("X"+Utf8Appendable.REPLACEMENT+Utf8Appendable.REPLACEMENT+"Z",map.getValue("name",0));
|
||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.jetty.util.component;
|
|||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
|
|
@ -24,12 +24,9 @@ import java.io.FilenameFilter;
|
|||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.sql.Time;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
@ -243,7 +240,7 @@ public class ResourceTest
|
|||
String s = "jar:"+__userURL+"TestData/test.zip!/subdir/";
|
||||
Resource r = Resource.newResource(s);
|
||||
|
||||
Set entries = new HashSet(Arrays.asList(r.list()));
|
||||
Set<String> entries = new HashSet<>(Arrays.asList(r.list()));
|
||||
assertEquals(3,entries.size());
|
||||
assertTrue(entries.contains("alphabet"));
|
||||
assertTrue(entries.contains("numbers"));
|
||||
|
@ -259,7 +256,7 @@ public class ResourceTest
|
|||
|
||||
Resource e = Resource.newResource(extract.getAbsolutePath());
|
||||
|
||||
entries = new HashSet(Arrays.asList(e.list()));
|
||||
entries = new HashSet<>(Arrays.asList(e.list()));
|
||||
assertEquals(3,entries.size());
|
||||
assertTrue(entries.contains("alphabet"));
|
||||
assertTrue(entries.contains("numbers"));
|
||||
|
@ -269,7 +266,7 @@ public class ResourceTest
|
|||
s = "jar:"+__userURL+"TestData/test.zip!/subdir/subsubdir/";
|
||||
r = Resource.newResource(s);
|
||||
|
||||
entries = new HashSet(Arrays.asList(r.list()));
|
||||
entries = new HashSet<>(Arrays.asList(r.list()));
|
||||
assertEquals(2,entries.size());
|
||||
assertTrue(entries.contains("alphabet"));
|
||||
assertTrue(entries.contains("numbers"));
|
||||
|
@ -284,7 +281,7 @@ public class ResourceTest
|
|||
|
||||
e = Resource.newResource(extract.getAbsolutePath());
|
||||
|
||||
entries = new HashSet(Arrays.asList(e.list()));
|
||||
entries = new HashSet<>(Arrays.asList(e.list()));
|
||||
assertEquals(2,entries.size());
|
||||
assertTrue(entries.contains("alphabet"));
|
||||
assertTrue(entries.contains("numbers"));
|
||||
|
@ -317,14 +314,12 @@ public class ResourceTest
|
|||
throws Exception
|
||||
{
|
||||
String s = "jar:"+__userURL+"TestData/test.zip!/subdir/numbers";
|
||||
|
||||
// TODO move this into src/test/resources!!!
|
||||
ZipFile zf = new ZipFile(MavenTestingUtils.getProjectFile("src/test/resources/org/eclipse/jetty/util/resource/TestData/test.zip"));
|
||||
|
||||
long last = zf.getEntry("subdir/numbers").getTime();
|
||||
|
||||
Resource r = Resource.newResource(s);
|
||||
assertEquals(last,r.lastModified()); // Known date value inside zip
|
||||
assertEquals(last,r.lastModified());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.jetty.util.statistic;
|
|||
//========================================================================
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -56,8 +56,8 @@ public class QueuedThreadPoolTest
|
|||
|
||||
public void stop() throws InterruptedException
|
||||
{
|
||||
_run.await(10,TimeUnit.SECONDS);
|
||||
_stopping.countDown();
|
||||
if (_run.await(10,TimeUnit.SECONDS))
|
||||
_stopping.countDown();
|
||||
if (!_stopped.await(10,TimeUnit.SECONDS))
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -226,6 +226,7 @@ public class QueuedThreadPoolTest
|
|||
}
|
||||
catch(InterruptedException e)
|
||||
{}
|
||||
now=System.currentTimeMillis();
|
||||
}
|
||||
Assert.assertEquals(idle,tp.getIdleThreads());
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class TimeoutTest
|
|||
timeout.setNow(1700);
|
||||
|
||||
for (int i=0;i<tasks.length;i++)
|
||||
if (i%2==1)
|
||||
if ((i+1)%2==0)
|
||||
tasks[i].cancel();
|
||||
|
||||
timeout.tick();
|
||||
|
|
Loading…
Reference in New Issue