Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-9.4.x-issue-2560-pathresource-exceptions
This commit is contained in:
commit
c36390967f
|
@ -90,7 +90,7 @@ def getFullBuild(jdk, os) {
|
|||
publisherStrategy: 'EXPLICIT',
|
||||
globalMavenSettingsConfig: settingsName,
|
||||
mavenLocalRepo: localRepo) {
|
||||
sh "mvn -V -B install -Dmaven.test.failure.ignore=true -Prun-its -e -Pmongodb -T3"
|
||||
sh "mvn -V -B install -Dmaven.test.failure.ignore=true -e -Pmongodb -T3"
|
||||
}
|
||||
// withMaven doesn't label..
|
||||
// Report failures in the jenkins UI
|
||||
|
|
|
@ -150,7 +150,10 @@ public abstract class SslBytesTest
|
|||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
x.printStackTrace();
|
||||
logger.info(x.getClass() + ": " + x.getMessage());
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -351,8 +351,7 @@ public class MimeTypes
|
|||
|
||||
if (type==null)
|
||||
{
|
||||
if (type==null)
|
||||
type=__dftMimeMap.get("*");
|
||||
type=__dftMimeMap.get("*");
|
||||
}
|
||||
|
||||
return type;
|
||||
|
|
|
@ -19,11 +19,15 @@
|
|||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.eclipse.jetty.http.HttpComplianceSection.NO_FIELD_FOLDING;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.http.HttpParser.State;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
@ -33,8 +37,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
|
||||
public class HttpParserTest
|
||||
{
|
||||
static
|
||||
|
@ -359,6 +361,62 @@ public class HttpParserTest
|
|||
Assert.assertThat(_bad, Matchers.containsString("Illegal character"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWhiteSpaceBeforeRequest()
|
||||
{
|
||||
HttpCompliance[] compliances = new HttpCompliance[]
|
||||
{
|
||||
HttpCompliance.RFC7230, HttpCompliance.RFC2616
|
||||
};
|
||||
|
||||
String whitespaces[][] = new String[][]
|
||||
{
|
||||
{ " ", "Illegal character SPACE" },
|
||||
{ "\t", "Illegal character HTAB" },
|
||||
{ "\n", null },
|
||||
{ "\r", "Bad EOL" },
|
||||
{ "\r\n", null },
|
||||
{ "\r\n\r\n", null },
|
||||
{ "\r\n \r\n", "Illegal character SPACE" },
|
||||
{ "\r\n\t\r\n", "Illegal character HTAB" },
|
||||
{ "\r\t\n", "Bad EOL" },
|
||||
{ "\r\r\n", "Bad EOL" },
|
||||
{ "\t\r\t\r\n", "Illegal character HTAB" },
|
||||
{ " \t \r \t \n\n", "Illegal character SPACE" },
|
||||
{ " \r \t \r\n\r\n\r\n", "Illegal character SPACE" }
|
||||
};
|
||||
|
||||
|
||||
for (int i = 0; i < compliances.length; i++)
|
||||
{
|
||||
HttpCompliance compliance = compliances[i];
|
||||
|
||||
for (int j = 0; j < whitespaces.length; j++)
|
||||
{
|
||||
String request =
|
||||
whitespaces[j][0] +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"Name: value" + j + "\r\n" +
|
||||
"Connection: close\r\n" +
|
||||
"\r\n";
|
||||
|
||||
ByteBuffer buffer = BufferUtil.toBuffer(request);
|
||||
HttpParser.RequestHandler handler = new Handler();
|
||||
HttpParser parser = new HttpParser(handler, 4096, compliance);
|
||||
_bad = null;
|
||||
parseAll(parser, buffer);
|
||||
|
||||
String test = "whitespace.[" + compliance + "].[" + j + "]";
|
||||
String expected = whitespaces[j][1];
|
||||
if (expected==null)
|
||||
Assert.assertNull(test, _bad);
|
||||
else
|
||||
Assert.assertThat(test, _bad, Matchers.containsString(expected));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoValue() throws Exception
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.http2.hpack;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
@ -254,6 +255,7 @@ public class HpackContext
|
|||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(String.format("HdrTbl[%x] !added size %d>%d",hashCode(),size,_maxDynamicTableSizeInBytes));
|
||||
_dynamicTable.evictAll();
|
||||
return null;
|
||||
}
|
||||
_dynamicTableSizeInBytes+=size;
|
||||
|
@ -391,6 +393,17 @@ public class HpackContext
|
|||
LOG.debug(String.format("HdrTbl[%x] entries=%d, size=%d, max=%d",HpackContext.this.hashCode(),_dynamicTable.size(),_dynamicTableSizeInBytes,_maxDynamicTableSizeInBytes));
|
||||
}
|
||||
|
||||
private void evictAll()
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(String.format("HdrTbl[%x] evictAll",HpackContext.this.hashCode()));
|
||||
_fieldMap.clear();
|
||||
_nameMap.clear();
|
||||
_offset = 0;
|
||||
_size = 0;
|
||||
_dynamicTableSizeInBytes = 0;
|
||||
Arrays.fill(_entries,null);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Entry
|
||||
|
|
|
@ -242,14 +242,9 @@ public class HpackDecoder
|
|||
// emit the field
|
||||
_builder.emit(field);
|
||||
|
||||
// if indexed
|
||||
// if indexed add to dynamic table
|
||||
if (indexed)
|
||||
{
|
||||
// add to dynamic table
|
||||
if (_context.add(field)==null)
|
||||
throw new BadMessageException(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431,"Indexed field value too large");
|
||||
}
|
||||
|
||||
_context.add(field);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -329,11 +329,9 @@ public class HpackEncoder
|
|||
}
|
||||
}
|
||||
|
||||
// If we want the field referenced, then we add it to our
|
||||
// table and reference set.
|
||||
// If we want the field referenced, then we add it to our table and reference set.
|
||||
if (indexed)
|
||||
if (_context.add(field)==null)
|
||||
throw new IllegalStateException();
|
||||
_context.add(field);
|
||||
}
|
||||
|
||||
if (_debug)
|
||||
|
|
|
@ -166,6 +166,11 @@ public class MetaDataBuilder
|
|||
return new MetaData.Request(_method,_scheme,_authority,_path,HttpVersion.HTTP_2,fields,_contentLength);
|
||||
if (_status!=0)
|
||||
return new MetaData.Response(HttpVersion.HTTP_2,_status,fields,_contentLength);
|
||||
if (_path!=null)
|
||||
fields.put(HttpHeader.C_PATH,_path);
|
||||
if (_authority!=null)
|
||||
fields.put(HttpHeader.HOST,_authority.getValue());
|
||||
|
||||
return new MetaData(HttpVersion.HTTP_2,fields,_contentLength);
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -191,6 +191,18 @@ public class HpackDecoderTest
|
|||
assertTrue(response.getFields().contains(new HttpField(HttpHeader.VIA,"1.1 nghttpx")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResize() throws Exception
|
||||
{
|
||||
String encoded = "3f6166871e33A13a47497f205f8841E92b043d492d49";
|
||||
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
|
||||
HpackDecoder decoder = new HpackDecoder(4096, 8192);
|
||||
MetaData metaData = decoder.decode(buffer);
|
||||
assertThat(metaData.getFields().get(HttpHeader.HOST),is("aHostName"));
|
||||
assertThat(metaData.getFields().get(HttpHeader.CONTENT_TYPE),is("some/content"));
|
||||
assertThat(decoder.getHpackContext().getDynamicTableSize(),is(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTooBigToIndex()
|
||||
{
|
||||
|
@ -198,16 +210,10 @@ public class HpackDecoderTest
|
|||
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
|
||||
|
||||
HpackDecoder decoder = new HpackDecoder(128,8192);
|
||||
try
|
||||
{
|
||||
decoder.decode(buffer);
|
||||
Assert.fail();
|
||||
}
|
||||
catch (BadMessageException e)
|
||||
{
|
||||
assertThat(e.getCode(),equalTo(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431));
|
||||
assertThat(e.getReason(),Matchers.startsWith("Indexed field value too large"));
|
||||
}
|
||||
MetaData metaData = decoder.decode(buffer);
|
||||
|
||||
assertThat(decoder.getHpackContext().getDynamicTableSize(),is(0));
|
||||
assertThat(metaData.getFields().get(HttpHeader.C_PATH),Matchers.startsWith("This is a very large field"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -27,10 +27,10 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -249,7 +249,4 @@ public class HpackEncoderTest
|
|||
context.get(HpackContext.STATIC_SIZE+1).getSize()+context.get(HpackContext.STATIC_SIZE+2).getSize()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -835,7 +835,10 @@ public class SocketChannelEndPointTest
|
|||
}
|
||||
catch (InterruptedException | EofException e)
|
||||
{
|
||||
LOG.info(e);
|
||||
if(LOG.isDebugEnabled())
|
||||
LOG.debug(e);
|
||||
else
|
||||
LOG.info(e.getClass().getName());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -42,6 +42,39 @@
|
|||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-invoker-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<debug>${it.debug}</debug>
|
||||
<addTestClassPath>true</addTestClassPath>
|
||||
<timeoutInSeconds>60</timeoutInSeconds>
|
||||
<projectsDirectory>src/it</projectsDirectory>
|
||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||
<pomIncludes>
|
||||
<pomInclude>*/pom.xml</pomInclude>
|
||||
</pomIncludes>
|
||||
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||
<settingsFile>src/it/settings.xml</settingsFile>
|
||||
<scriptVariables>
|
||||
<surefireVersion>${surefireVersion}</surefireVersion>
|
||||
</scriptVariables>
|
||||
<skipInvocation>${skipTests}</skipInvocation>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
@ -107,45 +140,4 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>run-its</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-invoker-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<debug>${it.debug}</debug>
|
||||
<addTestClassPath>true</addTestClassPath>
|
||||
<timeoutInSeconds>60</timeoutInSeconds>
|
||||
<projectsDirectory>src/it</projectsDirectory>
|
||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||
<pomIncludes>
|
||||
<pomInclude>*/pom.xml</pomInclude>
|
||||
</pomIncludes>
|
||||
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||
<settingsFile>src/it/settings.xml</settingsFile>
|
||||
<scriptVariables>
|
||||
<surefireVersion>${surefireVersion}</surefireVersion>
|
||||
</scriptVariables>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -36,6 +36,61 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-invoker-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<debug>${it.debug}</debug>
|
||||
<addTestClassPath>true</addTestClassPath>
|
||||
<projectsDirectory>src/it</projectsDirectory>
|
||||
<timeoutInSeconds>60</timeoutInSeconds>
|
||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||
<pomIncludes>
|
||||
<pomInclude>*/pom.xml</pomInclude>
|
||||
</pomIncludes>
|
||||
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||
<settingsFile>src/it/settings.xml</settingsFile>
|
||||
<scriptVariables>
|
||||
<jettyStopKey>${jetty.stopKey}</jettyStopKey>
|
||||
<jettyStopPort>${jetty.stopPort}</jettyStopPort>
|
||||
<jettyRunPort>${jetty.runPort}</jettyRunPort>
|
||||
<surefireVersion>${surefireVersion}</surefireVersion>
|
||||
</scriptVariables>
|
||||
<skipInvocation>${skipTests}</skipInvocation>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>reserve-ports</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>reserve-network-port</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<portNames>
|
||||
<portName>jetty.stopPort</portName>
|
||||
<portName>jetty.runPort</portName>
|
||||
</portNames>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
|
@ -179,68 +234,4 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>run-its</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-invoker-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<debug>${it.debug}</debug>
|
||||
<addTestClassPath>true</addTestClassPath>
|
||||
<projectsDirectory>src/it</projectsDirectory>
|
||||
<timeoutInSeconds>60</timeoutInSeconds>
|
||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||
<pomIncludes>
|
||||
<pomInclude>*/pom.xml</pomInclude>
|
||||
</pomIncludes>
|
||||
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||
<settingsFile>src/it/settings.xml</settingsFile>
|
||||
<scriptVariables>
|
||||
<jettyStopKey>${jetty.stopKey}</jettyStopKey>
|
||||
<jettyStopPort>${jetty.stopPort}</jettyStopPort>
|
||||
<jettyRunPort>${jetty.runPort}</jettyRunPort>
|
||||
<surefireVersion>${surefireVersion}</surefireVersion>
|
||||
</scriptVariables>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>reserve-ports</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>reserve-network-port</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<portNames>
|
||||
<portName>jetty.stopPort</portName>
|
||||
<portName>jetty.runPort</portName>
|
||||
</portNames>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -590,25 +590,5 @@
|
|||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jdk11</id>
|
||||
<activation>
|
||||
<jdk>11</jdk>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>${skipTests}</skipTests>
|
||||
<excludes>
|
||||
<exclude>**/**/TestJettyOSGiBoot**</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.servlet;
|
|||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -695,7 +696,8 @@ public class AsyncServletIOTest
|
|||
LOG.debug("last: "+last);
|
||||
|
||||
// last non empty line should not contain end chunk
|
||||
assertThat(last,not(containsString("0")));
|
||||
assertThat(last, notNullValue());
|
||||
assertThat(last.trim(),not(startsWith("0")));
|
||||
}
|
||||
|
||||
assertTrue(_servlet4.completed.await(5, TimeUnit.SECONDS));
|
||||
|
|
|
@ -26,32 +26,48 @@ import java.util.List;
|
|||
* Wraps multiple exceptions.
|
||||
*
|
||||
* Allows multiple exceptions to be thrown as a single exception.
|
||||
*
|
||||
* The MultiException itself should not be thrown instead one of the
|
||||
* ifExceptionThrow* methods should be called instead.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MultiException extends Exception
|
||||
{
|
||||
private static final String DEFAULT_MESSAGE = "Multiple exceptions";
|
||||
|
||||
private List<Throwable> nested;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public MultiException()
|
||||
{
|
||||
super("Multiple exceptions");
|
||||
// Avoid filling in stack trace information.
|
||||
super(DEFAULT_MESSAGE, null, false, false);
|
||||
this.nested = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MultiException which may be thrown.
|
||||
*
|
||||
* @param nested The nested exceptions which will be suppressed by this
|
||||
* exception.
|
||||
*/
|
||||
private MultiException(List<Throwable> nested) {
|
||||
super(DEFAULT_MESSAGE);
|
||||
this.nested = new ArrayList<>(nested);
|
||||
|
||||
if(nested.size() > 0) {
|
||||
initCause(nested.get(0));
|
||||
}
|
||||
|
||||
for(Throwable t : nested) {
|
||||
this.addSuppressed(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void add(Throwable e)
|
||||
{
|
||||
if (e==null)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
if(nested == null)
|
||||
{
|
||||
initCause(e);
|
||||
nested = new ArrayList<>();
|
||||
}
|
||||
else
|
||||
addSuppressed(e);
|
||||
|
||||
if (e instanceof MultiException)
|
||||
{
|
||||
MultiException me = (MultiException)e;
|
||||
|
@ -105,7 +121,7 @@ public class MultiException extends Exception
|
|||
if (th instanceof Exception)
|
||||
throw (Exception)th;
|
||||
default:
|
||||
throw this;
|
||||
throw new MultiException(nested);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +153,7 @@ public class MultiException extends Exception
|
|||
else
|
||||
throw new RuntimeException(th);
|
||||
default:
|
||||
throw new RuntimeException(this);
|
||||
throw new RuntimeException(new MultiException(nested));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +171,9 @@ public class MultiException extends Exception
|
|||
return;
|
||||
|
||||
if (nested.size()>0)
|
||||
throw this;
|
||||
{
|
||||
throw new MultiException(nested);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -21,10 +21,11 @@ package org.eclipse.jetty.util;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class MultiExceptionTest
|
||||
{
|
||||
|
@ -37,6 +38,8 @@ public class MultiExceptionTest
|
|||
me.ifExceptionThrow();
|
||||
me.ifExceptionThrowMulti();
|
||||
me.ifExceptionThrowRuntime();
|
||||
|
||||
assertEquals("Stack trace should not be filled out", 0, me.getStackTrace().length);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -65,7 +68,7 @@ public class MultiExceptionTest
|
|||
}
|
||||
catch(MultiException e)
|
||||
{
|
||||
assertTrue(e==me);
|
||||
assertTrue(e instanceof MultiException);
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -91,19 +94,26 @@ public class MultiExceptionTest
|
|||
{
|
||||
assertTrue(run==e);
|
||||
}
|
||||
|
||||
assertEquals("Stack trace should not be filled out", 0, me.getStackTrace().length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwo() throws Exception
|
||||
{
|
||||
private MultiException multiExceptionWithTwo() {
|
||||
MultiException me = new MultiException();
|
||||
IOException io = new IOException("one");
|
||||
RuntimeException run = new RuntimeException("one");
|
||||
me.add(io);
|
||||
me.add(run);
|
||||
|
||||
assertEquals(2,me.size());
|
||||
|
||||
assertEquals("Stack trace should not be filled out", 0, me.getStackTrace().length);
|
||||
return me;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwo() throws Exception
|
||||
{
|
||||
MultiException me = multiExceptionWithTwo();
|
||||
try
|
||||
{
|
||||
me.ifExceptionThrow();
|
||||
|
@ -111,9 +121,11 @@ public class MultiExceptionTest
|
|||
}
|
||||
catch(MultiException e)
|
||||
{
|
||||
assertTrue(e==me);
|
||||
assertTrue(e instanceof MultiException);
|
||||
assertTrue(e.getStackTrace().length > 0);
|
||||
}
|
||||
|
||||
me = multiExceptionWithTwo();
|
||||
try
|
||||
{
|
||||
me.ifExceptionThrowMulti();
|
||||
|
@ -121,9 +133,11 @@ public class MultiExceptionTest
|
|||
}
|
||||
catch(MultiException e)
|
||||
{
|
||||
assertTrue(e==me);
|
||||
assertTrue(e instanceof MultiException);
|
||||
assertTrue(e.getStackTrace().length > 0);
|
||||
}
|
||||
|
||||
me = multiExceptionWithTwo();
|
||||
try
|
||||
{
|
||||
me.ifExceptionThrowRuntime();
|
||||
|
@ -131,9 +145,11 @@ public class MultiExceptionTest
|
|||
}
|
||||
catch(RuntimeException e)
|
||||
{
|
||||
assertTrue(e.getCause()==me);
|
||||
assertTrue(e.getCause() instanceof MultiException);
|
||||
assertTrue(e.getStackTrace().length > 0);
|
||||
}
|
||||
|
||||
RuntimeException run = new RuntimeException("one");
|
||||
me = new MultiException();
|
||||
me.add(run);
|
||||
me.add(run);
|
||||
|
@ -145,7 +161,9 @@ public class MultiExceptionTest
|
|||
}
|
||||
catch(RuntimeException e)
|
||||
{
|
||||
assertTrue(e.getCause()==me);
|
||||
assertTrue(e.getCause() instanceof MultiException);
|
||||
Assert.assertEquals(e.getCause().getCause(), run);
|
||||
assertTrue(e.getStackTrace().length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +176,13 @@ public class MultiExceptionTest
|
|||
me.add(io);
|
||||
me.add(run);
|
||||
|
||||
assertEquals(2,me.size());
|
||||
assertEquals(io,me.getCause());
|
||||
|
||||
try {
|
||||
me.ifExceptionThrow();
|
||||
} catch (MultiException e) {
|
||||
assertEquals(io,e.getCause());
|
||||
assertEquals(2,e.size());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,14 +18,9 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.misbehaving;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.websocket.ContainerProvider;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
|
||||
|
@ -37,15 +32,15 @@ import org.eclipse.jetty.websocket.common.WebSocketSession;
|
|||
import org.eclipse.jetty.websocket.jsr356.EchoHandler;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class MisbehavingClassTest
|
||||
{
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
private static Server server;
|
||||
private static EchoHandler handler;
|
||||
private static URI serverUri;
|
||||
|
@ -100,20 +95,21 @@ public class MisbehavingClassTest
|
|||
|
||||
try (StacklessLogging logging = new StacklessLogging(EndpointRuntimeOnOpen.class, WebSocketSession.class))
|
||||
{
|
||||
// expecting IOException during onOpen
|
||||
expectedException.expect(IOException.class);
|
||||
expectedException.expectCause(instanceOf(RuntimeException.class));
|
||||
container.connectToServer(socket, serverUri);
|
||||
expectedException.reportMissingExceptionWithMessage("Should have failed .connectToServer()");
|
||||
try
|
||||
{
|
||||
container.connectToServer(socket, serverUri);
|
||||
fail("Should have failed .connectToServer()");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
assertThat(e.getCause(), instanceOf(RuntimeException.class));
|
||||
}
|
||||
|
||||
assertThat("Close should have occurred",socket.closeLatch.await(1,TimeUnit.SECONDS),is(true));
|
||||
|
||||
Throwable cause = socket.errors.pop();
|
||||
assertThat("Error",cause,instanceOf(RuntimeException.class));
|
||||
assertThat("Close should have occurred", socket.closeLatch.await(10,TimeUnit.SECONDS), is(true));
|
||||
assertThat("Error", socket.errors.pop(), instanceOf(RuntimeException.class));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
@Test
|
||||
public void testAnnotatedRuntimeOnOpen() throws Exception
|
||||
{
|
||||
|
@ -123,16 +119,18 @@ public class MisbehavingClassTest
|
|||
|
||||
try (StacklessLogging logging = new StacklessLogging(AnnotatedRuntimeOnOpen.class, WebSocketSession.class))
|
||||
{
|
||||
// expecting IOException during onOpen
|
||||
expectedException.expect(IOException.class);
|
||||
expectedException.expectCause(instanceOf(RuntimeException.class));
|
||||
container.connectToServer(socket, serverUri);
|
||||
expectedException.reportMissingExceptionWithMessage("Should have failed .connectToServer()");
|
||||
try
|
||||
{
|
||||
container.connectToServer(socket, serverUri);
|
||||
fail("Should have failed .connectToServer()");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
assertThat(e.getCause(), instanceOf(RuntimeException.class));
|
||||
}
|
||||
|
||||
assertThat("Close should have occurred",socket.closeLatch.await(1,TimeUnit.SECONDS),is(true));
|
||||
|
||||
Throwable cause = socket.errors.pop();
|
||||
assertThat("Error",cause,instanceOf(ArrayIndexOutOfBoundsException.class));
|
||||
assertThat("Close should have occurred", socket.closeLatch.await(10,TimeUnit.SECONDS), is(true));
|
||||
assertThat("Error",socket.errors.pop(), instanceOf(RuntimeException.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,11 @@ public abstract class TrackingSocket
|
|||
|
||||
protected void addError(Throwable t)
|
||||
{
|
||||
LOG.warn(t);
|
||||
LOG.warn(t.getClass() + ": " + t.getMessage());
|
||||
|
||||
if(LOG.isDebugEnabled())
|
||||
LOG.debug(t);
|
||||
|
||||
errorQueue.offer(t);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ public class ByteAccumulator
|
|||
{
|
||||
if (this.length + length > maxSize)
|
||||
{
|
||||
throw new MessageTooLargeException("Frame is too large");
|
||||
String err = String.format("Resulting message size [%,d] is too large for configured max of [%,d]", this.length + length, maxSize);
|
||||
throw new MessageTooLargeException(err);
|
||||
}
|
||||
|
||||
byte copy[] = new byte[length - offset];
|
||||
|
|
|
@ -149,7 +149,7 @@ public abstract class CompressExtension extends AbstractExtension
|
|||
|
||||
protected ByteAccumulator newByteAccumulator()
|
||||
{
|
||||
int maxSize = Math.max(getPolicy().getMaxTextMessageSize(),getPolicy().getMaxBinaryMessageBufferSize());
|
||||
int maxSize = Math.max(getPolicy().getMaxTextMessageSize(),getPolicy().getMaxBinaryMessageSize());
|
||||
return new ByteAccumulator(maxSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2018 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.websocket.common.extensions.compress;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.api.MessageTooLargeException;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class ByteAccumulatorTest
|
||||
{
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testCopyNormal()
|
||||
{
|
||||
ByteAccumulator accumulator = new ByteAccumulator(10_000);
|
||||
|
||||
byte hello[] = "Hello".getBytes(UTF_8);
|
||||
byte space[] = " ".getBytes(UTF_8);
|
||||
byte world[] = "World".getBytes(UTF_8);
|
||||
|
||||
accumulator.copyChunk(hello, 0, hello.length);
|
||||
accumulator.copyChunk(space, 0, space.length);
|
||||
accumulator.copyChunk(world, 0, world.length);
|
||||
|
||||
assertThat("Length", accumulator.getLength(), is(hello.length + space.length + world.length));
|
||||
|
||||
ByteBuffer out = ByteBuffer.allocate(200);
|
||||
accumulator.transferTo(out);
|
||||
String result = BufferUtil.toUTF8String(out);
|
||||
assertThat("ByteBuffer to UTF8", result, is("Hello World"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferTo_NotEnoughSpace()
|
||||
{
|
||||
ByteAccumulator accumulator = new ByteAccumulator(10_000);
|
||||
|
||||
byte hello[] = "Hello".getBytes(UTF_8);
|
||||
byte space[] = " ".getBytes(UTF_8);
|
||||
byte world[] = "World".getBytes(UTF_8);
|
||||
|
||||
accumulator.copyChunk(hello, 0, hello.length);
|
||||
accumulator.copyChunk(space, 0, space.length);
|
||||
accumulator.copyChunk(world, 0, world.length);
|
||||
|
||||
int length = hello.length + space.length + world.length;
|
||||
assertThat("Length", accumulator.getLength(), is(length));
|
||||
|
||||
ByteBuffer out = ByteBuffer.allocate(length - 2); // intentionally too small ByteBuffer
|
||||
expectedException.expect(IllegalArgumentException.class);
|
||||
expectedException.expectMessage(containsString("Not enough space in ByteBuffer"));
|
||||
accumulator.transferTo(out);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyChunk_NotEnoughSpace()
|
||||
{
|
||||
|
||||
byte hello[] = "Hello".getBytes(UTF_8);
|
||||
byte space[] = " ".getBytes(UTF_8);
|
||||
byte world[] = "World".getBytes(UTF_8);
|
||||
|
||||
int length = hello.length + space.length + world.length;
|
||||
ByteAccumulator accumulator = new ByteAccumulator(length - 2); // intentionally too small of a max
|
||||
|
||||
accumulator.copyChunk(hello, 0, hello.length);
|
||||
accumulator.copyChunk(space, 0, space.length);
|
||||
|
||||
expectedException.expect(MessageTooLargeException.class);
|
||||
expectedException.expectMessage(containsString("too large for configured max"));
|
||||
accumulator.copyChunk(world, 0, world.length);
|
||||
}
|
||||
}
|
|
@ -18,10 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.server;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
|
@ -49,10 +45,15 @@ import org.eclipse.jetty.websocket.common.test.Timeouts;
|
|||
import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class WebSocketUpgradeFilterTest
|
||||
{
|
||||
|
@ -344,6 +345,7 @@ public class WebSocketUpgradeFilterTest
|
|||
}
|
||||
}
|
||||
|
||||
@Ignore("Issue #2605")
|
||||
@Test
|
||||
public void testStopStartOfHandler() throws Exception
|
||||
{
|
||||
|
|
|
@ -92,8 +92,8 @@ public class MisbehavingClassTest
|
|||
|
||||
Future<BlockheadConnection> connFut = request.sendAsync();
|
||||
|
||||
try (BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT);
|
||||
StacklessLogging ignore = new StacklessLogging(ListenerRuntimeOnConnectSocket.class, WebSocketSession.class))
|
||||
try (StacklessLogging ignore = new StacklessLogging(ListenerRuntimeOnConnectSocket.class, WebSocketSession.class);
|
||||
BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT))
|
||||
{
|
||||
LinkedBlockingQueue<WebSocketFrame> frames = clientConn.getFrameQueue();
|
||||
WebSocketFrame frame = frames.poll(Timeouts.POLL_EVENT, Timeouts.POLL_EVENT_UNIT);
|
||||
|
@ -126,8 +126,8 @@ public class MisbehavingClassTest
|
|||
|
||||
Future<BlockheadConnection> connFut = request.sendAsync();
|
||||
|
||||
try (BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT);
|
||||
StacklessLogging scope = new StacklessLogging(AnnotatedRuntimeOnConnectSocket.class, WebSocketSession.class))
|
||||
try (StacklessLogging scope = new StacklessLogging(AnnotatedRuntimeOnConnectSocket.class, WebSocketSession.class);
|
||||
BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT))
|
||||
{
|
||||
LinkedBlockingQueue<WebSocketFrame> frames = clientConn.getFrameQueue();
|
||||
WebSocketFrame frame = frames.poll(Timeouts.POLL_EVENT, Timeouts.POLL_EVENT_UNIT);
|
||||
|
|
23
pom.xml
23
pom.xml
|
@ -26,7 +26,7 @@
|
|||
<!-- default values are unsupported, but required to be defined for reactor sanity reasons -->
|
||||
<alpn.version>undefined</alpn.version>
|
||||
<conscrypt.version>1.0.0.RC11</conscrypt.version>
|
||||
<asm.version>6.1.1</asm.version>
|
||||
<asm.version>6.2</asm.version>
|
||||
<jmh.version>1.20</jmh.version>
|
||||
<jmhjar.name>benchmarks</jmhjar.name>
|
||||
<surefireVersion>2.21.0</surefireVersion>
|
||||
|
@ -452,7 +452,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-invoker-plugin</artifactId>
|
||||
<version>3.0.2-SNAPSHOT</version>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -490,10 +490,6 @@
|
|||
<links>
|
||||
<link>http://docs.oracle.com/javase/8/docs/api/</link>
|
||||
<link>http://docs.oracle.com/javaee/7/api/</link>
|
||||
<!--
|
||||
not sure why we have this link....??
|
||||
<link>http://download.eclipse.org/jetty/stable-9/apidocs/</link>
|
||||
-->
|
||||
</links>
|
||||
<tags>
|
||||
<tag>
|
||||
|
@ -1291,8 +1287,19 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- needed for Java 8+ -->
|
||||
<additionalparam>--allow-script-in-comments</additionalparam>
|
||||
<excludePackageNames>com.acme</excludePackageNames>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/8/docs/api/</link>
|
||||
<link>http://docs.oracle.com/javaee/7/api</link>
|
||||
<link>http://junit.sourceforge.net/javadoc/</link>
|
||||
</links>
|
||||
<tags>
|
||||
<tag>
|
||||
<name>org.apache.xbean.XBean</name>
|
||||
<placement>X</placement>
|
||||
<head />
|
||||
</tag>
|
||||
</tags>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
|
|||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.log.StacklessLogging;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
|
@ -430,7 +431,7 @@ public class ServerTimeoutsTest extends AbstractTest
|
|||
});
|
||||
setServerIdleTimeout(idleTimeout);
|
||||
|
||||
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class))
|
||||
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class, QueuedThreadPool.class))
|
||||
{
|
||||
DeferredContentProvider contentProvider = new DeferredContentProvider();
|
||||
CountDownLatch resultLatch = new CountDownLatch(1);
|
||||
|
|
Loading…
Reference in New Issue