diff options
Diffstat (limited to 'jetty-util/src/main')
3 files changed, 78 insertions, 4 deletions
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java index 85ee7a6327..198e9e747a 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java @@ -84,7 +84,7 @@ import java.nio.charset.Charset; */ public class BufferUtil { - static final int TEMP_BUFFER_SIZE = 512; + static final int TEMP_BUFFER_SIZE = 4096; static final byte SPACE = 0x20; static final byte MINUS = '-'; static final byte[] DIGIT = diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/StacklessLogging.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StacklessLogging.java new file mode 100644 index 0000000000..8d7f2ebbe5 --- /dev/null +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StacklessLogging.java @@ -0,0 +1,69 @@ +// +// ======================================================================== +// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.util.log; + +/** + * A try-with-resources compatible layer for {@link StdErrLog#setHideStacks(boolean) hiding stacktraces} within the scope of the <code>try</code> block when + * logging with {@link StdErrLog} implementation. + * <p> + * Use of other logging implementation cause no effect when using this class + * <p> + * Example: + * + * <pre> + * try (StacklessLogging scope = new StacklessLogging(EventDriver.class,Noisy.class)) + * { + * doActionThatCausesStackTraces(); + * } + * </pre> + */ +public class StacklessLogging implements AutoCloseable +{ + private final Class<?> clazzes[]; + + public StacklessLogging(Class<?>... classesToSquelch) + { + this.clazzes = classesToSquelch; + hideStacks(true); + } + + @Override + public void close() throws Exception + { + hideStacks(false); + } + + private void hideStacks(boolean hide) + { + for (Class<?> clazz : clazzes) + { + Logger log = Log.getLogger(clazz); + if (log == null) + { + // not interested in classes without loggers + continue; + } + if (log instanceof StdErrLog) + { + // only operate on loggers that are of type StdErrLog + ((StdErrLog)log).setHideStacks(hide); + } + } + } +} diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java index 6aa32877ea..0febc2423d 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java @@ -157,9 +157,9 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo int size = _threads.size(); if (size > 0) { - LOG.warn("{} threads could not be stopped", size); - - if ((size <= Runtime.getRuntime().availableProcessors()) || LOG.isDebugEnabled()) + Thread.yield(); + + if (LOG.isDebugEnabled()) { for (Thread unstopped : _threads) { @@ -171,6 +171,11 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo LOG.warn("Couldn't stop {}{}", unstopped, dmp.toString()); } } + else + { + for (Thread unstopped : _threads) + LOG.warn("{} Couldn't stop {}",this,unstopped); + } } synchronized (_joinLock) |