Fixing Checkstyle violations

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2020-01-09 15:56:06 -06:00
parent 0e0f5822c3
commit 1f8ad08281
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
68 changed files with 423 additions and 439 deletions

View File

@ -181,7 +181,8 @@ public class JDK9ALPNTest
@Test
public void testClientSupportingALPNCannotNegotiateProtocol() throws Exception
{
startServer(new AbstractHandler() {
startServer(new AbstractHandler()
{
@Override
public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response)
{

View File

@ -426,16 +426,16 @@ public class HttpClientTest extends AbstractHttpClientServerTest
AtomicInteger progress = new AtomicInteger();
ContentResponse response = client.POST(scenario.getScheme() + "://localhost:" + connector.getLocalPort())
.onRequestContent((request, buffer) ->
{
byte[] bytes = new byte[buffer.remaining()];
assertEquals(1, bytes.length);
buffer.get(bytes);
assertEquals(bytes[0], progress.getAndIncrement());
})
.content(new BytesContentProvider(new byte[]{0}, new byte[]{1}, new byte[]{2}, new byte[]{3}, new byte[]{4}))
.timeout(5, TimeUnit.SECONDS)
.send();
.onRequestContent((request, buffer) ->
{
byte[] bytes = new byte[buffer.remaining()];
assertEquals(1, bytes.length);
buffer.get(bytes);
assertEquals(bytes[0], progress.getAndIncrement());
})
.content(new BytesContentProvider(new byte[]{0}, new byte[]{1}, new byte[]{2}, new byte[]{3}, new byte[]{4}))
.timeout(5, TimeUnit.SECONDS)
.send();
assertNotNull(response);
assertEquals(200, response.getStatus());

View File

@ -142,17 +142,17 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
failureLatch.countDown();
}
})
.send(new Response.Listener.Adapter()
{
@Override
public void onComplete(Result result)
.send(new Response.Listener.Adapter()
{
assertTrue(result.isFailed());
assertEquals(0, idleConnections.size());
assertEquals(0, activeConnections.size());
failureLatch.countDown();
}
});
@Override
public void onComplete(Result result)
{
assertTrue(result.isFailed());
assertEquals(0, idleConnections.size());
assertEquals(0, activeConnections.size());
failureLatch.countDown();
}
});
assertTrue(beginLatch.await(30, TimeUnit.SECONDS));
assertTrue(failureLatch.await(30, TimeUnit.SECONDS));
@ -195,24 +195,24 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
successLatch.countDown();
}
})
.send(new Response.Listener.Adapter()
{
@Override
public void onSuccess(Response response)
.send(new Response.Listener.Adapter()
{
assertEquals(400, response.getStatus());
// 400 response also come with a Connection: close,
// so the connection is closed and removed
successLatch.countDown();
}
@Override
public void onSuccess(Response response)
{
assertEquals(400, response.getStatus());
// 400 response also come with a Connection: close,
// so the connection is closed and removed
successLatch.countDown();
}
@Override
public void onComplete(Result result)
{
assertFalse(result.isFailed());
successLatch.countDown();
}
});
@Override
public void onComplete(Result result)
{
assertFalse(result.isFailed());
successLatch.countDown();
}
});
assertTrue(successLatch.await(30, TimeUnit.SECONDS));
@ -270,24 +270,24 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
successLatch.countDown();
}
})
.send(new Response.Listener.Adapter()
{
@Override
public void onSuccess(Response response)
.send(new Response.Listener.Adapter()
{
assertEquals(400, response.getStatus());
// 400 response also come with a Connection: close,
// so the connection is closed and removed
successLatch.countDown();
}
@Override
public void onSuccess(Response response)
{
assertEquals(400, response.getStatus());
// 400 response also come with a Connection: close,
// so the connection is closed and removed
successLatch.countDown();
}
@Override
public void onComplete(Result result)
{
assertFalse(result.isFailed());
successLatch.countDown();
}
});
@Override
public void onComplete(Result result)
{
assertFalse(result.isFailed());
successLatch.countDown();
}
});
assertTrue(successLatch.await(delay * 30, TimeUnit.MILLISECONDS));

View File

@ -359,10 +359,10 @@ public class GZIPContentDecoderTest
}
// Signed Integer Max
final long INT_MAX = Integer.MAX_VALUE;
static final long INT_MAX = Integer.MAX_VALUE;
// Unsigned Integer Max == 2^32
final long UINT_MAX = 0xFFFFFFFFL;
static final long UINT_MAX = 0xFFFFFFFFL;
@ParameterizedTest
@ValueSource(longs = {INT_MAX, INT_MAX + 1, UINT_MAX, UINT_MAX + 1})

View File

