Merge remote-tracking branch 'origin/jetty-9.2.x' into jetty-9.3.x
This commit is contained in:
commit
d065f1e068
|
@ -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);
|
||||
}
|
||||
}
|
208
pom.xml
208
pom.xml
|
@ -534,172 +534,35 @@
|
|||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-version-maven-plugin</artifactId>
|
||||
<versionRange>[1.0.3,)</versionRange>
|
||||
<goals>
|
||||
<goal>attach-version-text</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<versionRange>[2.1,)</versionRange>
|
||||
<goals>
|
||||
<goal>unpack</goal>
|
||||
<goal>unpack-dependencies</goal>
|
||||
<goal>copy-dependencies</goal>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.ops4j.pax.exam</groupId>
|
||||
<artifactId>maven-paxexam-plugin</artifactId>
|
||||
<versionRange>
|
||||
[1.2.0,)
|
||||
</versionRange>
|
||||
<goals>
|
||||
<goal>
|
||||
generate-depends-file
|
||||
</goal>
|
||||
<goal>generate-config</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<versionRange>[1.4,)</versionRange>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.sonatype.maven.plugin</groupId>
|
||||
<artifactId>emma-maven-plugin</artifactId>
|
||||
<versionRange>[1.1,)</versionRange>
|
||||
<goals>
|
||||
<goal>instrument</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<versionRange>[2.5,)</versionRange>
|
||||
<goals>
|
||||
<goal>default-descriptor</goal>
|
||||
<goal>descriptor</goal>
|
||||
<goal>xdoc</goal>
|
||||
<goal>helpmojo</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
<versionRange>[1.0-alpha-7,)</versionRange>
|
||||
<goals>
|
||||
<goal>initialize</goal>
|
||||
<goal>javah</goal>
|
||||
<goal>compile</goal>
|
||||
<goal>unzipinc</goal>
|
||||
<goal>link</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<versionRange>[2.8,)</versionRange>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<versionRange>[2.5,)</versionRange>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-remote-resources-plugin</artifactId>
|
||||
<versionRange>[1.0,)</versionRange>
|
||||
<goals>
|
||||
<goal>process</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<versionRange>[1.0,)</versionRange>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
<docfilessubdirs>true</docfilessubdirs>
|
||||
<detectLinks>false</detectLinks>
|
||||
<detectJavaApiLink>true</detectJavaApiLink>
|
||||
<excludePackageNames>com.acme.*;org.slf4j.*;org.mortbay.*</excludePackageNames>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/7/docs/api/</link>
|
||||
<link>http://docs.oracle.com/javaee/7/api/</link>
|
||||
<link>http://download.eclipse.org/jetty/stable-9/apidocs/</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>
|
||||
<plugin>
|
||||
|
@ -1062,6 +925,21 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludePackageNames>com.acme</excludePackageNames>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/7/docs/api/</link>
|
||||
<link>http://docs.oracle.com/javaee/6/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>
|
||||
</build>
|
||||
|
|
Loading…
Reference in New Issue