@ -760,8 +760,8 @@ public class HttpParserTest
"Foo\"Bar: value\r\n",
"Foo/Bar: value\r\n",
"Foo]Bar: value\r\n",
"Foo[Bar: value\r\n",
};
"Foo[Bar: value\r\n"
};
for (String s : bad)
{

View File

@ -174,12 +174,12 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
"name0: value0\r\n" +
"name1 :value1 \r\n" +
"name2:value\r\n" +
" 2\r\n" +
"\r\n" +
"Content");
"name0: value0\r\n" +
"name1 :value1 \r\n" +
"name2:value\r\n" +
" 2\r\n" +
"\r\n" +
"Content");
parser.parse(data, false);
assertThat(parser.getState(), is(State.FIRST_OCTETS));
@ -194,10 +194,10 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
"name: value\r\n" +
"\r\n" +
"\r\n" +
"--BOUNDARY");
"name: value\r\n" +
"\r\n" +
"\r\n" +
"--BOUNDARY");
parser.parse(data, false);
assertThat(parser.getState(), is(State.DELIMITER));
assertThat(data.remaining(), is(0));
@ -212,9 +212,9 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
"name: value\r\n" +
"\r\n" +
"--BOUNDARY");
"name: value\r\n" +
"\r\n" +
"--BOUNDARY");
parser.parse(data, false);
assertThat(parser.getState(), is(State.DELIMITER));
assertThat(data.remaining(), is(0));
@ -229,9 +229,9 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
"name: value\r\n" +
"\r\n" +
"-");
"name: value\r\n" +
"\r\n" +
"-");
parser.parse(data, false);
data = BufferUtil.toBuffer("Content!");
parser.parse(data, false);
@ -249,9 +249,9 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
"name: value\n" +
"\r\n" +
"Hello\r\n");
"name: value\n" +
"\r\n" +
"Hello\r\n");
parser.parse(data, false);
assertThat(parser.getState(), is(State.OCTETS));
assertThat(data.remaining(), is(0));
@ -260,17 +260,17 @@ public class MultiPartParserTest
data = BufferUtil.toBuffer(
"Now is the time for all good ment to come to the aid of the party.\r\n" +
"How now brown cow.\r\n" +
"The quick brown fox jumped over the lazy dog.\r\n" +
"this is not a --BOUNDARY\r\n");
"How now brown cow.\r\n" +
"The quick brown fox jumped over the lazy dog.\r\n" +
"this is not a --BOUNDARY\r\n");
parser.parse(data, false);
assertThat(parser.getState(), is(State.OCTETS));
assertThat(data.remaining(), is(0));
assertThat(handler.fields, Matchers.contains("name: value", "<<COMPLETE>>"));
assertThat(handler.content, Matchers.contains("Hello", "\r\n", "Now is the time for all good ment to come to the aid of the party.\r\n" +
"How now brown cow.\r\n" +
"The quick brown fox jumped over the lazy dog.\r\n" +
"this is not a --BOUNDARY"));
"How now brown cow.\r\n" +
"The quick brown fox jumped over the lazy dog.\r\n" +
"this is not a --BOUNDARY"));
}
@Test
@ -280,10 +280,10 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
"name: value\n" +
"\r\n" +
"Hello\r\n" +
"--BOUNDARY");
"name: value\n" +
"\r\n" +
"Hello\r\n" +
"--BOUNDARY");
parser.parse(data, false);
assertThat(parser.getState(), is(State.DELIMITER));
assertThat(data.remaining(), is(0));
@ -298,20 +298,20 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
"name: value\n" +
"\r\n" +
"Now is the time for all good ment to come to the aid of the party.\r\n" +
"How now brown cow.\r\n" +
"The quick brown fox jumped over the lazy dog.\r\n" +
"\r\n" +
"--BOUNDARY");
"name: value\n" +
"\r\n" +
"Now is the time for all good ment to come to the aid of the party.\r\n" +
"How now brown cow.\r\n" +
"The quick brown fox jumped over the lazy dog.\r\n" +
"\r\n" +
"--BOUNDARY");
parser.parse(data, false);
assertThat(parser.getState(), is(State.DELIMITER));
assertThat(data.remaining(), is(0));
assertThat(handler.fields, Matchers.contains("name: value", "<<COMPLETE>>"));
assertThat(handler.content, Matchers.contains("Now is the time for all good ment to come to the aid of the party.\r\n" +
"How now brown cow.\r\n" +
"The quick brown fox jumped over the lazy dog.\r\n", "<<LAST>>"));
"How now brown cow.\r\n" +
"The quick brown fox jumped over the lazy dog.\r\n", "<<LAST>>"));
}
@Test
@ -322,20 +322,20 @@ public class MultiPartParserTest
//boundary still requires carriage return
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\n" +
"name: value\n" +
"\n" +
"Now is the time for all good men to come to the aid of the party.\n" +
"How now brown cow.\n" +
"The quick brown fox jumped over the lazy dog.\n" +
"\r\n" +
"--BOUNDARY");
"name: value\n" +
"\n" +
"Now is the time for all good men to come to the aid of the party.\n" +
"How now brown cow.\n" +
"The quick brown fox jumped over the lazy dog.\n" +
"\r\n" +
"--BOUNDARY");
parser.parse(data, false);
assertThat(parser.getState(), is(State.DELIMITER));
assertThat(data.remaining(), is(0));
assertThat(handler.fields, Matchers.contains("name: value", "<<COMPLETE>>"));
assertThat(handler.content, Matchers.contains("Now is the time for all good men to come to the aid of the party.\n" +
"How now brown cow.\n" +
"The quick brown fox jumped over the lazy dog.\n", "<<LAST>>"));
"How now brown cow.\n" +
"The quick brown fox jumped over the lazy dog.\n", "<<LAST>>"));
}
@Test
@ -378,16 +378,16 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
ByteBuffer data = BufferUtil.toBuffer("" +
"--BOUNDARY\r\n" +
"name: value\n" +
"\r\n" +
"Hello\r\n" +
"--BOUNDARY--" +
"epilogue here:" +
"\r\n" +
"--BOUNDARY--" +
"\r\n" +
"--BOUNDARY");
"--BOUNDARY\r\n" +
"name: value\n" +
"\r\n" +
"Hello\r\n" +
"--BOUNDARY--" +
"epilogue here:" +
"\r\n" +
"--BOUNDARY--" +
"\r\n" +
"--BOUNDARY");
parser.parse(data, false);
assertThat(parser.getState(), is(State.DELIMITER));
@ -405,19 +405,19 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
ByteBuffer data = BufferUtil.toBuffer("" +
"--BOUNDARY\r\n" +
"name: value\n" +
"\r\n" +
"Hello" +
"\r\n" +
"--BOUNDARY\r\n" +
"powerLevel: 9001\n" +
"\r\n" +
"secondary" +
"\r\n" +
"content" +
"\r\n--BOUNDARY--" +
"epilogue here");
"--BOUNDARY\r\n" +
"name: value\n" +
"\r\n" +
"Hello" +
"\r\n" +
"--BOUNDARY\r\n" +
"powerLevel: 9001\n" +
"\r\n" +
"secondary" +
"\r\n" +
"content" +
"\r\n--BOUNDARY--" +
"epilogue here");
/* Test First Content Section */
parser.parse(data, false);
@ -613,20 +613,20 @@ public class MultiPartParserTest
assertThat("Third " + i, parser.parse(dataSeg, true), is(true));
assertThat(handler.fields, Matchers.contains("Content-Disposition: form-data; name=\"text\"", "<<COMPLETE>>",
"Content-Disposition: form-data; name=\"file1\"; filename=\"a.txt\"",
"Content-Type: text/plain", "<<COMPLETE>>",
"Content-Disposition: form-data; name=\"file2\"; filename=\"a.html\"",
"Content-Type: text/html", "<<COMPLETE>>",
"Field1: value1", "Field2: value2", "Field3: value3",
"Field4: value4", "Field5: value5", "Field6: value6",
"Field7: value7", "Field8: value8", "Field9: value 9", "<<COMPLETE>>",
"Field1: value1", "<<COMPLETE>>"));
"Content-Disposition: form-data; name=\"file1\"; filename=\"a.txt\"",
"Content-Type: text/plain", "<<COMPLETE>>",
"Content-Disposition: form-data; name=\"file2\"; filename=\"a.html\"",
"Content-Type: text/html", "<<COMPLETE>>",
"Field1: value1", "Field2: value2", "Field3: value3",
"Field4: value4", "Field5: value5", "Field6: value6",
"Field7: value7", "Field8: value8", "Field9: value 9", "<<COMPLETE>>",
"Field1: value1", "<<COMPLETE>>"));
assertThat(handler.contentString(), is("text default" + "<<LAST>>" +
"Content of a.txt.\n" + "<<LAST>>" +
"<!DOCTYPE html><title>Content of a.html.</title>\n" + "<<LAST>>" +
"<<LAST>>" +
"But the amount of denudation which the strata have\n" +
"Content of a.txt.\n" + "<<LAST>>" +
"<!DOCTYPE html><title>Content of a.html.</title>\n" + "<<LAST>>" +
"<<LAST>>" +
"But the amount of denudation which the strata have\n" +
"in many places suffered, independently of the rate\n" +
"of accumulation of the degraded matter, probably\n" +
"offers the best evidence of the lapse of time. I remember\n" +
@ -671,17 +671,17 @@ public class MultiPartParserTest
MultiPartParser parser = new MultiPartParser(handler, "WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW");
ByteBuffer data = BufferUtil.toBuffer("" +
"Content-Type: multipart/form-data; boundary=WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\r\n" +
"\r\n" +
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\r\n" +
"Content-Disposition: form-data; name=\"part1\"\r\n" +
"\n" +
"wNfミxVam﾿t\r\n" +
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\n" +
"Content-Disposition: form-data; name=\"part2\"\r\n" +
"\r\n" +
"&ᄈᄎ￙ᅱᅢO\r\n" +
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW--");
"Content-Type: multipart/form-data; boundary=WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\r\n" +
"\r\n" +
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\r\n" +
"Content-Disposition: form-data; name=\"part1\"\r\n" +
"\n" +
"wNfミxVam﾿t\r\n" +
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\n" +
"Content-Disposition: form-data; name=\"part2\"\r\n" +
"\r\n" +
"&ᄈᄎ￙ᅱᅢO\r\n" +
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW--");
parser.parse(data, true);
assertThat(parser.getState(), is(State.END));

View File

@ -68,7 +68,6 @@ import org.eclipse.jetty.util.resource.Resource;
*/
public abstract class AbstractWebAppMojo extends AbstractMojo
{
public static final String JETTY_HOME_GROUPID = "org.eclipse.jetty";
public static final String JETTY_HOME_ARTIFACTID = "jetty-home";
public static final String FAKE_WEBAPP = "webapp-synth";
@ -375,7 +374,6 @@ public abstract class AbstractWebAppMojo extends AbstractMojo
*/
protected List<Artifact> warArtifacts;
/**
* Webapp base before applying overlays etc
*/
@ -798,8 +796,6 @@ public abstract class AbstractWebAppMojo extends AbstractMojo
getLog().info("Context path = " + webApp.getContextPath());
getLog().info("Tmp directory = " + (webApp.getTempDirectory() == null ? " determined at runtime" : webApp.getTempDirectory()));
}
/**
* Try and find a jetty-web.xml file, using some

View File

@ -23,17 +23,14 @@ import java.util.EventListener;
import java.util.HashSet;
import java.util.Set;
/**
* ConsoleReader
*
* Reads lines from the System console and supplies them
* to ConsoleReader.Listeners.
*
*/
public class ConsoleReader implements Runnable
{
public interface Listener extends EventListener
{
public void consoleEvent(String line);

View File

@ -45,10 +45,9 @@ import org.eclipse.jetty.util.resource.Resource;
/**
* JettyDistroForker
*
*
* Unpacks a jetty distribution and configures it with a base that allows it
* to run an unassembled webapp.
*
*/
public class JettyDistroForker extends AbstractForker
{
@ -65,27 +64,27 @@ public class JettyDistroForker extends AbstractForker
* Zip of jetty distro
*/
protected File jettyDistro;
/**
* Location of existing jetty base directory
*/
protected File jettyBase;
protected File baseDir;
/**
* Optional list of other modules to
* activate.
*/
protected String[] modules;
protected List<File> libExtJarFiles;
protected List<File> libExtJarFiles;
protected Path modulesPath;
protected Path etcPath;
protected Path libPath;
protected Path webappPath;
protected Path mavenLibPath;
public List<File> getLibExtJarFiles()
{
return libExtJarFiles;
@ -135,7 +134,7 @@ public class JettyDistroForker extends AbstractForker
{
this.contextXml = contextXml;
}
public File getJettyDistro()
{
return jettyDistro;
@ -176,37 +175,37 @@ public class JettyDistroForker extends AbstractForker
cmd.add("java");
cmd.add("-jar");
cmd.add(new File(jettyHome, "start.jar").getAbsolutePath());
cmd.add("-DSTOP.PORT=" + stopPort);
if (stopKey != null)
cmd.add("-DSTOP.KEY=" + stopKey);
//add any args to the jvm
if (jvmArgs != null)
{
String[] args = jvmArgs.split(" ");
for (String a:args)
for (String a : args)
{
if (!StringUtil.isBlank(a))
cmd.add(a.trim());
}
}
if (systemProperties != null)
{
for (Map.Entry<String,String> e:systemProperties.entrySet())
for (Map.Entry<String, String> e : systemProperties.entrySet())
{
cmd.add("-D" + e.getKey() + "=" + e.getValue());
}
}
//set up enabled jetty modules
StringBuilder tmp = new StringBuilder();
tmp.append("--module=");
tmp.append("server,http,webapp,deploy");
if (modules != null)
{
for (String m:modules)
for (String m : modules)
{
if (tmp.indexOf(m) < 0)
tmp.append("," + m);
@ -217,11 +216,11 @@ public class JettyDistroForker extends AbstractForker
tmp.append(",ext");
tmp.append(",maven");
cmd.add(tmp.toString());
//put any jetty properties onto the command line
if (jettyProperties != null)
{
for (Map.Entry<String, String> e:jettyProperties.entrySet())
for (Map.Entry<String, String> e : jettyProperties.entrySet())
{
cmd.add(e.getKey() + "=" + e.getValue());
}
@ -232,9 +231,9 @@ public class JettyDistroForker extends AbstractForker
ProcessBuilder builder = new ProcessBuilder(cmd);
builder.directory(workDir);
PluginLog.getLog().info("Distro process starting");
//set up extra environment vars if there are any
if (!env.isEmpty())
builder.environment().putAll(env);
@ -254,16 +253,16 @@ public class JettyDistroForker extends AbstractForker
{
//set up a jetty-home
configureJettyHome();
if (jettyHome == null || !jettyHome.exists())
throw new IllegalStateException("No jetty home");
//set up a jetty-base
configureJettyBase();
//convert the webapp to properties
generateWebAppPropertiesFile();
super.doStart();
}
@ -280,11 +279,8 @@ public class JettyDistroForker extends AbstractForker
WebAppPropertyConverter.toProperties(webApp, etcPath.resolve("maven.props").toFile(), contextXml);
}
/**
* Create or configure a jetty base.
*
* @throws Exception
*/
private void configureJettyBase() throws Exception
{
@ -295,9 +291,9 @@ public class JettyDistroForker extends AbstractForker
Path targetBasePath = targetJettyBase.toPath();
if (Files.exists(targetBasePath))
IO.delete(targetJettyBase);
targetJettyBase.mkdirs();
//jetty-base will be the working directory for the forked command
workDir = targetJettyBase;
@ -305,41 +301,41 @@ public class JettyDistroForker extends AbstractForker
if (jettyBase != null)
{
Path jettyBasePath = jettyBase.toPath();
final File contextXmlFile = (contextXml == null ? null : FileSystems.getDefault().getPath(contextXml).toFile());
//copy the existing jetty base
Files.walkFileTree(jettyBasePath, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
new SimpleFileVisitor<Path>()
{
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException
{
Path targetDir = targetBasePath.resolve(jettyBasePath.relativize(dir));
try
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException
{
Files.copy(dir, targetDir);
Path targetDir = targetBasePath.resolve(jettyBasePath.relativize(dir));
try
{
Files.copy(dir, targetDir);
}
catch (FileAlreadyExistsException e)
{
if (!Files.isDirectory(targetDir)) //ignore attempt to recreate dir
throw e;
}
return FileVisitResult.CONTINUE;
}
catch (FileAlreadyExistsException e)
{
if (!Files.isDirectory(targetDir)) //ignore attempt to recreate dir
throw e;
}
return FileVisitResult.CONTINUE;
}
/**
* @see java.nio.file.SimpleFileVisitor#visitFile(java.lang.Object, java.nio.file.attribute.BasicFileAttributes)
*/
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
{
if (contextXmlFile != null && Files.isSameFile(contextXmlFile.toPath(), file))
return FileVisitResult.CONTINUE; //skip copying the context xml file
Files.copy(file, targetBasePath.resolve(jettyBasePath.relativize(file)));
return FileVisitResult.CONTINUE;
}
});
/**
* @see java.nio.file.SimpleFileVisitor#visitFile(java.lang.Object, java.nio.file.attribute.BasicFileAttributes)
*/
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
{
if (contextXmlFile != null && Files.isSameFile(contextXmlFile.toPath(), file))
return FileVisitResult.CONTINUE; //skip copying the context xml file
Files.copy(file, targetBasePath.resolve(jettyBasePath.relativize(file)));
return FileVisitResult.CONTINUE;
}
});
}
//make the jetty base structure
@ -355,45 +351,45 @@ public class JettyDistroForker extends AbstractForker
throw new IllegalStateException("Can't find jar for jetty-maven-plugin");
try (InputStream jarStream = thisJar.toURL().openStream();
FileOutputStream fileStream = new FileOutputStream(mavenLibPath.resolve("plugin.jar").toFile()))
FileOutputStream fileStream = new FileOutputStream(mavenLibPath.resolve("plugin.jar").toFile()))
{
IO.copy(jarStream,fileStream);
IO.copy(jarStream, fileStream);
}
//copy in the maven.xml webapp file
try (InputStream mavenXmlStream = getClass().getClassLoader().getResourceAsStream("maven.xml");
try (InputStream mavenXmlStream = getClass().getClassLoader().getResourceAsStream("maven.xml");
FileOutputStream fileStream = new FileOutputStream(webappPath.resolve("maven.xml").toFile()))
{
IO.copy(mavenXmlStream, fileStream);
}
//copy in the maven.mod file
try (InputStream mavenModStream = getClass().getClassLoader().getResourceAsStream("maven.mod");
FileOutputStream fileStream = new FileOutputStream(modulesPath.resolve("maven.mod").toFile()))
FileOutputStream fileStream = new FileOutputStream(modulesPath.resolve("maven.mod").toFile()))
{
IO.copy(mavenModStream, fileStream);
}
//copy in the jetty-maven.xml file
try (InputStream jettyMavenStream = getClass().getClassLoader().getResourceAsStream("jetty-maven.xml");
FileOutputStream fileStream = new FileOutputStream(etcPath.resolve("jetty-maven.xml").toFile()))
FileOutputStream fileStream = new FileOutputStream(etcPath.resolve("jetty-maven.xml").toFile()))
{
IO.copy(jettyMavenStream, fileStream);
}
//if there were plugin dependencies, copy them into lib/ext
if (libExtJarFiles != null && !libExtJarFiles.isEmpty())
{
Path libExtPath = Files.createDirectories(libPath.resolve("ext"));
for (File f:libExtJarFiles)
for (File f : libExtJarFiles)
{
try (InputStream jarStream = new FileInputStream(f);
FileOutputStream fileStream = new FileOutputStream(libExtPath.resolve(f.getName()).toFile()))
FileOutputStream fileStream = new FileOutputStream(libExtPath.resolve(f.getName()).toFile()))
{
IO.copy(jarStream, fileStream);
}
}
}
}
}
private void configureJettyHome()
@ -404,7 +400,7 @@ public class JettyDistroForker extends AbstractForker
if (baseDir == null)
throw new IllegalStateException("No baseDir");
if (jettyHome == null)
{
JarResource res = (JarResource)JarResource.newJarResource(Resource.newResource(jettyDistro));
@ -412,7 +408,7 @@ public class JettyDistroForker extends AbstractForker
//zip will unpack to target/jetty-home-<VERSION>
String name = jettyDistro.getName();
int i = name.lastIndexOf('.');
name = (i > 0 ? name.substring(0, i) : "distro");
name = (i > 0 ? name.substring(0, i) : "distro");
jettyHome = new File(baseDir, name);
}
}

View File

@ -38,7 +38,6 @@ import org.eclipse.jetty.util.resource.Resource;
* JettyEmbedded
*
* Starts jetty within the current process.
*
*/
public class JettyEmbedder extends AbstractLifeCycle
{
@ -244,8 +243,7 @@ public class JettyEmbedder extends AbstractLifeCycle
{
server.join();
}
/**
* Configure the server and the webapp
* @throws Exception

View File

@ -49,7 +49,6 @@ public class JettyForker extends AbstractForker
return scan;
}
/**
* @param scan if true, the forked child will scan for changes
*/
@ -229,7 +228,6 @@ public class JettyForker extends AbstractForker
return command;
}
/**
* @return the location of the java binary
*/

View File

@ -43,7 +43,6 @@ public class QuickStartGenerator
private boolean prepared = false;
private Server server;
private QueuedThreadPool tpool;
/**
* @param quickstartXml the file to generate quickstart into

View File

@ -38,11 +38,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
*
*/
public class TestWebAppPropertyConverter
{
static File testDir;

View File

@ -101,17 +101,17 @@ public class JwtDecoderTest
public void testDecodeMissingPadding()
{
// Example given in Issue #4128 which requires the re-adding the B64 padding to decode.
String jwt = "eyJraWQiOiIxNTU1OTM0ODQ3IiwieDV0IjoiOWdCOW9zRldSRHRSMkhtNGNmVnJnWTBGcmZRIiwiYWxnIjoiUlMyNTYifQ"
+ ".eyJhdF9oYXNoIjoiQTA0NUoxcE5YRk1nYzlXN2wxSk1fUSIsImRlbGVnYXRpb25faWQiOiJjZTBhNjRlNS0xYWY3LTQ2MzEtOGUz"
+ "NC1mNDE5N2JkYzVjZTAiLCJhY3IiOiJ1cm46c2U6Y3VyaXR5OmF1dGhlbnRpY2F0aW9uOmh0bWwtZm9ybTpodG1sLXByaW1hcnkiL"
+ "CJzX2hhc2giOiIwc1FtRG9YY3FwcnM4NWUzdy0wbHdBIiwiYXpwIjoiNzZiZTc5Y2ItM2E1Ni00ZTE3LTg3NzYtNDI1Nzc5MjRjYz"
+ "c2IiwiYXV0aF90aW1lIjoxNTY5NjU4MDk1LCJleHAiOjE1Njk2NjE5OTUsIm5iZiI6MTU2OTY1ODM5NSwianRpIjoiZjJkNWI2YzE"
+ "tNTIxYi00Y2Y5LThlNWEtOTg5NGJhNmE0MzkyIiwiaXNzIjoiaHR0cHM6Ly9ub3JkaWNhcGlzLmN1cml0eS5pby9-IiwiYXVkIjoi"
+ "NzZiZTc5Y2ItM2E1Ni00ZTE3LTg3NzYtNDI1Nzc5MjRjYzc2Iiwic3ViIjoibmlrb3MiLCJpYXQiOjE1Njk2NTgzOTUsInB1cnBvc"
+ "2UiOiJpZCJ9.Wd458zNmXggpkDN6vbS3-aiajh4-VbkmcStLYUqahYJUp9p-AUI_RZttWvwh3UDMG9rWww_ya8KFK_SkPfKooEaSN"
+ "OjOhw0ox4d-9lgti3J49eRyO20RViXvRHyLVtcjv5IaqvMXgwW60Thubv19OION7DstyArffcxNNSpiqDq6wjd0T2DJ3gSXXlJHLT"
+ "Wrry3svqu1j_GCbHc04XYGicxsusKgc3n22dh4I6p4trdo0Gu5Un0bZ8Yov7IzWItqTgm9X5r9gZlAOLcAuK1WTwkzAwZJ24HgvxK"
+ "muYfV_4ZCg_VPN2Op8YPuRAQOgUERpeTv1RDFTOG9GKZIMBVR0A";
String jwt = "eyJraWQiOiIxNTU1OTM0ODQ3IiwieDV0IjoiOWdCOW9zRldSRHRSMkhtNGNmVnJnWTBGcmZRIiwiYWxnIjoiUlMyNTYifQ" +
".eyJhdF9oYXNoIjoiQTA0NUoxcE5YRk1nYzlXN2wxSk1fUSIsImRlbGVnYXRpb25faWQiOiJjZTBhNjRlNS0xYWY3LTQ2MzEtOGUz" +
"NC1mNDE5N2JkYzVjZTAiLCJhY3IiOiJ1cm46c2U6Y3VyaXR5OmF1dGhlbnRpY2F0aW9uOmh0bWwtZm9ybTpodG1sLXByaW1hcnkiL" +
"CJzX2hhc2giOiIwc1FtRG9YY3FwcnM4NWUzdy0wbHdBIiwiYXpwIjoiNzZiZTc5Y2ItM2E1Ni00ZTE3LTg3NzYtNDI1Nzc5MjRjYz" +
"c2IiwiYXV0aF90aW1lIjoxNTY5NjU4MDk1LCJleHAiOjE1Njk2NjE5OTUsIm5iZiI6MTU2OTY1ODM5NSwianRpIjoiZjJkNWI2YzE" +
"tNTIxYi00Y2Y5LThlNWEtOTg5NGJhNmE0MzkyIiwiaXNzIjoiaHR0cHM6Ly9ub3JkaWNhcGlzLmN1cml0eS5pby9-IiwiYXVkIjoi" +
"NzZiZTc5Y2ItM2E1Ni00ZTE3LTg3NzYtNDI1Nzc5MjRjYzc2Iiwic3ViIjoibmlrb3MiLCJpYXQiOjE1Njk2NTgzOTUsInB1cnBvc" +
"2UiOiJpZCJ9.Wd458zNmXggpkDN6vbS3-aiajh4-VbkmcStLYUqahYJUp9p-AUI_RZttWvwh3UDMG9rWww_ya8KFK_SkPfKooEaSN" +
"OjOhw0ox4d-9lgti3J49eRyO20RViXvRHyLVtcjv5IaqvMXgwW60Thubv19OION7DstyArffcxNNSpiqDq6wjd0T2DJ3gSXXlJHLT" +
"Wrry3svqu1j_GCbHc04XYGicxsusKgc3n22dh4I6p4trdo0Gu5Un0bZ8Yov7IzWItqTgm9X5r9gZlAOLcAuK1WTwkzAwZJ24HgvxK" +
"muYfV_4ZCg_VPN2Op8YPuRAQOgUERpeTv1RDFTOG9GKZIMBVR0A";
// Decode the ID Token and verify the claims are the correct.
Map<String, Object> decodedClaims = JwtDecoder.decode(jwt);

View File

@ -110,7 +110,7 @@ public class OpenIdAuthenticationTest
context.setSecurityHandler(securityHandler);
server.start();
String redirectUri = "http://localhost:"+connector.getLocalPort() + "/j_security_check";
String redirectUri = "http://localhost:" + connector.getLocalPort() + "/j_security_check";
openIdProvider.addRedirectUri(redirectUri);
client = new HttpClient();
@ -127,7 +127,7 @@ public class OpenIdAuthenticationTest
@Test
public void testLoginLogout() throws Exception
{
String appUriString = "http://localhost:"+connector.getLocalPort();
String appUriString = "http://localhost:" + connector.getLocalPort();
// Initially not authenticated
ContentResponse response = client.GET(appUriString + "/");

View File

@ -142,8 +142,8 @@ public class OpenIdProvider extends ContainerLifeCycle
final Request baseRequest = Request.getBaseRequest(req);
final Response baseResponse = baseRequest.getResponse();
redirectUri += "?code=" + authCode + "&state=" + state;
int redirectCode = (baseRequest.getHttpVersion().getVersion() < HttpVersion.HTTP_1_1.getVersion() ?
HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER);
int redirectCode = (baseRequest.getHttpVersion().getVersion() < HttpVersion.HTTP_1_1.getVersion()
? HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER);
baseResponse.sendRedirect(redirectCode, resp.encodeRedirectURL(redirectUri));
}
}

View File

@ -130,7 +130,7 @@ public class SpnegoAuthenticatorTest
{
public MockConnector()
{
super(new Server() , null, null, null, 0);
super(new Server(), null, null, null, 0);
}
@Override
@ -150,29 +150,5 @@ public class SpnegoAuthenticatorTest
return null;
}
}
}
class MockConnector extends AbstractConnector
{
public MockConnector()
{
super(new Server() , null, null, null, 0);
}
@Override
protected void accept(int acceptorID) throws IOException, InterruptedException
{
}
@Override
public Object getTransport()
{
return null;
}
@Override
public String dumpSelf()
{
return null;
}
}

View File

@ -709,23 +709,24 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
statement.setLong(10, data.getExpiry());
statement.setLong(11, data.getMaxInactiveMs());
if(!data.getAllAttributes().isEmpty())
if (!data.getAllAttributes().isEmpty())
{
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos))
{
SessionData.serializeAttributes( data, oos );
SessionData.serializeAttributes(data, oos);
byte[] bytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream( bytes );
statement.setBinaryStream( 12, bais, bytes.length );//attribute map as blob
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
statement.setBinaryStream(12, bais, bytes.length);//attribute map as blob
}
}
else
{
statement.setBinaryStream( 12, EMPTY, 0);
statement.setBinaryStream(12, EMPTY, 0);
}
statement.executeUpdate();
if ( LOG.isDebugEnabled() ) LOG.debug( "Inserted session " + data );
if (LOG.isDebugEnabled())
LOG.debug("Inserted session " + data);
}
}
}
@ -745,7 +746,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
statement.setLong(5, data.getExpiry());
statement.setLong(6, data.getMaxInactiveMs());
if(!data.getAllAttributes().isEmpty())
if (!data.getAllAttributes().isEmpty())
{
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos))
@ -754,17 +755,18 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
byte[] bytes = baos.toByteArray();
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes))
{
statement.setBinaryStream( 7, bais, bytes.length );//attribute map as blob
statement.setBinaryStream(7, bais, bytes.length);//attribute map as blob
}
}
}
else
{
statement.setBinaryStream( 7, EMPTY, 0);
statement.setBinaryStream(7, EMPTY, 0);
}
statement.executeUpdate();
if ( LOG.isDebugEnabled() ) LOG.debug( "Updated session " + data );
if (LOG.isDebugEnabled())
LOG.debug("Updated session " + data);
}
}
}

View File

@ -171,9 +171,9 @@ public class AsyncCompletionTest extends HttpServerTestFixture
}
enum WriteStyle
{ARRAY, BUFFER, BYTE, BYTE_THEN_ARRAY, PRINT}
;
{
ARRAY, BUFFER, BYTE, BYTE_THEN_ARRAY, PRINT
}
public static Stream<Arguments> asyncIOWriteTests()
{
@ -443,9 +443,6 @@ public class AsyncCompletionTest extends HttpServerTestFixture
{
throw new RuntimeException(e);
}
finally
{
}
}
@Override
@ -702,7 +699,10 @@ public class AsyncCompletionTest extends HttpServerTestFixture
}
enum ContentStyle
{BUFFER, STREAM} // TODO more types needed here
{
BUFFER, STREAM
// TODO more types needed here
}
private static class SendContentHandler extends AbstractHandler
{

View File

@ -163,8 +163,8 @@ public class CookiesTest
new Cookie("nameA0", "A0"),
new Cookie("nameA1", "A1"),
new Cookie("nameB0", "B0"),
new Cookie("nameB1", "B1"),
});
new Cookie("nameB1", "B1")
});
Cookie[] cookiesX = cutter.getCookies();
assertThat(cookiesX.length, is(4));

View File

@ -73,13 +73,13 @@ public class DelayedServerTest extends HttpServerTestBase
@Override
public void succeeded()
{
pool.execute(()->
pool.execute(() ->
{
try
{
Thread.sleep(10);
}
catch (InterruptedException e)
catch (InterruptedException ignored)
{
}
finally
@ -92,13 +92,13 @@ public class DelayedServerTest extends HttpServerTestBase
@Override
public void failed(Throwable x)
{
pool.execute(()->
pool.execute(() ->
{
try
{
Thread.sleep(20);
}
catch (InterruptedException e)
catch (InterruptedException ignored)
{
}
finally

View File

@ -168,9 +168,9 @@ public class GracefulStopTest
client.close();
}
/**
* Test completed writes during shutdown do not close output
*
* @throws Exception on test failure
*/
@Test
@ -205,7 +205,7 @@ public class GracefulStopTest
stopper.start();
final int port = connector.getLocalPort();
try(Socket client = new Socket("127.0.0.1", port))
try (Socket client = new Socket("127.0.0.1", port))
{
client.getOutputStream().write((
"GET / HTTP/1.1\r\n" +
@ -215,7 +215,9 @@ public class GracefulStopTest
client.getOutputStream().flush();
while (!connector.isShutdown())
{
Thread.sleep(10);
}
handler.latchB.countDown();

View File

@ -274,6 +274,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
assertThat(response, Matchers.containsString("HTTP/1.1 400 "));
}
}
@Test
public void testExceptionThrownInHandlerLoop() throws Exception
{

View File

@ -185,7 +185,6 @@ public class HttpServerTestFixture
}
}
protected static class SendErrorHandler extends AbstractHandler
{
private final int code;

View File

@ -24,7 +24,7 @@ class MockConnector extends AbstractConnector
{
public MockConnector()
{
super(new Server() , null, null, null, 0);
super(new Server(), null, null, null, 0);
}
@Override

View File

@ -107,7 +107,6 @@ public class PartialRFC2616Test
}
}
@Test
public void test3_3_2()
{
@ -133,7 +132,6 @@ public class PartialRFC2616Test
}
}
@Test
public void test3_6_a() throws Exception
{

View File

@ -72,7 +72,8 @@ public class ServletWriterTest
char[] chars = new char[128 * 1024 * 1024];
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Thread> serverThreadRef = new AtomicReference<>();
start(chars.length, new AbstractHandler() {
start(chars.length, new AbstractHandler()
{
@Override
public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{

View File

@ -131,7 +131,8 @@ public class InetAccessHandlerTest
testConnector(_connector2.getLocalPort(), include, exclude, includeConnectors, excludeConnectors, codePerConnector.get(1));
}
private void testConnector(int port, String include, String exclude, String includeConnectors, String excludeConnectors, String code) throws IOException {
private void testConnector(int port, String include, String exclude, String includeConnectors, String excludeConnectors, String code) throws IOException
{
try (Socket socket = new Socket("127.0.0.1", port);)
{
socket.setSoTimeout(5000);
@ -157,6 +158,7 @@ public class InetAccessHandlerTest
/**
* Data for this test.
*
* @return Format of data: include;exclude;includeConnectors;excludeConnectors;assertionStatusCodePerConnector
*/
public static Stream<Arguments> data()
@ -211,12 +213,12 @@ public class InetAccessHandlerTest
{"127.0.0.1-127.0.0.254", "", "http_connector1;http_connector2", "", "200;200"},
{"192.0.0.1", "", "http_connector1;http_connector2", "", "403;403"},
{"192.0.0.1-192.0.0.254", "", "http_connector1;http_connector2", "", "403;403"},
// exclude takes precedence over include
{"127.0.0.1", "", "http_connector1;http_connector2", "http_connector1;http_connector2", "200;200"},
{"127.0.0.1-127.0.0.254", "", "http_connector1;http_connector2", "http_connector1;http_connector2", "200;200"},
{"192.0.0.1", "", "http_connector1;http_connector2", "http_connector1;http_connector2", "200;200"},
{"192.0.0.1-192.0.0.254", "", "http_connector1;http_connector2", "http_connector1;http_connector2", "200;200"},
{"192.0.0.1-192.0.0.254", "", "http_connector1;http_connector2", "http_connector1;http_connector2", "200;200"}
};
return Arrays.asList(data).stream().map(Arguments::of);
}

View File

@ -272,8 +272,6 @@ public class SniSslConnectionFactoryTest
assertThat(response.getStatus(), is(400));
}
@Test
public void testWrongSNIRejectedFunction() throws Exception
{

View File

@ -495,7 +495,7 @@ public class ErrorPageTest
{
final CountDownLatch hold = new CountDownLatch(1);
final String mode = request.getParameter("mode");
switch(mode)
switch (mode)
{
case "DSC":
case "SDC":
@ -511,7 +511,7 @@ public class ErrorPageTest
{
try
{
switch(mode)
switch (mode)
{
case "SDC":
response.sendError(599);
@ -554,7 +554,7 @@ public class ErrorPageTest
break;
}
}
catch(IllegalStateException e)
catch (IllegalStateException e)
{
Log.getLog().ignore(e);
}

View File

@ -196,6 +196,7 @@ public class GzipHandlerTest
out.setWriteListener(new WriteListener()
{
int count = writes == null ? 1 : Integer.valueOf(writes);
{
response.setContentLength(count * __bytes.length);
}
@ -203,7 +204,7 @@ public class GzipHandlerTest
@Override
public void onWritePossible() throws IOException
{
while(out.isReady())
while (out.isReady())
{
if (count-- == 0)
{
@ -426,7 +427,9 @@ public class GzipHandlerTest
byte[] bytes = testOut.toByteArray();
for (int i = 0; i < writes; i++)
assertEquals(__content, new String(Arrays.copyOfRange(bytes,i * __bytes.length, (i + 1) * __bytes.length), StandardCharsets.UTF_8), "chunk " + i);
{
assertEquals(__content, new String(Arrays.copyOfRange(bytes, i * __bytes.length, (i + 1) * __bytes.length), StandardCharsets.UTF_8), "chunk " + i);
}
}
@Test
@ -450,8 +453,6 @@ public class GzipHandlerTest
assertThat(response.getStatus(), is(200));
assertThat(response.get("Content-Encoding"), Matchers.equalToIgnoringCase("gzip"));
assertThat(response.getCSV("Vary", false), Matchers.contains("Accept-Encoding"));
}
@Test

View File

@ -70,9 +70,11 @@ public class ServletLifeCycleTest
sh.addServletWithMapping(TestServlet.class, "/1/*").setInitOrder(1);
sh.addServletWithMapping(TestServlet2.class, "/2/*").setInitOrder(-1);
sh.addServletWithMapping(new ServletHolder(context.getServletContext().createServlet(TestServlet3.class))
{{
setInitOrder(1);
}}, "/3/*");
{
{
setInitOrder(1);
}
}, "/3/*");
assertThat(events, Matchers.contains(
"Decorate class org.eclipse.jetty.servlet.ServletLifeCycleTest$TestListener2",
@ -126,7 +128,8 @@ public class ServletLifeCycleTest
assertThat(listeners.get(0).getClass(), is(TestListener2.class));
server.start();
context.addEventListener(new EventListener() {});listeners = context.getEventListeners();
context.addEventListener(new EventListener() {});
listeners = context.getEventListeners();
listeners = context.getEventListeners();
assertThat(listeners.size(), is(3));

View File

@ -64,8 +64,8 @@ public class GzipDefaultNoRecompressTest
{"jetty_logo.jp2", "image/jpeg2000", GzipHandler.GZIP},
//qvalue disables compression
{"test_quotes.txt", "text/plain", GzipHandler.GZIP + ";q=0"},
{"test_quotes.txt", "text/plain", GzipHandler.GZIP + "; q = 0 "},
}).stream().map(Arguments::of);
{"test_quotes.txt", "text/plain", GzipHandler.GZIP + "; q = 0 "}
}).stream().map(Arguments::of);
}
public WorkDir testingdir;

View File

@ -102,10 +102,10 @@ public class GzipDefaultTest
@SuppressWarnings("serial")
public static class HttpContentTypeWithEncoding extends HttpServlet
{
public static final String COMPRESSED_CONTENT = "<html><head></head><body><h1>COMPRESSABLE CONTENT</h1>"
+ "This content must be longer than the default min gzip length, which is 256 bytes. "
+ "The moon is blue to a fish in love. How now brown cow. The quick brown fox jumped over the lazy dog. A woman needs a man like a fish needs a bicycle!"
+ "</body></html>";
public static final String COMPRESSED_CONTENT = "<html><head></head><body><h1>COMPRESSABLE CONTENT</h1>" +
"This content must be longer than the default min gzip length, which is 256 bytes. " +
"The moon is blue to a fish in love. How now brown cow. The quick brown fox jumped over the lazy dog. A woman needs a man like a fish needs a bicycle!" +
"</body></html>";
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException

View File

@ -57,7 +57,7 @@ public final class Hex
return buf;
}
public static String asHex(byte buf[])
public static String asHex(byte[] buf)
{
int len = buf.length;
char[] out = new char[len * 2];

View File

@ -46,8 +46,8 @@ public class JSONPojoConvertorFactoryTest
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
foo._int1 = 1;
foo._int2 = 2;
foo._long1 = 1000001l;
foo._long2 = 1000002l;
foo._long1 = 1000001L;
foo._long2 = 1000002L;
foo._float1 = 10.11f;
foo._float2 = 10.22f;
foo._double1 = 10000.11111d;
@ -92,8 +92,8 @@ public class JSONPojoConvertorFactoryTest
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
foo._int1 = 1;
foo._int2 = 2;
foo._long1 = 1000001l;
foo._long2 = 1000002l;
foo._long1 = 1000001L;
foo._long2 = 1000002L;
foo._float1 = 10.11f;
foo._float2 = 10.22f;
foo._double1 = 10000.11111d;

View File

@ -45,8 +45,8 @@ public class JSONPojoConvertorTest
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
foo._int1 = 1;
foo._int2 = 2;
foo._long1 = 1000001l;
foo._long2 = 1000002l;
foo._long1 = 1000001L;
foo._long2 = 1000002L;
foo._float1 = 10.11f;
foo._float2 = 10.22f;
foo._double1 = 10000.11111d;
@ -93,8 +93,8 @@ public class JSONPojoConvertorTest
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
foo._int1 = 1;
foo._int2 = 2;
foo._long1 = 1000001l;
foo._long2 = 1000002l;
foo._long1 = 1000001L;
foo._long2 = 1000002L;
foo._float1 = 10.11f;
foo._float2 = 10.22f;
foo._double1 = 10000.11111d;

View File

@ -95,7 +95,7 @@ public class ScannerTest
_bulk.add(filenames);
}
});
_scanner.start();
_scanner.scan();
@ -121,11 +121,11 @@ public class ScannerTest
_notification = notification;
}
}
@Test
public void testDepth() throws Exception
{
File root = new File (_directory, "root");
File root = new File(_directory, "root");
FS.ensureDirExists(root);
FS.touch(new File(root, "foo.foo"));
FS.touch(new File(root, "foo2.foo"));
@ -141,7 +141,7 @@ public class ScannerTest
FS.touch(y1);
File y2 = new File(dir2, "yyy2.foo");
FS.touch(y2);
BlockingQueue<Event> queue = new LinkedBlockingQueue<Event>();
Scanner scanner = new Scanner();
scanner.setScanInterval(0);
@ -160,7 +160,7 @@ public class ScannerTest
@Override
public void fileChanged(String filename) throws Exception
{
queue.add(new Event(filename, Notification.CHANGED));
queue.add(new Event(filename, Notification.CHANGED));
}
@Override
@ -178,7 +178,7 @@ public class ScannerTest
queue.clear();
scanner.stop();
scanner.reset();
//Depth one should report the dir itself and its file and dir direct children
scanner.setScanDepth(1);
scanner.addDirectory(root.toPath());
@ -187,7 +187,7 @@ public class ScannerTest
queue.clear();
scanner.stop();
scanner.reset();
//Depth 2 should report the dir itself, all file children, xxx and xxx's children
scanner.setScanDepth(2);
scanner.addDirectory(root.toPath());
@ -203,25 +203,25 @@ public class ScannerTest
//test include and exclude patterns
File root = new File(_directory, "proot");
FS.ensureDirExists(root);
File ttt = new File(root, "ttt.txt");
FS.touch(ttt);
FS.touch(new File(root, "ttt.foo"));
File dir = new File(root, "xxx");
FS.ensureDirExists(dir);
File x1 = new File(dir, "ttt.xxx");
FS.touch(x1);
File x2 = new File(dir, "xxx.txt");
FS.touch(x2);
File dir2 = new File(dir, "yyy");
FS.ensureDirExists(dir2);
File y1 = new File(dir2, "ttt.yyy");
FS.touch(y1);
File y2 = new File(dir2, "yyy.txt");
FS.touch(y2);
BlockingQueue<Event> queue = new LinkedBlockingQueue<Event>();
//only scan the *.txt files for changes
Scanner scanner = new Scanner();
@ -252,7 +252,7 @@ public class ScannerTest
queue.add(new Event(filename, Notification.ADDED));
}
});
scanner.start();
assertTrue(queue.isEmpty());
@ -281,7 +281,7 @@ public class ScannerTest
// takes 2 scans to notice a0 and check that it is stable
_scanner.scan();
_scanner.scan();
Event event = _queue.poll();
assertNotNull(event, "Event should not be null");
assertEquals(_directory + "/a0", event._filename);

View File

@ -516,7 +516,7 @@ public class QueuedThreadPoolTest extends AbstractThreadPoolTest
{
latch.await();
}
catch(InterruptedException e)
catch (InterruptedException e)
{
e.printStackTrace();
}

View File

@ -185,15 +185,17 @@ public class AutoFragmentTest
Random rand = new Random();
ByteBuffer payload = BufferUtil.allocate(payloadSize);
BufferUtil.clearToFill(payload);
for (int i=0; i<payloadSize; i++)
for (int i = 0; i < payloadSize; i++)
{
payload.put((byte)rand.nextInt(Byte.MAX_VALUE));
}
BufferUtil.flipToFlush(payload, 0);
// Send the large random payload which should be fragmented on the server.
clientHandler.coreSession.sendFrame(new Frame(OpCode.BINARY, BufferUtil.copy(payload)), Callback.NOOP, false);
// Assemble the message from the fragmented frames.
ByteBuffer message = BufferUtil.allocate(payloadSize*2);
ByteBuffer message = BufferUtil.allocate(payloadSize * 2);
Frame frame = serverHandler.receivedFrames.poll(1, TimeUnit.SECONDS);
while (frame != null)
{
@ -240,7 +242,7 @@ public class AutoFragmentTest
clientHandler.coreSession.sendFrame(new Frame(OpCode.BINARY, BufferUtil.copy(payload)), Callback.NOOP, false);
// Assemble the message from the fragmented frames.
ByteBuffer message = BufferUtil.allocate(payload.remaining()*2);
ByteBuffer message = BufferUtil.allocate(payload.remaining() * 2);
Frame frame = serverHandler.receivedFrames.poll(1, TimeUnit.SECONDS);
while (frame != null)
{
@ -259,7 +261,6 @@ public class AutoFragmentTest
assertTrue(clientHandler.closed.await(5, TimeUnit.SECONDS));
}
@Test
public void testOutgoingAutoFragmentWithPermessageDeflate() throws Exception
{
@ -299,7 +300,7 @@ public class AutoFragmentTest
serverHandler.sendFrame(new Frame(OpCode.BINARY, sendPayload), Callback.NOOP, false);
// Assemble the message from the fragmented frames.
ByteBuffer message = BufferUtil.allocate(payload.remaining()*2);
ByteBuffer message = BufferUtil.allocate(payload.remaining() * 2);
Frame frame = clientHandler.receivedFrames.poll(1, TimeUnit.SECONDS);
int numFrames = 0;
while (frame != null)
@ -333,7 +334,7 @@ public class AutoFragmentTest
byte[] buffer = new byte[bufferSize];
while (true)
{
int compressed = deflater.deflate(buffer, 0 , bufferSize, Deflater.SYNC_FLUSH);
int compressed = deflater.deflate(buffer, 0, bufferSize, Deflater.SYNC_FLUSH);
if (compressed <= 0)
break;
out.write(buffer, 0, compressed);

View File

@ -1443,8 +1443,8 @@ public class ParserTest
String part1 = "Hello ";
String part2 = "World";
byte b1[] = part1.getBytes(StandardCharsets.UTF_8);
byte b2[] = part2.getBytes(StandardCharsets.UTF_8);
byte[] b1 = part1.getBytes(StandardCharsets.UTF_8);
byte[] b2 = part2.getBytes(StandardCharsets.UTF_8);
ByteBuffer buf = ByteBuffer.allocate(32);

View File

@ -135,7 +135,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
tester.assertNegotiated("permessage-deflate");
tester.parseIncomingHex( // context takeover (2 messages)
tester.parseIncomingHex(// context takeover (2 messages)
// message 1
"0xc1 0x07", // (HEADER added for this test)
"0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00",
@ -530,7 +530,8 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
// Captured from Pywebsocket (r790) - 3 messages with similar parts.
tester.parseIncomingHex(// context takeover (3 messages)
tester.parseIncomingHex(
// context takeover (3 messages)
"c1 09 0a c9 2f 4a 0c 01 62 00 00", // ToraTora
"c1 0b 72 2c c9 2f 4a 74 cb 01 12 00 00", // AtoraFlora
"c1 0b 0a c8 c8 c9 2f 4a 0c 01 62 00 00" // PhloraTora
@ -548,7 +549,8 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
// Captured from Pywebsocket (r790) - "tora" sent 3 times.
tester.parseIncomingHex( // context takeover (3 messages)
tester.parseIncomingHex(
// context takeover (3 messages)
"c1 06 2a c9 2f 4a 04 00", // tora 1
"c1 05 2a 01 62 00 00", // tora 2
"c1 04 02 61 00 00" // tora 3

View File

@ -103,10 +103,11 @@ public class PerMessageDeflaterBufferSizeTest
int deflateBufferSize = 6;
TestFrameHandler clientHandler = new TestFrameHandler();
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, serverUri, clientHandler);
upgradeRequest.addExtensions("permessage-deflate; @deflate_buffer_size="+deflateBufferSize);
upgradeRequest.addExtensions("permessage-deflate; @deflate_buffer_size=" + deflateBufferSize);
CompletableFuture<HttpFields> futureRequestHeaders = new CompletableFuture<>();
upgradeRequest.addListener(new UpgradeListener() {
upgradeRequest.addListener(new UpgradeListener()
{
@Override
public void onHandshakeRequest(HttpRequest request)
{
@ -156,10 +157,11 @@ public class PerMessageDeflaterBufferSizeTest
int inflateBufferSize = 6;
TestFrameHandler clientHandler = new TestFrameHandler();
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, serverUri, clientHandler);
upgradeRequest.addExtensions("permessage-deflate; @inflate_buffer_size="+inflateBufferSize);
upgradeRequest.addExtensions("permessage-deflate; @inflate_buffer_size=" + inflateBufferSize);
CompletableFuture<HttpFields> futureRequestHeaders = new CompletableFuture<>();
upgradeRequest.addListener(new UpgradeListener() {
upgradeRequest.addListener(new UpgradeListener()
{
@Override
public void onHandshakeRequest(HttpRequest request)
{
@ -213,7 +215,8 @@ public class PerMessageDeflaterBufferSizeTest
upgradeRequest.addExtensions("permessage-deflate");
CompletableFuture<HttpFields> futureResponseHeaders = new CompletableFuture<>();
upgradeRequest.addListener(new UpgradeListener() {
upgradeRequest.addListener(new UpgradeListener()
{
@Override
public void onHandshakeResponse(HttpRequest request, HttpResponse response)
{
@ -267,7 +270,8 @@ public class PerMessageDeflaterBufferSizeTest
upgradeRequest.addExtensions("permessage-deflate");
CompletableFuture<HttpFields> futureResponseHeaders = new CompletableFuture<>();
upgradeRequest.addListener(new UpgradeListener() {
upgradeRequest.addListener(new UpgradeListener()
{
@Override
public void onHandshakeResponse(HttpRequest request, HttpResponse response)
{

View File

@ -627,6 +627,7 @@ class WebSocketProxy
state = State.FAILED;
Callback doubleCallback = Callback.from(callback, closeCallback);
sendCallback = Callback.from(doubleCallback, failure);
break;
default:
state = State.FAILED;

View File

@ -48,12 +48,12 @@ public class JavaxWebSocketFrameHandler_OnCloseTest extends AbstractJavaxWebSock
CloseStatus status = new CloseStatus(CloseStatus.NORMAL, "Normal");
Frame closeFrame = status.toFrame();
localEndpoint.onFrame(closeFrame, Callback.from(() ->
{
localEndpoint.onClosed(status, Callback.NOOP);
}, t ->
{
throw new RuntimeException(t);
}));
localEndpoint.onClosed(status, Callback.NOOP),
t ->
{
throw new RuntimeException(t);
}
));
String event = socket.events.poll(10, TimeUnit.SECONDS);
assertThat("Event", event, eventMatcher);
}

View File

@ -130,7 +130,7 @@ public class JettySpecificConfigTest
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
EventSocket clientEndpoint = new ClientConfigSocket();
URI serverUri = URI.create("ws://localhost:"+ _connector.getLocalPort());
URI serverUri = URI.create("ws://localhost:" + _connector.getLocalPort());
Session session = container.connectToServer(clientEndpoint, serverUri);
// Check correct client config is set.

View File

@ -82,7 +82,7 @@ public class PathParamTest
@OnMessage
public void onMessage(String message, @PathParam("name") String name)
{
session.getAsyncRemote().sendText(message+"-"+name);
session.getAsyncRemote().sendText(message + "-" + name);
}
}
@ -92,7 +92,7 @@ public class PathParamTest
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
EventSocket clientEndpoint = new EventSocket();
URI serverUri = URI.create("ws://localhost:"+ _connector.getLocalPort()+"/pathparam/echo/myParam");
URI serverUri = URI.create("ws://localhost:" + _connector.getLocalPort() + "/pathparam/echo/myParam");
Session session = container.connectToServer(clientEndpoint, serverUri);
session.getBasicRemote().sendText("echo");

View File

@ -73,7 +73,7 @@ public class JavaxAutobahnServer
context.setContextPath("/");
server.setHandler(context);
JavaxWebSocketServletContainerInitializer.configure(context, (servletContext, container)->
JavaxWebSocketServletContainerInitializer.configure(context, (servletContext, container) ->
container.addEndpoint(JavaxAutobahnSocket.class));
server.start();

View File

@ -31,7 +31,7 @@ import javax.websocket.EndpointConfig;
*/
public class DateDecoder implements Decoder.Text<Date>
{
private TimeZone GMT = TimeZone.getTimeZone("GMT");
private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
@Override
public Date decode(String s) throws DecodeException

View File

@ -30,7 +30,7 @@ import javax.websocket.EndpointConfig;
*/
public class DateEncoder implements Encoder.Text<Date>
{
private TimeZone GMT = TimeZone.getTimeZone("GMT");
private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
@Override
public String encode(Date object) throws EncodeException

View File

@ -30,7 +30,7 @@ import javax.websocket.EndpointConfig;
*/
public class DateTimeEncoder implements Encoder.Text<Date>
{
private TimeZone GMT = TimeZone.getTimeZone("GMT");
private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
@Override
public String encode(Date object) throws EncodeException

View File

@ -30,7 +30,7 @@ import static org.hamcrest.Matchers.is;
public class DecoderTextTest
{
private TimeZone GMT = TimeZone.getTimeZone("GMT");
private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
@Test
public void testDateDecoder() throws DecodeException

View File

@ -303,20 +303,20 @@ public class ConfiguratorTest
public static class GmtTimeDecoder implements Decoder.Text<Calendar>
{
private TimeZone TZ;
private TimeZone tz;
@Override
public Calendar decode(String s) throws DecodeException
{
if (TZ == null)
if (tz == null)
throw new DecodeException(s, ".init() not called");
try
{
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
dateFormat.setTimeZone(TZ);
dateFormat.setTimeZone(tz);
Date time = dateFormat.parse(s);
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TZ);
cal.setTimeZone(tz);
cal.setTime(time);
return cal;
}
@ -329,7 +329,7 @@ public class ConfiguratorTest
@Override
public void init(EndpointConfig config)
{
TZ = TimeZone.getTimeZone("GMT+0");
tz = TimeZone.getTimeZone("GMT+0");
}
@Override
@ -351,7 +351,7 @@ public class ConfiguratorTest
decoders = {GmtTimeDecoder.class})
public static class TimeDecoderSocket
{
private TimeZone TZ = TimeZone.getTimeZone("GMT+0");
private final TimeZone tz = TimeZone.getTimeZone("GMT+0");
@OnMessage
public String onMessage(Calendar cal)
@ -362,7 +362,7 @@ public class ConfiguratorTest
private SimpleDateFormat newDateFormat()
{
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss Z", Locale.ENGLISH);
dateFormat.setTimeZone(TZ);
dateFormat.setTimeZone(tz);
return dateFormat;
}
}

View File

@ -52,8 +52,8 @@ public class WebAppClassLoaderTest
@ServerEndpoint("/echo")
public static class MySocket
{
public final static CountDownLatch closeLatch = new CountDownLatch(1);
public final static Map<String, ClassLoader> classLoaders = new ConcurrentHashMap<>();
public static final CountDownLatch closeLatch = new CountDownLatch(1);
public static final Map<String, ClassLoader> classLoaders = new ConcurrentHashMap<>();
public MySocket()
{

View File

@ -247,10 +247,10 @@ public class ClientDemo
long duration = System.currentTimeMillis() - start;
System.out.println("--- " + host + " websocket ping statistics using " + clients + " connection" + (clients > 1 ? "s" : "") + " ---");
System.out.printf("%d/%d frames sent/recv, %d/%d mesg sent/recv, time %dms %dm/s %.2fbps%n", framesSent, framesReceived.get(), messagesSent,
messagesReceived.get(), duration, ((1000L * messagesReceived.get()) / duration), (1000.0D * messagesReceived.get() * 8 * size)
/ duration / 1024 / 1024);
System.out.printf("rtt min/ave/max = %.3f/%.3f/%.3f ms\n", minDuration.get() / 1000000.0, messagesReceived.get() == 0 ? 0.0 : (totalTime.get()
/ messagesReceived.get() / 1000000.0), maxDuration.get() / 1000000.0);
messagesReceived.get(), duration, ((1000L * messagesReceived.get()) / duration),
(1000.0D * messagesReceived.get() * 8 * size) / duration / 1024 / 1024);
System.out.printf("rtt min/ave/max = %.3f/%.3f/%.3f ms\n", minDuration.get() / 1000000.0,
messagesReceived.get() == 0 ? 0.0 : (totalTime.get() / messagesReceived.get() / 1000000.0), maxDuration.get() / 1000000.0);
wsclient.stop();
}

View File

@ -85,45 +85,45 @@ public class OutgoingMessageCapture extends FrameHandler.CoreSession.Empty imple
String event = String.format("CLOSE:%s:%s", CloseStatus.codeString(closeStatus.getCode()), closeStatus.getReason());
LOG.debug(event);
events.offer(event);
break;
}
break;
case OpCode.PING:
{
String event = String.format("PING:%s", dataHint(frame.getPayload()));
LOG.debug(event);
events.offer(event);
break;
}
break;
case OpCode.PONG:
{
String event = String.format("PONG:%s", dataHint(frame.getPayload()));
LOG.debug(event);
events.offer(event);
break;
}
break;
case OpCode.TEXT:
{
String event = String.format("TEXT:fin=%b:len=%d", frame.isFin(), frame.getPayloadLength());
LOG.debug(event);
events.offer(event);
messageSink = new StringMessageSink(null, wholeTextHandle, getFakeSession());
break;
}
break;
case OpCode.BINARY:
{
String event = String.format("BINARY:fin=%b:len=%d", frame.isFin(), frame.getPayloadLength());
LOG.debug(event);
events.offer(event);
messageSink = new ByteBufferMessageSink(null, wholeBinaryHandle, getFakeSession());
break;
}
break;
case OpCode.CONTINUATION:
{
String event = String.format("CONTINUATION:fin=%b:len=%d", frame.isFin(), frame.getPayloadLength());
LOG.debug(event);
events.offer(event);
break;
}
break;
}
if (OpCode.isDataFrame(frame.getOpCode()))

View File

@ -32,7 +32,7 @@ public class AnnotatedBinaryArraySocket
public EventQueue events = new EventQueue();
@OnWebSocketMessage
public void onBinary(byte payload[], int offset, int length)
public void onBinary(byte[] payload, int offset, int length)
{
events.add("onBinary([%d],%d,%d)", payload.length, offset, length);
}

View File

@ -38,7 +38,7 @@ public class BadBinarySignatureSocket
* @return the response boolean
*/
@OnWebSocketMessage
public boolean onBinary(Session session, byte buf[], int offset, int len)
public boolean onBinary(Session session, byte[] buf, int offset, int len)
{
return false;
}

View File

@ -31,7 +31,7 @@ import org.eclipse.jetty.websocket.api.annotations.WebSocket;
public class MyEchoBinarySocket extends MyEchoSocket
{
@OnWebSocketMessage
public void echoBin(byte buf[], int offset, int length)
public void echoBin(byte[] buf, int offset, int length)
{
try
{

View File

@ -64,7 +64,8 @@ public class ConcurrentConnectTest
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
JettyWebSocketServlet servlet = new JettyWebSocketServlet() {
JettyWebSocketServlet servlet = new JettyWebSocketServlet()
{
@Override
protected void configure(JettyWebSocketServletFactory factory)
{

View File

@ -71,7 +71,7 @@ public class EventSocket
}
@OnWebSocketMessage
public void onMessage(byte buf[], int offset, int len)
public void onMessage(byte[] buf, int offset, int len)
{
ByteBuffer message = ByteBuffer.wrap(buf, offset, len);
if (LOG.isDebugEnabled())

View File

@ -244,7 +244,7 @@ public class WebSocketOverHTTP2Test
startClient(clientConnector -> new ClientConnectionFactoryOverHTTP2.H2(new HTTP2Client(clientConnector)));
EventSocket wsEndPoint = new EventSocket();
URI uri = URI.create("ws://localhost:" + (connector.getLocalPort()+1) + "/ws/echo");
URI uri = URI.create("ws://localhost:" + (connector.getLocalPort() + 1) + "/ws/echo");
ExecutionException failure = Assertions.assertThrows(ExecutionException.class, () ->
wsClient.connect(wsEndPoint, uri).get(5, TimeUnit.SECONDS));

View File

@ -73,7 +73,7 @@ public class JettyAutobahnServer
context.setContextPath("/");
server.setHandler(context);
JettyWebSocketServletContainerInitializer.configure(context, (servletContext, container)->
JettyWebSocketServletContainerInitializer.configure(context, (servletContext, container) ->
container.addMapping("/", (req, resp) -> new JettyAutobahnSocket()));
server.start();

View File

@ -32,6 +32,6 @@ public class JettyAutobahnSocket extends EchoSocket
super.onOpen(session);
session.setMaxTextMessageSize(Long.MAX_VALUE);
session.setMaxBinaryMessageSize(Long.MAX_VALUE);
session.setMaxFrameSize(WebSocketConstants.DEFAULT_MAX_FRAME_SIZE*2);
session.setMaxFrameSize(WebSocketConstants.DEFAULT_MAX_FRAME_SIZE * 2);
}
}

View File

@ -31,7 +31,7 @@ import org.eclipse.jetty.websocket.api.annotations.WebSocket;
public class MyBinaryEchoSocket
{
@OnWebSocketMessage
public void onWebSocketText(Session session, byte buf[], int offset, int len)
public void onWebSocketText(Session session, byte[] buf, int offset, int len)
{
// Echo message back, asynchronously
session.getRemote().sendBytes(ByteBuffer.wrap(buf, offset, len), null);

57
pom.xml
View File

@ -418,6 +418,40 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<configLocation>jetty-checkstyle.xml</configLocation>
<suppressionsLocation>jetty-suppressions.xml</suppressionsLocation>
<suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<violationSeverity>warning</violationSeverity>
<consoleOutput>true</consoleOutput>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>build-resources</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.20</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>checkcheck</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
@ -439,29 +473,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<configLocation>jetty-checkstyle.xml</configLocation>
<suppressionsLocation>jetty-suppressions.xml</suppressionsLocation>
<suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>build-resources</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.20</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>

View File

@ -502,7 +502,7 @@ public class AsyncIOServletTest extends AbstractTest<AsyncIOServletTest.AsyncTra
Thread.sleep(50);
listener.onWritePossible();
}
catch(Exception ignored)
catch (Exception ignored)
{
// no op
}

View File

@ -176,14 +176,15 @@ public class JdbcTestHelper
statement = con.prepareStatement(
"select * from " + TABLE +
" where " + ID_COL + " = ? and " + CONTEXT_COL +
" = ? and virtualHost = ?" );
" = ? and virtualHost = ?");
statement.setString(1, data.getId());
statement.setString(2, data.getContextPath());
statement.setString(3, data.getVhost());
result = statement.executeQuery();
if (!result.next()) return false;
if (!result.next())
return false;
assertEquals(data.getCreated(), result.getLong(CREATE_COL));
assertEquals(data.getAccessed(), result.getLong(ACCESS_COL));
@ -200,9 +201,9 @@ public class JdbcTestHelper
Blob blob = result.getBlob(MAP_COL);
SessionData tmp =
new SessionData( data.getId(), data.getContextPath(), data.getVhost(), result.getLong(CREATE_COL),
result.getLong(ACCESS_COL), result.getLong(LAST_ACCESS_COL),
result.getLong(MAX_IDLE_COL));
new SessionData(data.getId(), data.getContextPath(), data.getVhost(), result.getLong(CREATE_COL),
result.getLong(ACCESS_COL), result.getLong(LAST_ACCESS_COL),
result.getLong(MAX_IDLE_COL));
if (blob.length() > 0)
{