Merged branch 'jetty-10.0.x' into 'jetty-10.0.x-4400-review_httpclient_content'.

This commit is contained in:
Simone Bordet 2020-03-18 11:40:11 +01:00
commit f8d9f82eff
1060 changed files with 11975 additions and 10313 deletions

View File

@ -355,6 +355,40 @@ jetty-10.0.0-alpha0 - 11 July 2019
+ 3849 ClosedChannelException from jetty-test-webapp javax websocket chat + 3849 ClosedChannelException from jetty-test-webapp javax websocket chat
example example
jetty-9.4.27.v20200227 - 27 February 2020
+ 3247 Generate jetty-maven-plugin website
+ 4247 Cookie security attributes are going to mandated by Google Chrome
+ 4360 Upgrade to Apache Jasper 8.5.49
+ 4475 WebSocket JSR356 implementation not honoring javadoc of MessageHandler
on Whole<Reader>
+ 4495 Review ReservedThreadExecutor's concurrency model
+ 4504 X-Forwarded-Server header overwrites X-Forwarded-Host
+ 4520 Jetty jdbc session manager causing exceptions for violating primary key
in inserting session in the table
+ 4529 ErrorHandler showing servlet info, can not be disabled unless
overriding most of its functionality
+ 4533 Reinstate hard close in dispatcher
+ 4537 High CPU on Jetty Websocket thread
+ 4541 Jetty server always allocates maximum response header size
+ 4550 XmlConfiguration constructor selection based on number of arguments
+ 4567 Jetty logging supporting Throwable as last argument
+ 4573 Order dependency of X-Forwarded-Host and X-Forwarded-Port
+ 4575 Stopping ReservedThreadExecutor may hang
+ 4577 request getPathInfo returns null
+ 4594 ServletContextListeners added to destroyServletContextListeners in
ContextHandler::startContext() are not removed by
ContextHandler::removeEventListener()
+ 4606 DateCache.formatNow(long now) does not honor the passed in long
+ 4612 ReservedThreadExecutor hangs when the last reserved thread idles out
jetty-9.4.26.v20200117 - 17 January 2020
+ 2620 Exception from user endpoint onClose results in unclosed
WebSocketSession
+ 4383 Errors deleting multipart tmp files java.lang.NullPointerException
under heavy load
+ 4444 TLS Connection Timeout Intermittently
+ 4461 IllegalStateException in HttpOutput with Jersey
jetty-9.4.25.v20191220 - 20 December 2019 jetty-9.4.25.v20191220 - 20 December 2019
+ 995 UrlEncoded.encodeString should skip more characters + 995 UrlEncoded.encodeString should skip more characters
+ 2195 Add parameter expansion to start.jar --exec parameters + 2195 Add parameter expansion to start.jar --exec parameters

View File

@ -63,6 +63,10 @@
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId> <artifactId>jetty-util</artifactId>
@ -81,6 +85,10 @@
<artifactId>jetty-annotations</artifactId> <artifactId>jetty-annotations</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
@ -101,6 +109,12 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.toolchain</groupId> <groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId> <artifactId>jetty-test-helper</artifactId>

View File

@ -31,6 +31,7 @@ module org.eclipse.jetty.apache.jsp
requires jetty.servlet.api; requires jetty.servlet.api;
requires org.eclipse.jetty.util; requires org.eclipse.jetty.util;
requires org.mortbay.apache.jasper; requires org.mortbay.apache.jasper;
requires org.slf4j;
provides Log with JuliLog; provides Log with JuliLog;
provides ServletContainerInitializer with JettyJasperInitializer; provides ServletContainerInitializer with JettyJasperInitializer;

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.apache.jsp; package org.eclipse.jetty.apache.jsp;
import org.slf4j.LoggerFactory;
public class JuliLog implements org.apache.juli.logging.Log public class JuliLog implements org.apache.juli.logging.Log
{ {
public static org.apache.juli.logging.Log getInstance(String name) public static org.apache.juli.logging.Log getInstance(String name)
@ -25,19 +27,16 @@ public class JuliLog implements org.apache.juli.logging.Log
return new JuliLog(name); return new JuliLog(name);
} }
private final org.eclipse.jetty.util.log.Logger _logger; private final org.slf4j.Logger _logger;
private final org.eclipse.jetty.util.log.StdErrLog _stdErrLog;
public JuliLog() public JuliLog()
{ {
_logger = org.eclipse.jetty.util.log.Log.getRootLogger(); _logger = LoggerFactory.getLogger("");
_stdErrLog = (_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger : null;
} }
public JuliLog(String name) public JuliLog(String name)
{ {
_logger = org.eclipse.jetty.util.log.Log.getLogger(name); _logger = LoggerFactory.getLogger(name);
_stdErrLog = (_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger : null;
} }
@Override @Override
@ -49,31 +48,31 @@ public class JuliLog implements org.apache.juli.logging.Log
@Override @Override
public boolean isErrorEnabled() public boolean isErrorEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN; return _logger.isErrorEnabled();
} }
@Override @Override
public boolean isFatalEnabled() public boolean isFatalEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN; return _logger.isErrorEnabled();
} }
@Override @Override
public boolean isInfoEnabled() public boolean isInfoEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_INFO; return _logger.isInfoEnabled();
} }
@Override @Override
public boolean isTraceEnabled() public boolean isTraceEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_DEBUG; return _logger.isTraceEnabled();
} }
@Override @Override
public boolean isWarnEnabled() public boolean isWarnEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN; return _logger.isWarnEnabled();
} }
@Override @Override

View File

@ -1,3 +1,3 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog # Jetty Logging using jetty-slf4j-impl
# org.eclipse.jetty.LEVEL=INFO # org.eclipse.jetty.LEVEL=INFO
# org.eclipse.jetty.util.LEVEL=DEBUG # org.eclipse.jetty.util.LEVEL=DEBUG

View File

@ -15,6 +15,14 @@
<bundle-symbolic-name>${project.groupId}.embedded</bundle-symbolic-name> <bundle-symbolic-name>${project.groupId}.embedded</bundle-symbolic-name>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util-ajax</artifactId> <artifactId>jetty-util-ajax</artifactId>

View File

@ -23,8 +23,8 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* A utility test class to locate a Jetty Distribution for testing purposes by searching: * A utility test class to locate a Jetty Distribution for testing purposes by searching:
@ -36,7 +36,7 @@ import org.eclipse.jetty.util.log.Logger;
*/ */
public class JettyDistribution public class JettyDistribution
{ {
private static final Logger LOG = Log.getLogger(JettyDistribution.class); private static final Logger LOG = LoggerFactory.getLogger(JettyDistribution.class);
public static final Path DISTRIBUTION; public static final Path DISTRIBUTION;
static static
@ -64,7 +64,7 @@ public class JettyDistribution
} }
catch (Throwable th) catch (Throwable th)
{ {
LOG.warn(th); LOG.warn("Unable to resolve Jetty Distribution location", th);
} }
} }
@ -119,7 +119,7 @@ public class JettyDistribution
} }
catch (Exception e) catch (Exception e)
{ {
LOG.ignore(e); LOG.trace("IGNORED", e);
} }
return null; return null;
} }

View File

@ -1,4 +1,4 @@
#org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog ## Jetty Logging using jetty-slf4j-impl
#org.eclipse.jetty.util.log.javautil.PROPERTIES=java-util-logging.properties #org.eclipse.jetty.util.log.javautil.PROPERTIES=java-util-logging.properties
#org.eclipse.jetty.util.log.SOURCE=true #org.eclipse.jetty.util.log.SOURCE=true
#org.eclipse.jetty.LEVEL=INFO #org.eclipse.jetty.LEVEL=INFO

View File

@ -25,8 +25,6 @@ import java.util.concurrent.LinkedBlockingQueue;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError;
@ -37,6 +35,8 @@ import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
@ -87,7 +87,7 @@ public class WebSocketServerTest
@WebSocket @WebSocket
public static class TrackingClientEndpoint public static class TrackingClientEndpoint
{ {
private static final Logger LOG = Log.getLogger(TrackingClientEndpoint.class); private static final Logger LOG = LoggerFactory.getLogger(TrackingClientEndpoint.class);
public LinkedBlockingQueue<String> messages = new LinkedBlockingQueue<>(); public LinkedBlockingQueue<String> messages = new LinkedBlockingQueue<>();
@OnWebSocketMessage @OnWebSocketMessage
@ -99,7 +99,7 @@ public class WebSocketServerTest
@OnWebSocketError @OnWebSocketError
public void onError(Throwable cause) public void onError(Throwable cause)
{ {
LOG.warn(cause); LOG.warn("TrackingClientEndpoint Error", cause);
} }
@OnWebSocketClose @OnWebSocketClose

View File

@ -1,4 +1,4 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog # Jetty Logging using jetty-slf4j-impl
org.eclipse.jetty.LEVEL=INFO org.eclipse.jetty.LEVEL=INFO
org.eclipse.jetty.embedded.JettyDistribution.LEVEL=DEBUG org.eclipse.jetty.embedded.JettyDistribution.LEVEL=DEBUG
#org.eclipse.jetty.STACKS=true #org.eclipse.jetty.STACKS=true

View File

@ -51,6 +51,16 @@
<artifactId>jetty-io</artifactId> <artifactId>jetty-io</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.toolchain</groupId> <groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId> <artifactId>jetty-test-helper</artifactId>

View File

@ -23,6 +23,7 @@ module org.eclipse.jetty.alpn.client
exports org.eclipse.jetty.alpn.client; exports org.eclipse.jetty.alpn.client;
requires transitive org.eclipse.jetty.io; requires transitive org.eclipse.jetty.io;
requires org.slf4j;
uses ALPNProcessor.Client; uses ALPNProcessor.Client;
} }

View File

@ -32,12 +32,12 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.NegotiatingClientConnectionFactory; import org.eclipse.jetty.io.NegotiatingClientConnectionFactory;
import org.eclipse.jetty.io.ssl.ALPNProcessor.Client; import org.eclipse.jetty.io.ssl.ALPNProcessor.Client;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory; import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class ALPNClientConnectionFactory extends NegotiatingClientConnectionFactory public class ALPNClientConnectionFactory extends NegotiatingClientConnectionFactory
{ {
private static final Logger LOG = Log.getLogger(ALPNClientConnectionFactory.class); private static final Logger LOG = LoggerFactory.getLogger(ALPNClientConnectionFactory.class);
private final List<Client> processors = new ArrayList<>(); private final List<Client> processors = new ArrayList<>();
private final Executor executor; private final Executor executor;
@ -64,7 +64,7 @@ public class ALPNClientConnectionFactory extends NegotiatingClientConnectionFact
catch (Throwable x) catch (Throwable x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug(x); LOG.debug("Unable to load client processor", x);
failure.addSuppressed(x); failure.addSuppressed(x);
continue; continue;
} }

View File

@ -26,12 +26,23 @@
<artifactId>jetty-alpn-client</artifactId> <artifactId>jetty-alpn-client</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.http2</groupId> <groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-client</artifactId> <artifactId>http2-client</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>

View File

@ -23,6 +23,7 @@ module org.eclipse.jetty.alpn.conscrypt.client
{ {
requires org.conscrypt; requires org.conscrypt;
requires transitive org.eclipse.jetty.alpn.client; requires transitive org.eclipse.jetty.alpn.client;
requires org.slf4j;
provides ALPNProcessor.Client with ConscryptClientALPNProcessor; provides ALPNProcessor.Client with ConscryptClientALPNProcessor;
} }

View File

@ -28,12 +28,12 @@ import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ssl.ALPNProcessor; import org.eclipse.jetty.io.ssl.ALPNProcessor;
import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.io.ssl.SslHandshakeListener; import org.eclipse.jetty.io.ssl.SslHandshakeListener;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class ConscryptClientALPNProcessor implements ALPNProcessor.Client public class ConscryptClientALPNProcessor implements ALPNProcessor.Client
{ {
private static final Logger LOG = Log.getLogger(ConscryptClientALPNProcessor.class); private static final Logger LOG = LoggerFactory.getLogger(ConscryptClientALPNProcessor.class);
@Override @Override
public void init() public void init()
@ -95,8 +95,8 @@ public class ConscryptClientALPNProcessor implements ALPNProcessor.Client
} }
catch (Throwable e) catch (Throwable e)
{ {
LOG.warn("Unable to process Conscrypt ApplicationProtocol for {}", alpnConnection, e);
alpnConnection.selected(null); alpnConnection.selected(null);
LOG.warn(e);
} }
} }
} }

View File

@ -1,2 +1,2 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog # Jetty Logging using jetty-slf4j-impl
#org.eclipse.jetty.LEVEL=DEBUG #org.eclipse.jetty.LEVEL=DEBUG

View File

@ -22,6 +22,7 @@ import org.eclipse.jetty.io.ssl.ALPNProcessor;
module org.eclipse.jetty.alpn.conscrypt.server module org.eclipse.jetty.alpn.conscrypt.server
{ {
requires org.conscrypt; requires org.conscrypt;
requires org.slf4j;
requires transitive org.eclipse.jetty.alpn.server; requires transitive org.eclipse.jetty.alpn.server;
provides ALPNProcessor.Server with ConscryptServerALPNProcessor; provides ALPNProcessor.Server with ConscryptServerALPNProcessor;

View File

@ -31,12 +31,12 @@ import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ssl.ALPNProcessor; import org.eclipse.jetty.io.ssl.ALPNProcessor;
import org.eclipse.jetty.io.ssl.SslConnection.DecryptedEndPoint; import org.eclipse.jetty.io.ssl.SslConnection.DecryptedEndPoint;
import org.eclipse.jetty.io.ssl.SslHandshakeListener; import org.eclipse.jetty.io.ssl.SslHandshakeListener;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class ConscryptServerALPNProcessor implements ALPNProcessor.Server public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
{ {
private static final Logger LOG = Log.getLogger(ConscryptServerALPNProcessor.class); private static final Logger LOG = LoggerFactory.getLogger(ConscryptServerALPNProcessor.class);
@Override @Override
public void init() public void init()

View File

@ -1,3 +1,3 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog # Jetty Logging using jetty-slf4j-impl
#org.eclipse.jetty.LEVEL=DEBUG #org.eclipse.jetty.LEVEL=DEBUG
#org.eclipse.jetty.alpn.LEVEL=DEBUG #org.eclipse.jetty.alpn.LEVEL=DEBUG

View File

@ -40,6 +40,10 @@
<artifactId>jetty-alpn-client</artifactId> <artifactId>jetty-alpn-client</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.http2</groupId> <groupId>org.eclipse.jetty.http2</groupId>
@ -47,6 +51,12 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -22,6 +22,7 @@ import org.eclipse.jetty.io.ssl.ALPNProcessor;
module org.eclipse.jetty.alpn.java.client module org.eclipse.jetty.alpn.java.client
{ {
requires transitive org.eclipse.jetty.alpn.client; requires transitive org.eclipse.jetty.alpn.client;
requires org.slf4j;
provides ALPNProcessor.Client with JDK9ClientALPNProcessor; provides ALPNProcessor.Client with JDK9ClientALPNProcessor;
} }

View File

@ -28,12 +28,12 @@ import org.eclipse.jetty.io.ssl.ALPNProcessor;
import org.eclipse.jetty.io.ssl.SslConnection.DecryptedEndPoint; import org.eclipse.jetty.io.ssl.SslConnection.DecryptedEndPoint;
import org.eclipse.jetty.io.ssl.SslHandshakeListener; import org.eclipse.jetty.io.ssl.SslHandshakeListener;
import org.eclipse.jetty.util.JavaVersion; import org.eclipse.jetty.util.JavaVersion;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class JDK9ClientALPNProcessor implements ALPNProcessor.Client public class JDK9ClientALPNProcessor implements ALPNProcessor.Client
{ {
private static final Logger LOG = Log.getLogger(JDK9ClientALPNProcessor.class); private static final Logger LOG = LoggerFactory.getLogger(JDK9ClientALPNProcessor.class);
@Override @Override
public void init() public void init()

View File

@ -1,2 +1,2 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog # Jetty Logging using jetty-slf4j-impl
#org.eclipse.jetty.LEVEL=DEBUG #org.eclipse.jetty.LEVEL=DEBUG

View File

@ -21,6 +21,7 @@ import org.eclipse.jetty.io.ssl.ALPNProcessor;
module org.eclipse.jetty.alpn.java.server module org.eclipse.jetty.alpn.java.server
{ {
requires org.slf4j;
requires transitive org.eclipse.jetty.alpn.server; requires transitive org.eclipse.jetty.alpn.server;
provides ALPNProcessor.Server with JDK9ServerALPNProcessor; provides ALPNProcessor.Server with JDK9ServerALPNProcessor;

View File

@ -28,12 +28,12 @@ import org.eclipse.jetty.io.ssl.ALPNProcessor;
import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.io.ssl.SslHandshakeListener; import org.eclipse.jetty.io.ssl.SslHandshakeListener;
import org.eclipse.jetty.util.JavaVersion; import org.eclipse.jetty.util.JavaVersion;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class JDK9ServerALPNProcessor implements ALPNProcessor.Server, SslHandshakeListener public class JDK9ServerALPNProcessor implements ALPNProcessor.Server, SslHandshakeListener
{ {
private static final Logger LOG = Log.getLogger(JDK9ServerALPNProcessor.class); private static final Logger LOG = LoggerFactory.getLogger(JDK9ServerALPNProcessor.class);
@Override @Override
public void init() public void init()

View File

@ -1,3 +1,3 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog # Jetty Logging using jetty-slf4j-impl
#org.eclipse.jetty.LEVEL=DEBUG #org.eclipse.jetty.LEVEL=DEBUG
#org.eclipse.jetty.alpn.LEVEL=DEBUG #org.eclipse.jetty.alpn.LEVEL=DEBUG

View File

@ -0,0 +1,4 @@
DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html
[depend]
alpn-impl/alpn-11

View File

@ -23,6 +23,7 @@ module org.eclipse.jetty.alpn.server
exports org.eclipse.jetty.alpn.server; exports org.eclipse.jetty.alpn.server;
requires transitive org.eclipse.jetty.server; requires transitive org.eclipse.jetty.server;
requires org.slf4j;
uses ALPNProcessor.Server; uses ALPNProcessor.Server;
} }

View File

@ -27,12 +27,12 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.ConnectionFactory; import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.NegotiatingServerConnection; import org.eclipse.jetty.server.NegotiatingServerConnection;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class ALPNServerConnection extends NegotiatingServerConnection public class ALPNServerConnection extends NegotiatingServerConnection
{ {
private static final Logger LOG = Log.getLogger(ALPNServerConnection.class); private static final Logger LOG = LoggerFactory.getLogger(ALPNServerConnection.class);
public ALPNServerConnection(Connector connector, EndPoint endPoint, SSLEngine engine, List<String> protocols, String defaultProtocol) public ALPNServerConnection(Connector connector, EndPoint endPoint, SSLEngine engine, List<String> protocols, String defaultProtocol)
{ {

View File

@ -31,12 +31,12 @@ import org.eclipse.jetty.io.ssl.ALPNProcessor.Server;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.NegotiatingServerConnectionFactory; import org.eclipse.jetty.server.NegotiatingServerConnectionFactory;
import org.eclipse.jetty.util.annotation.Name; import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFactory public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFactory
{ {
private static final Logger LOG = Log.getLogger(ALPNServerConnectionFactory.class); private static final Logger LOG = LoggerFactory.getLogger(ALPNServerConnectionFactory.class);
private final List<Server> processors = new ArrayList<>(); private final List<Server> processors = new ArrayList<>();
@ -61,7 +61,7 @@ public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFact
catch (Throwable x) catch (Throwable x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug(x); LOG.debug(x.getMessage(), x);
if (x != failure) if (x != failure)
failure.addSuppressed(x); failure.addSuppressed(x);
continue; continue;
@ -75,7 +75,7 @@ public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFact
catch (Throwable x) catch (Throwable x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("Could not initialize " + processor, x); LOG.debug("Could not initialize {}", processor, x);
if (x != failure) if (x != failure)
failure.addSuppressed(x); failure.addSuppressed(x);
} }

View File

@ -29,6 +29,7 @@ module org.eclipse.jetty.annotations
requires java.naming; requires java.naming;
requires transitive org.eclipse.jetty.plus; requires transitive org.eclipse.jetty.plus;
requires transitive org.objectweb.asm; requires transitive org.objectweb.asm;
requires org.slf4j;
uses ServletContainerInitializer; uses ServletContainerInitializer;

View File

@ -50,26 +50,25 @@ import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.util.ProcessorUtils; import org.eclipse.jetty.util.ProcessorUtils;
import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.statistic.CounterStatistic; import org.eclipse.jetty.util.statistic.CounterStatistic;
import org.eclipse.jetty.webapp.AbstractConfiguration; import org.eclipse.jetty.webapp.AbstractConfiguration;
import org.eclipse.jetty.webapp.FragmentConfiguration; import org.eclipse.jetty.webapp.FragmentConfiguration;
import org.eclipse.jetty.webapp.FragmentDescriptor; import org.eclipse.jetty.webapp.FragmentDescriptor;
import org.eclipse.jetty.webapp.JettyWebXmlConfiguration; import org.eclipse.jetty.webapp.JettyWebXmlConfiguration;
import org.eclipse.jetty.webapp.MetaDataComplete;
import org.eclipse.jetty.webapp.MetaInfConfiguration; import org.eclipse.jetty.webapp.MetaInfConfiguration;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebDescriptor; import org.eclipse.jetty.webapp.WebDescriptor;
import org.eclipse.jetty.webapp.WebXmlConfiguration; import org.eclipse.jetty.webapp.WebXmlConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Configuration for Annotations * Configuration for Annotations
*/ */
public class AnnotationConfiguration extends AbstractConfiguration public class AnnotationConfiguration extends AbstractConfiguration
{ {
private static final Logger LOG = Log.getLogger(AnnotationConfiguration.class); private static final Logger LOG = LoggerFactory.getLogger(AnnotationConfiguration.class);
public static final String SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN = "org.eclipse.jetty.containerInitializerExclusionPattern"; public static final String SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN = "org.eclipse.jetty.containerInitializerExclusionPattern";
public static final String SERVLET_CONTAINER_INITIALIZER_ORDER = "org.eclipse.jetty.containerInitializerOrder"; public static final String SERVLET_CONTAINER_INITIALIZER_ORDER = "org.eclipse.jetty.containerInitializerOrder";
@ -335,11 +334,13 @@ public class AnnotationConfiguration extends AbstractConfiguration
@Override @Override
public void configure(WebAppContext context) throws Exception public void configure(WebAppContext context) throws Exception
{ {
//handle introspectable annotations (postconstruct,predestroy, multipart etc etc)
context.getObjectFactory().addDecorator(new AnnotationDecorator(context)); context.getObjectFactory().addDecorator(new AnnotationDecorator(context));
if (!context.getMetaData().isMetaDataComplete()) if (!context.getMetaData().isMetaDataComplete())
{ {
//If metadata isn't complete, if this is a servlet 3 webapp or isConfigDiscovered is true, we need to search for annotations //If web.xml not metadata-complete, if this is a servlet 3 webapp or above
//or configDiscovered is true, we need to search for annotations
if (context.getServletContext().getEffectiveMajorVersion() >= 3 || context.isConfigurationDiscovered()) if (context.getServletContext().getEffectiveMajorVersion() >= 3 || context.isConfigurationDiscovered())
{ {
_discoverableAnnotationHandlers.add(new WebServletAnnotationHandler(context)); _discoverableAnnotationHandlers.add(new WebServletAnnotationHandler(context));
@ -408,7 +409,8 @@ public class AnnotationConfiguration extends AbstractConfiguration
} }
/** /**
* Perform scanning of classes for annotations * Perform scanning of classes for discoverable
* annotations such as WebServlet/WebFilter/WebListener
* *
* @param context the context for the scan * @param context the context for the scan
* @throws Exception if unable to scan * @throws Exception if unable to scan
@ -431,6 +433,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
isUseMultiThreading(context), isUseMultiThreading(context),
getMaxScanWait(context)); getMaxScanWait(context));
//scan selected jars on the container classpath first
parseContainerPath(context, parser); parseContainerPath(context, parser);
//email from Rajiv Mordani jsrs 315 7 April 2010 //email from Rajiv Mordani jsrs 315 7 April 2010
// If there is a <others/> then the ordering should be // If there is a <others/> then the ordering should be
@ -438,6 +441,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
// In case there is no others then it is // In case there is no others then it is
// WEB-INF/classes + order of the elements. // WEB-INF/classes + order of the elements.
parseWebInfClasses(context, parser); parseWebInfClasses(context, parser);
//scan non-excluded, non medatadata-complete jars in web-inf lib
parseWebInfLib(context, parser); parseWebInfLib(context, parser);
long start = System.nanoTime(); long start = System.nanoTime();
@ -691,14 +695,14 @@ public class AnnotationConfiguration extends AbstractConfiguration
} }
//If no ordering, nothing is excluded //If no ordering, nothing is excluded
if (context.getMetaData().getOrdering() == null) if (!context.getMetaData().isOrdered())
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("!Excluded {} no ordering", sci); LOG.debug("!Excluded {} no ordering", sci);
return false; return false;
} }
List<Resource> orderedJars = context.getMetaData().getOrderedWebInfJars(); List<Resource> orderedJars = context.getMetaData().getWebInfResources(true);
//there is an ordering, but there are no jars resulting from the ordering, everything excluded //there is an ordering, but there are no jars resulting from the ordering, everything excluded
if (orderedJars.isEmpty()) if (orderedJars.isEmpty())
@ -710,17 +714,17 @@ public class AnnotationConfiguration extends AbstractConfiguration
//Check if it is excluded by an ordering //Check if it is excluded by an ordering
URI loadingJarURI = sciResource.getURI(); URI loadingJarURI = sciResource.getURI();
boolean found = false; boolean included = false;
Iterator<Resource> itor = orderedJars.iterator(); for (Resource r : orderedJars)
while (!found && itor.hasNext())
{ {
Resource r = itor.next(); included = r.getURI().equals(loadingJarURI);
found = r.getURI().equals(loadingJarURI); if (included)
break;
} }
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("{}Excluded {} found={}", found ? "!" : "", sci, found); LOG.debug("{}Excluded {} found={}", included ? "!" : "", sci, included);
return !found; return !included;
} }
/** /**
@ -785,7 +789,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
*/ */
public boolean isFromWebInfClasses(WebAppContext context, Resource sci) public boolean isFromWebInfClasses(WebAppContext context, Resource sci)
{ {
for (Resource dir : context.getMetaData().getWebInfClassesDirs()) for (Resource dir : context.getMetaData().getWebInfClassesResources())
{ {
if (dir.equals(sci)) if (dir.equals(sci))
{ {
@ -831,8 +835,10 @@ public class AnnotationConfiguration extends AbstractConfiguration
catch (Error e) catch (Error e)
{ {
// Probably a SCI discovered on the system classpath that is hidden by the context classloader // Probably a SCI discovered on the system classpath that is hidden by the context classloader
LOG.info("Error: " + e.getMessage() + " for " + context); if (LOG.isDebugEnabled())
LOG.debug(e); LOG.debug("Error: {} for {}", e.getMessage(), context, e);
else
LOG.info("Error: {} for {}", e.getMessage(), context);
continue; continue;
} }
@ -867,7 +873,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
if (initializerOrdering != null && !initializerOrdering.isDefaultOrder()) if (initializerOrdering != null && !initializerOrdering.isDefaultOrder())
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("Ordering ServletContainerInitializers with " + initializerOrdering); LOG.debug("Ordering ServletContainerInitializers with {}", initializerOrdering);
//There is an ordering that is not just "*". //There is an ordering that is not just "*".
//Arrange ServletContainerInitializers according to the ordering of classnames given, irrespective of coming from container or webapp classpaths //Arrange ServletContainerInitializers according to the ordering of classnames given, irrespective of coming from container or webapp classpaths
@ -894,7 +900,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
} }
else else
{ {
for (Resource dir : context.getMetaData().getWebInfClassesDirs()) for (Resource dir : context.getMetaData().getWebInfClassesResources())
{ {
if (dir.equals(entry.getValue()))//from WEB-INF/classes so can't be ordered/excluded if (dir.equals(entry.getValue()))//from WEB-INF/classes so can't be ordered/excluded
{ {
@ -923,7 +929,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
LOG.debug("Ordering ServletContainerInitializers with ordering {}", context.getMetaData().getOrdering()); LOG.debug("Ordering ServletContainerInitializers with ordering {}", context.getMetaData().getOrdering());
//add SCIs according to the ordering of its containing jar //add SCIs according to the ordering of its containing jar
for (Resource webInfJar : context.getMetaData().getOrderedWebInfJars()) for (Resource webInfJar : context.getMetaData().getWebInfResources(true))
{ {
for (Map.Entry<ServletContainerInitializer, Resource> entry : sciResourceMap.entrySet()) for (Map.Entry<ServletContainerInitializer, Resource> entry : sciResourceMap.entrySet())
{ {
@ -977,7 +983,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
return null; return null;
String tmp = (String)context.getAttribute(SERVLET_CONTAINER_INITIALIZER_ORDER); String tmp = (String)context.getAttribute(SERVLET_CONTAINER_INITIALIZER_ORDER);
if (tmp == null || "".equals(tmp.trim())) if (StringUtil.isBlank(tmp))
return null; return null;
return new ServletContainerInitializerOrdering(tmp); return new ServletContainerInitializerOrdering(tmp);
@ -1002,9 +1008,10 @@ public class AnnotationConfiguration extends AbstractConfiguration
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
_containerPathStats = new CounterStatistic(); _containerPathStats = new CounterStatistic();
//scan the container classpath jars that were selected by
//filtering in MetaInfConfiguration
for (Resource r : context.getMetaData().getContainerResources()) for (Resource r : context.getMetaData().getContainerResources())
{ {
//queue it up for scanning if using multithreaded mode
if (_parserTasks != null) if (_parserTasks != null)
{ {
ParserTask task = new ParserTask(parser, handlers, r); ParserTask task = new ParserTask(parser, handlers, r);
@ -1019,7 +1026,10 @@ public class AnnotationConfiguration extends AbstractConfiguration
} }
/** /**
* Scan jars in WEB-INF/lib * Scan jars in WEB-INF/lib.
*
* Only jars selected by MetaInfConfiguration, and that are not excluded
* by an ordering will be considered.
* *
* @param context the context for the scan * @param context the context for the scan
* @param parser the annotation parser to use * @param parser the annotation parser to use
@ -1027,20 +1037,13 @@ public class AnnotationConfiguration extends AbstractConfiguration
*/ */
public void parseWebInfLib(final WebAppContext context, final AnnotationParser parser) throws Exception public void parseWebInfLib(final WebAppContext context, final AnnotationParser parser) throws Exception
{ {
List<FragmentDescriptor> frags = context.getMetaData().getFragments();
//email from Rajiv Mordani jsrs 315 7 April 2010 //email from Rajiv Mordani jsrs 315 7 April 2010
//jars that do not have a web-fragment.xml are still considered fragments //jars that do not have a web-fragment.xml are still considered fragments
//they have to participate in the ordering //they have to participate in the ordering
ArrayList<URI> webInfUris = new ArrayList<URI>();
List<Resource> jars = null; //if there is an ordering, the ordered jars should be used.
//If there is no ordering, jars will be unordered.
if (context.getMetaData().getOrdering() != null) List<Resource> jars = context.getMetaData().getWebInfResources(context.getMetaData().isOrdered());
jars = context.getMetaData().getOrderedWebInfJars();
else
//No ordering just use the jars in any order
jars = context.getMetaData().getWebInfJars();
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{ {
@ -1053,13 +1056,13 @@ public class AnnotationConfiguration extends AbstractConfiguration
//for each jar, we decide which set of annotations we need to parse for //for each jar, we decide which set of annotations we need to parse for
final Set<Handler> handlers = new HashSet<Handler>(); final Set<Handler> handlers = new HashSet<Handler>();
FragmentDescriptor f = getFragmentFromJar(r, frags); FragmentDescriptor f = context.getMetaData().getFragmentDescriptorForJar(r);
//if its from a fragment jar that is metadata complete, we should skip scanning for @webservlet etc //if its from a fragment jar that is metadata complete, we should skip scanning for @webservlet etc
// but yet we still need to do the scanning for the classes on behalf of the servletcontainerinitializers // but yet we still need to do the scanning for the classes on behalf of the servletcontainerinitializers
//if a jar has no web-fragment.xml we scan it (because it is not excluded by the ordering) //if a jar has no web-fragment.xml we scan it (because it is not excluded by the ordering)
//or if it has a fragment we scan it if it is not metadata complete //or if it has a fragment we scan it if it is not metadata complete
if (f == null || !isMetaDataComplete(f) || _classInheritanceHandler != null || !_containerInitializerAnnotationHandlers.isEmpty()) if (f == null || !WebDescriptor.isMetaDataComplete(f) || _classInheritanceHandler != null || !_containerInitializerAnnotationHandlers.isEmpty())
{ {
//register the classinheritance handler if there is one //register the classinheritance handler if there is one
if (_classInheritanceHandler != null) if (_classInheritanceHandler != null)
@ -1069,7 +1072,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
handlers.addAll(_containerInitializerAnnotationHandlers); handlers.addAll(_containerInitializerAnnotationHandlers);
//only register the discoverable annotation handlers if this fragment is not metadata complete, or has no fragment descriptor //only register the discoverable annotation handlers if this fragment is not metadata complete, or has no fragment descriptor
if (f == null || !isMetaDataComplete(f)) if (f == null || !WebDescriptor.isMetaDataComplete(f))
handlers.addAll(_discoverableAnnotationHandlers); handlers.addAll(_discoverableAnnotationHandlers);
if (_parserTasks != null) if (_parserTasks != null)
@ -1087,7 +1090,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
} }
/** /**
* Scan classes in WEB-INF/classes * Scan classes in WEB-INF/classes.
* *
* @param context the context for the scan * @param context the context for the scan
* @param parser the annotation parser to use * @param parser the annotation parser to use
@ -1105,7 +1108,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
_webInfClassesStats = new CounterStatistic(); _webInfClassesStats = new CounterStatistic();
for (Resource dir : context.getMetaData().getWebInfClassesDirs()) for (Resource dir : context.getMetaData().getWebInfClassesResources())
{ {
if (_parserTasks != null) if (_parserTasks != null)
{ {
@ -1120,39 +1123,8 @@ public class AnnotationConfiguration extends AbstractConfiguration
} }
} }
/**
* Get the web-fragment.xml from a jar
*
* @param jar the jar to look in for a fragment
* @param frags the fragments previously found
* @return true if the fragment if found, or null of not found
* @throws Exception if unable to determine the the fragment contains
*/
public FragmentDescriptor getFragmentFromJar(Resource jar, List<FragmentDescriptor> frags)
throws Exception
{
//check if the jar has a web-fragment.xml
FragmentDescriptor d = null;
for (FragmentDescriptor frag : frags)
{
Resource fragResource = frag.getResource(); //eg jar:file:///a/b/c/foo.jar!/META-INF/web-fragment.xml
if (Resource.isContainedIn(fragResource, jar))
{
d = frag;
break;
}
}
return d;
}
public boolean isMetaDataComplete(WebDescriptor d)
{
return (d != null && d.getMetaDataComplete() == MetaDataComplete.True);
}
public static class ClassInheritanceMap extends ConcurrentHashMap<String, Set<String>> public static class ClassInheritanceMap extends ConcurrentHashMap<String, Set<String>>
{ {
@Override @Override
public String toString() public String toString()
{ {

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.annotations; package org.eclipse.jetty.annotations;
import java.util.Objects;
import org.eclipse.jetty.util.DecoratedObjectFactory;
import org.eclipse.jetty.util.Decorator; import org.eclipse.jetty.util.Decorator;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
@ -26,23 +29,26 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/ */
public class AnnotationDecorator implements Decorator public class AnnotationDecorator implements Decorator
{ {
protected AnnotationIntrospector _introspector = new AnnotationIntrospector(); protected AnnotationIntrospector _introspector;
protected WebAppContext _context;
public AnnotationDecorator(WebAppContext context) public AnnotationDecorator(WebAppContext context)
{ {
registerHandlers(context); _context = Objects.requireNonNull(context);
_introspector = new AnnotationIntrospector(_context);
registerHandlers();
} }
public void registerHandlers(WebAppContext context) private void registerHandlers()
{ {
_introspector.registerHandler(new ResourceAnnotationHandler(context)); _introspector.registerHandler(new ResourceAnnotationHandler(_context));
_introspector.registerHandler(new ResourcesAnnotationHandler(context)); _introspector.registerHandler(new ResourcesAnnotationHandler(_context));
_introspector.registerHandler(new RunAsAnnotationHandler(context)); _introspector.registerHandler(new RunAsAnnotationHandler(_context));
_introspector.registerHandler(new PostConstructAnnotationHandler(context)); _introspector.registerHandler(new PostConstructAnnotationHandler(_context));
_introspector.registerHandler(new PreDestroyAnnotationHandler(context)); _introspector.registerHandler(new PreDestroyAnnotationHandler(_context));
_introspector.registerHandler(new DeclareRolesAnnotationHandler(context)); _introspector.registerHandler(new DeclareRolesAnnotationHandler(_context));
_introspector.registerHandler(new MultiPartConfigAnnotationHandler(context)); _introspector.registerHandler(new MultiPartConfigAnnotationHandler(_context));
_introspector.registerHandler(new ServletSecurityAnnotationHandler(context)); _introspector.registerHandler(new ServletSecurityAnnotationHandler(_context));
} }
/** /**
@ -50,22 +56,28 @@ public class AnnotationDecorator implements Decorator
* <ul> * <ul>
* <li> Resource </li> * <li> Resource </li>
* <li> Resources </li> * <li> Resources </li>
* <li> RunAs </li>
* <li> PostConstruct </li> * <li> PostConstruct </li>
* <li> PreDestroy </li> * <li> PreDestroy </li>
* <li> ServletSecurity? </li> * <li> DeclareRoles </li>
* <li> MultiPart </li>
* <li> ServletSecurity</li>
* </ul> * </ul>
* *
* @param o the object ot introspect * @param o the object to introspect
* @param metaInfo information about the object to introspect
*/ */
protected void introspect(Object o) protected void introspect(Object o, Object metaInfo)
{ {
_introspector.introspect(o.getClass()); if (o == null)
return;
_introspector.introspect(o, metaInfo);
} }
@Override @Override
public Object decorate(Object o) public Object decorate(Object o)
{ {
introspect(o); introspect(o, DecoratedObjectFactory.getAssociatedInfo());
return o; return o;
} }

View File

@ -18,11 +18,21 @@
package org.eclipse.jetty.annotations; package org.eclipse.jetty.annotations;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import org.eclipse.jetty.servlet.BaseHolder;
import org.eclipse.jetty.servlet.Source.Origin;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebDescriptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* AnnotationIntrospector * AnnotationIntrospector
* Introspects a class to find various types of * Introspects a class to find various types of
@ -30,8 +40,10 @@ import java.util.Set;
*/ */
public class AnnotationIntrospector public class AnnotationIntrospector
{ {
private static final Logger LOG = LoggerFactory.getLogger(AnnotationIntrospector.class);
private final Set<Class<?>> _introspectedClasses = new HashSet<>(); private final Set<Class<?>> _introspectedClasses = new HashSet<>();
private final List<IntrospectableAnnotationHandler> _handlers = new ArrayList<IntrospectableAnnotationHandler>(); private final List<IntrospectableAnnotationHandler> _handlers = new ArrayList<IntrospectableAnnotationHandler>();
private final WebAppContext _context;
/** /**
* IntrospectableAnnotationHandler * IntrospectableAnnotationHandler
@ -51,12 +63,14 @@ public class AnnotationIntrospector
*/ */
public abstract static class AbstractIntrospectableAnnotationHandler implements IntrospectableAnnotationHandler public abstract static class AbstractIntrospectableAnnotationHandler implements IntrospectableAnnotationHandler
{ {
private boolean _introspectAncestors; protected boolean _introspectAncestors;
protected WebAppContext _context;
public abstract void doHandle(Class<?> clazz); public abstract void doHandle(Class<?> clazz);
public AbstractIntrospectableAnnotationHandler(boolean introspectAncestors) public AbstractIntrospectableAnnotationHandler(boolean introspectAncestors, WebAppContext context)
{ {
_context = Objects.requireNonNull(context);
_introspectAncestors = introspectAncestors; _introspectAncestors = introspectAncestors;
} }
@ -75,6 +89,16 @@ public class AnnotationIntrospector
c = c.getSuperclass(); c = c.getSuperclass();
} }
} }
public WebAppContext getContext()
{
return _context;
}
}
public AnnotationIntrospector(WebAppContext context)
{
_context = Objects.requireNonNull(context);
} }
public void registerHandler(IntrospectableAnnotationHandler handler) public void registerHandler(IntrospectableAnnotationHandler handler)
@ -82,13 +106,95 @@ public class AnnotationIntrospector
_handlers.add(handler); _handlers.add(handler);
} }
public void introspect(Class<?> clazz) /**
* Test if an object should be introspected for some specific types of annotations
* like PostConstruct/PreDestroy/MultiPart etc etc.
*
* According to servlet 4.0, these types of annotations should only be evaluated iff any
* of the following are true:
* <ol>
* <li>the object was created by the javax.servlet.ServletContext.createServlet/Filter/Listener method</li>
* <li>the object comes either from a discovered annotation (WebServlet/Filter/Listener) or a declaration
* in a descriptor AND web.xml is NOT metadata-complete AND any web-fragment.xml associated with the location of
* the class is NOT metadata-complete</li>
* </ol>
*
* We also support evaluations of these types of annotations for objects that were created directly
* by the jetty api.
*
* @param o the object to check for its ability to be introspected for annotations
* @param metaInfo meta information about the object to be introspected
* @return true if it can be introspected according to servlet 4.0 rules
*/
public boolean isIntrospectable(Object o, Object metaInfo)
{ {
if (_handlers == null) if (o == null)
return; return false; //nothing to introspect
if (clazz == null)
if (metaInfo == null)
return true; //no information about the object to introspect, assume introspectable
@SuppressWarnings("rawtypes")
BaseHolder holder = null;
try
{
holder = (BaseHolder)metaInfo;
}
catch (ClassCastException e)
{
LOG.warn("Not introspectable {}", metaInfo.getClass().getName(), e);
return true; //not the type of information we were expecting, assume introspectable
}
Origin origin = (holder.getSource() == null ? null : holder.getSource().getOrigin());
if (origin == null)
return true; //assume introspectable
switch (origin)
{
case EMBEDDED:
case JAVAX_API:
{
return true; //objects created from the jetty or servlet api are always introspectable
}
case ANNOTATION:
{
return true; //we will have discovered annotations only if metadata-complete==false
}
default:
{
//must be from a descriptor. Only introspect if the descriptor with which it was associated
//is not metadata-complete
if (_context.getMetaData().isMetaDataComplete())
return false;
String descriptorLocation = holder.getSource().getResource();
if (descriptorLocation == null)
return true; //no descriptor, can't be metadata-complete
try
{
return !WebDescriptor.isMetaDataComplete(_context.getMetaData().getFragmentDescriptor(Resource.newResource(descriptorLocation)));
}
catch (IOException e)
{
LOG.warn("Unable to get Resource for descriptor {}", descriptorLocation, e);
return false; //something wrong with the descriptor
}
}
}
}
/**
*
*/
public void introspect(Object o, Object metaInfo)
{
if (!isIntrospectable(o, metaInfo))
return; return;
Class<?> clazz = o.getClass();
synchronized (_introspectedClasses) synchronized (_introspectedClasses)
{ {
//Synchronize on the set of already introspected classes. //Synchronize on the set of already introspected classes.

View File

@ -39,8 +39,6 @@ import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.util.MultiReleaseJarFile; import org.eclipse.jetty.util.MultiReleaseJarFile;
import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
@ -48,6 +46,8 @@ import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* AnnotationParser * AnnotationParser
@ -69,7 +69,7 @@ import org.objectweb.asm.Opcodes;
*/ */
public class AnnotationParser public class AnnotationParser
{ {
private static final Logger LOG = Log.getLogger(AnnotationParser.class); private static final Logger LOG = LoggerFactory.getLogger(AnnotationParser.class);
protected static int ASM_OPCODE_VERSION = Opcodes.ASM7; //compatibility of api protected static int ASM_OPCODE_VERSION = Opcodes.ASM7; //compatibility of api
protected static String ASM_OPCODE_VERSION_STR = "ASM7"; protected static String ASM_OPCODE_VERSION_STR = "ASM7";

View File

@ -24,8 +24,8 @@ import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jetty.annotations.AnnotationParser.AbstractHandler; import org.eclipse.jetty.annotations.AnnotationParser.AbstractHandler;
import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo; import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* ClassInheritanceHandler * ClassInheritanceHandler
@ -34,7 +34,7 @@ import org.eclipse.jetty.util.log.Logger;
*/ */
public class ClassInheritanceHandler extends AbstractHandler public class ClassInheritanceHandler extends AbstractHandler
{ {
private static final Logger LOG = Log.getLogger(ClassInheritanceHandler.class); private static final Logger LOG = LoggerFactory.getLogger(ClassInheritanceHandler.class);
Map<String, Set<String>> _inheritanceMap; Map<String, Set<String>> _inheritanceMap;
@ -64,7 +64,7 @@ public class ClassInheritanceHandler extends AbstractHandler
} }
catch (Exception e) catch (Exception e)
{ {
LOG.warn(e); LOG.warn("Failed to handle {}", classInfo, e);
} }
} }

View File

@ -24,23 +24,20 @@ import javax.servlet.Servlet;
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler; import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
import org.eclipse.jetty.security.ConstraintAware; import org.eclipse.jetty.security.ConstraintAware;
import org.eclipse.jetty.security.ConstraintSecurityHandler; import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* DeclaresRolesAnnotationHandler * DeclaresRolesAnnotationHandler
*/ */
public class DeclareRolesAnnotationHandler extends AbstractIntrospectableAnnotationHandler public class DeclareRolesAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{ {
private static final Logger LOG = Log.getLogger(DeclareRolesAnnotationHandler.class); private static final Logger LOG = LoggerFactory.getLogger(DeclareRolesAnnotationHandler.class);
protected WebAppContext _context;
public DeclareRolesAnnotationHandler(WebAppContext context) public DeclareRolesAnnotationHandler(WebAppContext context)
{ {
super(false); super(false, context);
_context = context;
} }
@Override @Override

View File

@ -33,13 +33,10 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/ */
public class MultiPartConfigAnnotationHandler extends AbstractIntrospectableAnnotationHandler public class MultiPartConfigAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{ {
protected WebAppContext _context;
public MultiPartConfigAnnotationHandler(WebAppContext context) public MultiPartConfigAnnotationHandler(WebAppContext context)
{ {
//TODO verify that MultipartConfig is not inheritable //TODO verify that MultipartConfig is not inheritable
super(false); super(false, context);
_context = context;
} }
@Override @Override

View File

@ -31,12 +31,9 @@ import org.eclipse.jetty.webapp.WebAppContext;
public class PostConstructAnnotationHandler extends AbstractIntrospectableAnnotationHandler public class PostConstructAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{ {
protected WebAppContext _context;
public PostConstructAnnotationHandler(WebAppContext wac) public PostConstructAnnotationHandler(WebAppContext wac)
{ {
super(true); super(true, wac);
_context = wac;
} }
@Override @Override

View File

@ -31,12 +31,9 @@ import org.eclipse.jetty.webapp.WebAppContext;
public class PreDestroyAnnotationHandler extends AbstractIntrospectableAnnotationHandler public class PreDestroyAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{ {
WebAppContext _context;
public PreDestroyAnnotationHandler(WebAppContext wac) public PreDestroyAnnotationHandler(WebAppContext wac)
{ {
super(true); super(true, wac);
_context = wac;
} }
@Override @Override

View File

@ -32,28 +32,25 @@ import javax.naming.NamingException;
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler; import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
import org.eclipse.jetty.plus.annotation.Injection; import org.eclipse.jetty.plus.annotation.Injection;
import org.eclipse.jetty.plus.annotation.InjectionCollection; import org.eclipse.jetty.plus.annotation.InjectionCollection;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.MetaData; import org.eclipse.jetty.webapp.MetaData;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationHandler public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{ {
private static final Logger LOG = Log.getLogger(ResourceAnnotationHandler.class); private static final Logger LOG = LoggerFactory.getLogger(ResourceAnnotationHandler.class);
protected static final List<Class<?>> ENV_ENTRY_TYPES = protected static final List<Class<?>> ENV_ENTRY_TYPES =
Arrays.asList(new Class[] Arrays.asList(new Class[]
{ {
String.class, Character.class, Integer.class, Boolean.class, Double.class, Byte.class, Short.class, Long.class, String.class, Character.class, Integer.class, Boolean.class, Double.class, Byte.class, Short.class, Long.class,
Float.class Float.class
}); });
protected WebAppContext _context;
public ResourceAnnotationHandler(WebAppContext wac) public ResourceAnnotationHandler(WebAppContext wac)
{ {
super(true); super(true, wac);
_context = wac;
} }
/** /**
@ -101,7 +98,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
} }
catch (NamingException e) catch (NamingException e)
{ {
LOG.warn(e); LOG.warn("Unable to bind name {} to {} from class {}", name, mappedName, clazz, e);
} }
} }
} }

View File

@ -23,20 +23,17 @@ import javax.annotation.Resources;
import javax.naming.NamingException; import javax.naming.NamingException;
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler; import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotationHandler public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{ {
private static final Logger LOG = Log.getLogger(ResourcesAnnotationHandler.class); private static final Logger LOG = LoggerFactory.getLogger(ResourcesAnnotationHandler.class);
protected WebAppContext _wac;
public ResourcesAnnotationHandler(WebAppContext wac) public ResourcesAnnotationHandler(WebAppContext wac)
{ {
super(true); super(true, wac);
_wac = wac;
} }
@Override @Override
@ -64,13 +61,13 @@ public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotation
{ {
//TODO don't ignore the shareable, auth etc etc //TODO don't ignore the shareable, auth etc etc
if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_wac, name, mappedName)) if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context, name, mappedName))
if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_wac.getServer(), name, mappedName)) if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context.getServer(), name, mappedName))
LOG.warn("Skipping Resources(Resource) annotation on " + clazz.getName() + " for name " + name + ": No resource bound at " + (mappedName == null ? name : mappedName)); LOG.warn("Skipping Resources(Resource) annotation on " + clazz.getName() + " for name " + name + ": No resource bound at " + (mappedName == null ? name : mappedName));
} }
catch (NamingException e) catch (NamingException e)
{ {
LOG.warn(e); LOG.warn("Unable to bind {} to {}", name, mappedName, e);
} }
} }
} }

View File

@ -23,24 +23,21 @@ import javax.servlet.Servlet;
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler; import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
import org.eclipse.jetty.plus.annotation.RunAsCollection; import org.eclipse.jetty.plus.annotation.RunAsCollection;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.Descriptor; import org.eclipse.jetty.webapp.Descriptor;
import org.eclipse.jetty.webapp.MetaData; import org.eclipse.jetty.webapp.MetaData;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RunAsAnnotationHandler extends AbstractIntrospectableAnnotationHandler public class RunAsAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{ {
private static final Logger LOG = Log.getLogger(RunAsAnnotationHandler.class); private static final Logger LOG = LoggerFactory.getLogger(RunAsAnnotationHandler.class);
protected WebAppContext _context;
public RunAsAnnotationHandler(WebAppContext wac) public RunAsAnnotationHandler(WebAppContext wac)
{ {
//Introspect only the given class for a RunAs annotation, as it is a class level annotation, //Introspect only the given class for a RunAs annotation, as it is a class level annotation,
//and according to Common Annotation Spec p2-6 a class-level annotation is not inheritable. //and according to Common Annotation Spec p2-6 a class-level annotation is not inheritable.
super(false); super(false, wac);
_context = wac;
} }
@Override @Override

View File

@ -23,9 +23,9 @@ import java.util.List;
import org.eclipse.jetty.plus.annotation.ContainerInitializer; import org.eclipse.jetty.plus.annotation.ContainerInitializer;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* ServletContainerInitializersStarter * ServletContainerInitializersStarter
@ -35,7 +35,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/ */
public class ServletContainerInitializersStarter extends AbstractLifeCycle implements ServletContextHandler.ServletContainerInitializerCaller public class ServletContainerInitializersStarter extends AbstractLifeCycle implements ServletContextHandler.ServletContainerInitializerCaller
{ {
private static final Logger LOG = Log.getLogger(ServletContainerInitializersStarter.class); private static final Logger LOG = LoggerFactory.getLogger(ServletContainerInitializersStarter.class);
WebAppContext _context; WebAppContext _context;
public ServletContainerInitializersStarter(WebAppContext context) public ServletContainerInitializersStarter(WebAppContext context)
@ -60,7 +60,7 @@ public class ServletContainerInitializersStarter extends AbstractLifeCycle imple
} }
catch (Exception e) catch (Exception e)
{ {
LOG.warn(e); LOG.warn("Failed to call startup on {}", i, e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

View File

@ -31,10 +31,10 @@ import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler; import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.ServletMapping; import org.eclipse.jetty.servlet.ServletMapping;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.security.Constraint; import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* ServletSecurityAnnotationHandler * ServletSecurityAnnotationHandler
@ -55,14 +55,11 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/ */
public class ServletSecurityAnnotationHandler extends AbstractIntrospectableAnnotationHandler public class ServletSecurityAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{ {
private static final Logger LOG = Log.getLogger(ServletSecurityAnnotationHandler.class); private static final Logger LOG = LoggerFactory.getLogger(ServletSecurityAnnotationHandler.class);
private WebAppContext _context;
public ServletSecurityAnnotationHandler(WebAppContext wac) public ServletSecurityAnnotationHandler(WebAppContext wac)
{ {
super(false); super(false, wac);
_context = wac;
} }
@Override @Override

View File

@ -29,20 +29,20 @@ import org.eclipse.jetty.http.pathmap.ServletPathSpec;
import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.FilterMapping; import org.eclipse.jetty.servlet.FilterMapping;
import org.eclipse.jetty.servlet.Source; import org.eclipse.jetty.servlet.Source;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.DiscoveredAnnotation; import org.eclipse.jetty.webapp.DiscoveredAnnotation;
import org.eclipse.jetty.webapp.MetaData; import org.eclipse.jetty.webapp.MetaData;
import org.eclipse.jetty.webapp.Origin; import org.eclipse.jetty.webapp.Origin;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* WebFilterAnnotation * WebFilterAnnotation
*/ */
public class WebFilterAnnotation extends DiscoveredAnnotation public class WebFilterAnnotation extends DiscoveredAnnotation
{ {
private static final Logger LOG = Log.getLogger(WebFilterAnnotation.class); private static final Logger LOG = LoggerFactory.getLogger(WebFilterAnnotation.class);
public WebFilterAnnotation(WebAppContext context, String className) public WebFilterAnnotation(WebAppContext context, String className)
{ {

View File

@ -21,16 +21,16 @@ package org.eclipse.jetty.annotations;
import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo; import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo; import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo; import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* WebFilterAnnotationHandler * WebFilterAnnotationHandler
*/ */
public class WebFilterAnnotationHandler extends AbstractDiscoverableAnnotationHandler public class WebFilterAnnotationHandler extends AbstractDiscoverableAnnotationHandler
{ {
private static final Logger LOG = Log.getLogger(WebFilterAnnotationHandler.class); private static final Logger LOG = LoggerFactory.getLogger(WebFilterAnnotationHandler.class);
public WebFilterAnnotationHandler(WebAppContext context) public WebFilterAnnotationHandler(WebAppContext context)
{ {

View File

@ -29,20 +29,20 @@ import javax.servlet.http.HttpSessionListener;
import org.eclipse.jetty.servlet.ListenerHolder; import org.eclipse.jetty.servlet.ListenerHolder;
import org.eclipse.jetty.servlet.Source; import org.eclipse.jetty.servlet.Source;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.DiscoveredAnnotation; import org.eclipse.jetty.webapp.DiscoveredAnnotation;
import org.eclipse.jetty.webapp.MetaData; import org.eclipse.jetty.webapp.MetaData;
import org.eclipse.jetty.webapp.Origin; import org.eclipse.jetty.webapp.Origin;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* WebListenerAnnotation * WebListenerAnnotation
*/ */
public class WebListenerAnnotation extends DiscoveredAnnotation public class WebListenerAnnotation extends DiscoveredAnnotation
{ {
private static final Logger LOG = Log.getLogger(WebListenerAnnotation.class); private static final Logger LOG = LoggerFactory.getLogger(WebListenerAnnotation.class);
public WebListenerAnnotation(WebAppContext context, String className) public WebListenerAnnotation(WebAppContext context, String className)
{ {
@ -88,7 +88,7 @@ public class WebListenerAnnotation extends DiscoveredAnnotation
} }
catch (Exception e) catch (Exception e)
{ {
LOG.warn(e); LOG.warn("Unable to add listener {}", clazz, e);
} }
} }
} }

View File

@ -21,13 +21,13 @@ package org.eclipse.jetty.annotations;
import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo; import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo; import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo; import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WebListenerAnnotationHandler extends AbstractDiscoverableAnnotationHandler public class WebListenerAnnotationHandler extends AbstractDiscoverableAnnotationHandler
{ {
private static final Logger LOG = Log.getLogger(WebListenerAnnotationHandler.class); private static final Logger LOG = LoggerFactory.getLogger(WebListenerAnnotationHandler.class);
public WebListenerAnnotationHandler(WebAppContext context) public WebListenerAnnotationHandler(WebAppContext context)
{ {

View File

@ -32,20 +32,20 @@ import org.eclipse.jetty.servlet.ServletMapping;
import org.eclipse.jetty.servlet.Source; import org.eclipse.jetty.servlet.Source;
import org.eclipse.jetty.util.ArrayUtil; import org.eclipse.jetty.util.ArrayUtil;
import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.DiscoveredAnnotation; import org.eclipse.jetty.webapp.DiscoveredAnnotation;
import org.eclipse.jetty.webapp.MetaData; import org.eclipse.jetty.webapp.MetaData;
import org.eclipse.jetty.webapp.Origin; import org.eclipse.jetty.webapp.Origin;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* WebServletAnnotation * WebServletAnnotation
*/ */
public class WebServletAnnotation extends DiscoveredAnnotation public class WebServletAnnotation extends DiscoveredAnnotation
{ {
private static final Logger LOG = Log.getLogger(WebServletAnnotation.class); private static final Logger LOG = LoggerFactory.getLogger(WebServletAnnotation.class);
public WebServletAnnotation(WebAppContext context, String className) public WebServletAnnotation(WebAppContext context, String className)
{ {

View File

@ -21,9 +21,9 @@ package org.eclipse.jetty.annotations;
import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo; import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo; import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo; import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* WebServletAnnotationHandler * WebServletAnnotationHandler
@ -32,7 +32,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/ */
public class WebServletAnnotationHandler extends AbstractDiscoverableAnnotationHandler public class WebServletAnnotationHandler extends AbstractDiscoverableAnnotationHandler
{ {
private static final Logger LOG = Log.getLogger(WebServletAnnotationHandler.class); private static final Logger LOG = LoggerFactory.getLogger(WebServletAnnotationHandler.class);
public WebServletAnnotationHandler(WebAppContext context) public WebServletAnnotationHandler(WebAppContext context)
{ {

View File

@ -16,9 +16,15 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.webapp; package org.eclipse.jetty.annotations;
public enum MetaDataComplete import javax.annotation.PreDestroy;
import javax.servlet.http.HttpServlet;
public class ServletE extends HttpServlet
{ {
NotSet, True, False @PreDestroy
public void preDestroy()
{
}
} }

View File

@ -21,7 +21,6 @@ package org.eclipse.jetty.annotations;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContainerInitializer;
@ -30,9 +29,9 @@ import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.JAR; import org.eclipse.jetty.toolchain.test.JAR;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.FragmentDescriptor;
import org.eclipse.jetty.webapp.RelativeOrdering; import org.eclipse.jetty.webapp.RelativeOrdering;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebDescriptor;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -125,7 +124,7 @@ public class TestAnnotationConfiguration
context25.setClassLoader(Thread.currentThread().getContextClassLoader()); context25.setClassLoader(Thread.currentThread().getContextClassLoader());
context25.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE); context25.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE);
context25.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0); context25.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0);
context25.getMetaData().setWebXml(Resource.newResource(web25)); context25.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web25)));
context25.getServletContext().setEffectiveMajorVersion(2); context25.getServletContext().setEffectiveMajorVersion(2);
context25.getServletContext().setEffectiveMinorVersion(5); context25.getServletContext().setEffectiveMinorVersion(5);
config25.configure(context25); config25.configure(context25);
@ -138,7 +137,7 @@ public class TestAnnotationConfiguration
context25b.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE); context25b.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE);
context25b.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0); context25b.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0);
context25b.setConfigurationDiscovered(true); context25b.setConfigurationDiscovered(true);
context25b.getMetaData().setWebXml(Resource.newResource(web25)); context25b.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web25)));
context25b.getServletContext().setEffectiveMajorVersion(2); context25b.getServletContext().setEffectiveMajorVersion(2);
context25b.getServletContext().setEffectiveMinorVersion(5); context25b.getServletContext().setEffectiveMinorVersion(5);
config25b.configure(context25b); config25b.configure(context25b);
@ -150,7 +149,7 @@ public class TestAnnotationConfiguration
context31.setClassLoader(Thread.currentThread().getContextClassLoader()); context31.setClassLoader(Thread.currentThread().getContextClassLoader());
context31.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE); context31.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE);
context31.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0); context31.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0);
context31.getMetaData().setWebXml(Resource.newResource(web31true)); context31.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web31true)));
context31.getServletContext().setEffectiveMajorVersion(3); context31.getServletContext().setEffectiveMajorVersion(3);
context31.getServletContext().setEffectiveMinorVersion(1); context31.getServletContext().setEffectiveMinorVersion(1);
config31.configure(context31); config31.configure(context31);
@ -162,7 +161,7 @@ public class TestAnnotationConfiguration
context31b.setClassLoader(Thread.currentThread().getContextClassLoader()); context31b.setClassLoader(Thread.currentThread().getContextClassLoader());
context31b.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE); context31b.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE);
context31b.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0); context31b.setAttribute(AnnotationConfiguration.MAX_SCAN_WAIT, 0);
context31b.getMetaData().setWebXml(Resource.newResource(web31false)); context31b.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web31false)));
context31b.getServletContext().setEffectiveMajorVersion(3); context31b.getServletContext().setEffectiveMajorVersion(3);
context31b.getServletContext().setEffectiveMinorVersion(1); context31b.getServletContext().setEffectiveMinorVersion(1);
config31b.configure(context31b); config31b.configure(context31b);
@ -183,9 +182,9 @@ public class TestAnnotationConfiguration
//test 3.1 webapp loads both server and app scis //test 3.1 webapp loads both server and app scis
context.setClassLoader(webAppLoader); context.setClassLoader(webAppLoader);
context.getMetaData().addWebInfJar(Resource.newResource(testSciJar.toURI().toURL())); context.getMetaData().addWebInfResource(Resource.newResource(testSciJar.toURI().toURL()));
context.getMetaData().setWebXml(Resource.newResource(web31true)); context.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web31true)));
context.getMetaData().setWebInfClassesDirs(classes); context.getMetaData().setWebInfClassesResources(classes);
context.getServletContext().setEffectiveMajorVersion(3); context.getServletContext().setEffectiveMajorVersion(3);
context.getServletContext().setEffectiveMinorVersion(1); context.getServletContext().setEffectiveMinorVersion(1);
scis = config.getNonExcludedInitializers(context); scis = config.getNonExcludedInitializers(context);
@ -215,9 +214,9 @@ public class TestAnnotationConfiguration
// test a 3.1 webapp with metadata-complete=false loads both server // test a 3.1 webapp with metadata-complete=false loads both server
// and webapp scis // and webapp scis
context.setClassLoader(webAppLoader); context.setClassLoader(webAppLoader);
context.getMetaData().setWebXml(Resource.newResource(web31false)); context.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web31false)));
context.getMetaData().setWebInfClassesDirs(classes); context.getMetaData().setWebInfClassesResources(classes);
context.getMetaData().addWebInfJar(Resource.newResource(testSciJar.toURI().toURL())); context.getMetaData().addWebInfResource(Resource.newResource(testSciJar.toURI().toURL()));
context.getServletContext().setEffectiveMajorVersion(3); context.getServletContext().setEffectiveMajorVersion(3);
context.getServletContext().setEffectiveMinorVersion(1); context.getServletContext().setEffectiveMinorVersion(1);
scis = config.getNonExcludedInitializers(context); scis = config.getNonExcludedInitializers(context);
@ -260,12 +259,12 @@ public class TestAnnotationConfiguration
WebAppContext context = new WebAppContext(); WebAppContext context = new WebAppContext();
List<ServletContainerInitializer> scis; List<ServletContainerInitializer> scis;
context.setClassLoader(orderedLoader); context.setClassLoader(orderedLoader);
context.getMetaData().setWebXml(Resource.newResource(web31true)); context.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web31true)));
RelativeOrdering ordering = new RelativeOrdering(context.getMetaData()); RelativeOrdering ordering = new RelativeOrdering(context.getMetaData());
context.getMetaData().setOrdering(ordering); context.getMetaData().setOrdering(ordering);
context.getMetaData().addWebInfJar(Resource.newResource(orderedFragmentJar.toURI().toURL())); context.getMetaData().addWebInfResource(Resource.newResource(orderedFragmentJar.toURI().toURL()));
context.getMetaData().addWebInfJar(Resource.newResource(testSciJar.toURI().toURL())); context.getMetaData().addWebInfResource(Resource.newResource(testSciJar.toURI().toURL()));
context.getMetaData().setWebInfClassesDirs(classes); context.getMetaData().setWebInfClassesResources(classes);
context.getMetaData().orderFragments(); context.getMetaData().orderFragments();
context.getServletContext().setEffectiveMajorVersion(3); context.getServletContext().setEffectiveMajorVersion(3);
context.getServletContext().setEffectiveMinorVersion(1); context.getServletContext().setEffectiveMinorVersion(1);
@ -295,9 +294,9 @@ public class TestAnnotationConfiguration
WebAppContext context = new WebAppContext(); WebAppContext context = new WebAppContext();
List<ServletContainerInitializer> scis; List<ServletContainerInitializer> scis;
context.setClassLoader(webAppLoader); context.setClassLoader(webAppLoader);
context.getMetaData().setWebXml(Resource.newResource(web25)); context.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web25)));
context.getMetaData().setWebInfClassesDirs(classes); context.getMetaData().setWebInfClassesResources(classes);
context.getMetaData().addWebInfJar(Resource.newResource(testSciJar.toURI().toURL())); context.getMetaData().addWebInfResource(Resource.newResource(testSciJar.toURI().toURL()));
context.getServletContext().setEffectiveMajorVersion(2); context.getServletContext().setEffectiveMajorVersion(2);
context.getServletContext().setEffectiveMinorVersion(5); context.getServletContext().setEffectiveMinorVersion(5);
scis = config.getNonExcludedInitializers(context); scis = config.getNonExcludedInitializers(context);
@ -332,9 +331,9 @@ public class TestAnnotationConfiguration
List<ServletContainerInitializer> scis; List<ServletContainerInitializer> scis;
context.setConfigurationDiscovered(true); context.setConfigurationDiscovered(true);
context.setClassLoader(webAppLoader); context.setClassLoader(webAppLoader);
context.getMetaData().setWebXml(Resource.newResource(web25)); context.getMetaData().setWebDescriptor(new WebDescriptor(Resource.newResource(web25)));
context.getMetaData().setWebInfClassesDirs(classes); context.getMetaData().setWebInfClassesResources(classes);
context.getMetaData().addWebInfJar(Resource.newResource(testSciJar.toURI().toURL())); context.getMetaData().addWebInfResource(Resource.newResource(testSciJar.toURI().toURL()));
context.getServletContext().setEffectiveMajorVersion(2); context.getServletContext().setEffectiveMajorVersion(2);
context.getServletContext().setEffectiveMinorVersion(5); context.getServletContext().setEffectiveMinorVersion(5);
scis = config.getNonExcludedInitializers(context); scis = config.getNonExcludedInitializers(context);
@ -349,24 +348,4 @@ public class TestAnnotationConfiguration
Thread.currentThread().setContextClassLoader(old); Thread.currentThread().setContextClassLoader(old);
} }
} }
@Test
public void testGetFragmentFromJar() throws Exception
{
String dir = MavenTestingUtils.getTargetTestingDir("getFragmentFromJar").getAbsolutePath();
File file = new File(dir);
file = new File(file.getCanonicalPath());
URL url = file.toURI().toURL();
Resource jar1 = Resource.newResource(url + "file.jar");
AnnotationConfiguration config = new AnnotationConfiguration();
WebAppContext wac = new WebAppContext();
List<FragmentDescriptor> frags = new ArrayList<FragmentDescriptor>();
frags.add(new FragmentDescriptor(Resource.newResource("jar:" + url + "file.jar!/fooa.props")));
frags.add(new FragmentDescriptor(Resource.newResource("jar:" + url + "file2.jar!/foob.props")));
assertNotNull(config.getFragmentFromJar(jar1, frags));
}
} }

View File

@ -0,0 +1,127 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.annotations;
import org.eclipse.jetty.plus.annotation.LifeCycleCallbackCollection;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.Source;
import org.eclipse.jetty.util.DecoratedObjectFactory;
import org.eclipse.jetty.util.resource.EmptyResource;
import org.eclipse.jetty.webapp.MetaData;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebDescriptor;
import org.eclipse.jetty.xml.XmlParser;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestAnnotationDecorator
{
public class TestWebDescriptor extends WebDescriptor
{
public TestWebDescriptor(MetaData.Complete metadata)
{
super(EmptyResource.INSTANCE);
_metaDataComplete = metadata;
}
@Override
public void parse(XmlParser parser) throws Exception
{
}
@Override
public void processVersion()
{
}
@Override
public void processOrdering()
{
}
@Override
public void processDistributable()
{
}
@Override
public int getMajorVersion()
{
return 4;
}
@Override
public int getMinorVersion()
{
return 0;
}
}
@Test
public void testAnnotationDecorator() throws Exception
{
assertThrows(NullPointerException.class, () ->
{
new AnnotationDecorator(null);
});
WebAppContext context = new WebAppContext();
AnnotationDecorator decorator = new AnnotationDecorator(context);
ServletE servlet = new ServletE();
//test without BaseHolder metadata
decorator.decorate(servlet);
LifeCycleCallbackCollection callbacks = (LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
assertNotNull(callbacks);
assertFalse(callbacks.getPreDestroyCallbacks().isEmpty());
//reset
context.removeAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
//test with BaseHolder metadata, should not introspect with metdata-complete==true
context.getMetaData().setWebDescriptor(new TestWebDescriptor(MetaData.Complete.True));
assertTrue(context.getMetaData().isMetaDataComplete());
ServletHolder holder = new ServletHolder(new Source(Source.Origin.DESCRIPTOR, ""));
holder.setHeldClass(ServletE.class);
context.getServletHandler().addServlet(holder);
DecoratedObjectFactory.associateInfo(holder);
decorator = new AnnotationDecorator(context);
decorator.decorate(servlet);
DecoratedObjectFactory.disassociateInfo();
callbacks = (LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
assertNull(callbacks);
//reset
context.removeAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
//test with BaseHolder metadata, should introspect with metadata-complete==false
context.getMetaData().setWebDescriptor(new TestWebDescriptor(MetaData.Complete.False));
DecoratedObjectFactory.associateInfo(holder);
decorator = new AnnotationDecorator(context);
decorator.decorate(servlet);
DecoratedObjectFactory.disassociateInfo();
callbacks = (LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
assertNotNull(callbacks);
assertFalse(callbacks.getPreDestroyCallbacks().isEmpty());
}
}

View File

@ -0,0 +1,98 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.annotations;
import java.io.File;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.Source;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.FragmentDescriptor;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebDescriptor;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestAnnotationIntrospector
{
@Test
public void testIsIntrospectable() throws Exception
{
try (StacklessLogging ignore = new StacklessLogging(AnnotationIntrospector.class))
{
WebAppContext wac = new WebAppContext();
AnnotationIntrospector introspector = new AnnotationIntrospector(wac);
//can't introspect nothing
assertFalse(introspector.isIntrospectable(null, null));
//can introspect if no metadata to say otherwise
assertTrue(introspector.isIntrospectable(new Object(), null));
//can introspect if metdata isn't a BaseHolder
assertTrue(introspector.isIntrospectable(new Object(), new Object()));
//an EMBEDDED sourced servlet can be introspected
ServletHolder holder = new ServletHolder();
holder.setHeldClass(ServletE.class);
assertTrue(introspector.isIntrospectable(new ServletE(), holder));
//a JAVAX API sourced servlet can be introspected
holder = new ServletHolder(Source.JAVAX_API);
holder.setHeldClass(ServletE.class);
assertTrue(introspector.isIntrospectable(new ServletE(), holder));
//an ANNOTATION sourced servlet can be introspected
holder = new ServletHolder(new Source(Source.Origin.ANNOTATION, ServletE.class.getName()));
holder.setHeldClass(ServletE.class);
assertTrue(introspector.isIntrospectable(new ServletE(), holder));
//a DESCRIPTOR sourced servlet can be introspected if web.xml metdata-complete==false
File file = MavenTestingUtils.getTestResourceFile("web31false.xml");
Resource resource = Resource.newResource(file);
wac.getMetaData().setWebDescriptor(new WebDescriptor(resource));
holder = new ServletHolder(new Source(Source.Origin.DESCRIPTOR, resource.toString()));
assertTrue(introspector.isIntrospectable(new ServletE(), holder));
//a DESCRIPTOR sourced servlet can be introspected if web-fragment.xml medata-complete==false && web.xml metadata-complete==false
file = MavenTestingUtils.getTestResourceFile("web-fragment4false.xml");
resource = Resource.newResource(file);
wac.getMetaData().addFragmentDescriptor(Resource.newResource(file.getParentFile()), new FragmentDescriptor(resource));
holder = new ServletHolder(new Source(Source.Origin.DESCRIPTOR, resource.toString()));
assertTrue(introspector.isIntrospectable(new ServletE(), holder));
//a DESCRIPTOR sourced servlet cannot be introspected if web-fragment.xml medata-complete==true (&& web.xml metadata-complete==false)
file = MavenTestingUtils.getTestResourceFile("web-fragment4true.xml");
resource = Resource.newResource(file);
wac.getMetaData().addFragmentDescriptor(Resource.newResource(file.getParentFile()), new FragmentDescriptor(resource));
holder = new ServletHolder(new Source(Source.Origin.DESCRIPTOR, resource.toString()));
assertFalse(introspector.isIntrospectable(new ServletE(), holder));
//a DESCRIPTOR sourced servlet cannot be introspected if web.xml medata-complete==true
file = MavenTestingUtils.getTestResourceFile("web31true.xml");
resource = Resource.newResource(file);
wac.getMetaData().setWebDescriptor(new WebDescriptor(resource));
holder = new ServletHolder(new Source(Source.Origin.DESCRIPTOR, resource.toString()));
assertFalse(introspector.isIntrospectable(new ServletE(), holder));
}
}
}

View File

@ -89,7 +89,7 @@ public class TestSecurityAnnotationConversions
//Assume we found 1 servlet with a @HttpConstraint with value=EmptyRoleSemantic.DENY security annotation //Assume we found 1 servlet with a @HttpConstraint with value=EmptyRoleSemantic.DENY security annotation
ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac); ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac);
AnnotationIntrospector introspector = new AnnotationIntrospector(); AnnotationIntrospector introspector = new AnnotationIntrospector(wac);
introspector.registerHandler(annotationHandler); introspector.registerHandler(annotationHandler);
//set up the expected outcomes: //set up the expected outcomes:
@ -108,7 +108,7 @@ public class TestSecurityAnnotationConversions
expectedMappings[1].setConstraint(expectedConstraint); expectedMappings[1].setConstraint(expectedConstraint);
expectedMappings[1].setPathSpec("*.foo"); expectedMappings[1].setPathSpec("*.foo");
introspector.introspect(DenyServlet.class); introspector.introspect(new DenyServlet(), null);
compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings()); compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
} }
@ -122,15 +122,15 @@ public class TestSecurityAnnotationConversions
}); });
ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac); ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac);
AnnotationIntrospector introspector = new AnnotationIntrospector(); AnnotationIntrospector introspector = new AnnotationIntrospector(wac);
introspector.registerHandler(annotationHandler); introspector.registerHandler(annotationHandler);
//set up the expected outcomes - no constraints at all as per Servlet Spec 3.1 pg 129 //set up the expected outcomes - no constraints at all as per Servlet Spec 3.1 pg 129
//1 ConstraintMapping per ServletMapping pathSpec //1 ConstraintMapping per ServletMapping pathSpec
ConstraintMapping[] expectedMappings = new ConstraintMapping[]{}; ConstraintMapping[] expectedMappings = new ConstraintMapping[]{};
PermitServlet permit = new PermitServlet();
introspector.introspect(PermitServlet.class); introspector.introspect(permit, null);
compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings()); compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
} }
@ -146,7 +146,7 @@ public class TestSecurityAnnotationConversions
}); });
ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac); ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac);
AnnotationIntrospector introspector = new AnnotationIntrospector(); AnnotationIntrospector introspector = new AnnotationIntrospector(wac);
introspector.registerHandler(annotationHandler); introspector.registerHandler(annotationHandler);
//set up the expected outcomes:compareResults //set up the expected outcomes:compareResults
@ -164,8 +164,7 @@ public class TestSecurityAnnotationConversions
expectedMappings[1] = new ConstraintMapping(); expectedMappings[1] = new ConstraintMapping();
expectedMappings[1].setConstraint(expectedConstraint); expectedMappings[1].setConstraint(expectedConstraint);
expectedMappings[1].setPathSpec("*.foo"); expectedMappings[1].setPathSpec("*.foo");
introspector.introspect(new RolesServlet(), null);
introspector.introspect(RolesServlet.class);
compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings()); compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
} }
@ -211,10 +210,10 @@ public class TestSecurityAnnotationConversions
expectedMappings[3].setPathSpec("*.foo"); expectedMappings[3].setPathSpec("*.foo");
expectedMappings[3].setMethod("GET"); expectedMappings[3].setMethod("GET");
AnnotationIntrospector introspector = new AnnotationIntrospector(); AnnotationIntrospector introspector = new AnnotationIntrospector(wac);
ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac); ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac);
introspector.registerHandler(annotationHandler); introspector.registerHandler(annotationHandler);
introspector.introspect(Method1Servlet.class); introspector.introspect(new Method1Servlet(), null);
compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings()); compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
} }
@ -227,7 +226,7 @@ public class TestSecurityAnnotationConversions
"/foo/*", "*.foo" "/foo/*", "*.foo"
}); });
AnnotationIntrospector introspector = new AnnotationIntrospector(); AnnotationIntrospector introspector = new AnnotationIntrospector(wac);
ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac); ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac);
introspector.registerHandler(annotationHandler); introspector.registerHandler(annotationHandler);
@ -263,7 +262,7 @@ public class TestSecurityAnnotationConversions
expectedMappings[3].setPathSpec("*.foo"); expectedMappings[3].setPathSpec("*.foo");
expectedMappings[3].setMethod("GET"); expectedMappings[3].setMethod("GET");
introspector.introspect(Method2Servlet.class); introspector.introspect(new Method2Servlet(), null);
compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings()); compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
} }

View File

@ -73,11 +73,14 @@ public class TestResourceAnnotations
new org.eclipse.jetty.plus.jndi.EnvEntry(server, "resA", objA, false); new org.eclipse.jetty.plus.jndi.EnvEntry(server, "resA", objA, false);
new org.eclipse.jetty.plus.jndi.EnvEntry(server, "resB", objB, false); new org.eclipse.jetty.plus.jndi.EnvEntry(server, "resB", objB, false);
AnnotationIntrospector parser = new AnnotationIntrospector(); AnnotationIntrospector parser = new AnnotationIntrospector(wac);
ResourceAnnotationHandler handler = new ResourceAnnotationHandler(wac); ResourceAnnotationHandler handler = new ResourceAnnotationHandler(wac);
parser.registerHandler(handler); parser.registerHandler(handler);
parser.introspect(ResourceA.class);
parser.introspect(ResourceB.class); ResourceA resourceA = new ResourceA();
ResourceB resourceB = new ResourceB();
parser.introspect(resourceA, null);
parser.introspect(resourceB, null);
//processing classA should give us these jndi name bindings: //processing classA should give us these jndi name bindings:
// java:comp/env/myf // java:comp/env/myf
@ -155,11 +158,13 @@ public class TestResourceAnnotations
new org.eclipse.jetty.plus.jndi.EnvEntry(server, "resA", objA, false); new org.eclipse.jetty.plus.jndi.EnvEntry(server, "resA", objA, false);
new org.eclipse.jetty.plus.jndi.EnvEntry(server, "resB", objB, false); new org.eclipse.jetty.plus.jndi.EnvEntry(server, "resB", objB, false);
AnnotationIntrospector introspector = new AnnotationIntrospector(); AnnotationIntrospector introspector = new AnnotationIntrospector(wac);
ResourcesAnnotationHandler handler = new ResourcesAnnotationHandler(wac); ResourcesAnnotationHandler handler = new ResourcesAnnotationHandler(wac);
introspector.registerHandler(handler); introspector.registerHandler(handler);
introspector.introspect(ResourceA.class); ResourceA resourceA = new ResourceA();
introspector.introspect(ResourceB.class); ResourceB resourceB = new ResourceB();
introspector.introspect(resourceA, null);
introspector.introspect(resourceB, null);
assertEquals(objA, env.lookup("peach")); assertEquals(objA, env.lookup("peach"));
assertEquals(objB, env.lookup("pear")); assertEquals(objB, env.lookup("pear"));

View File

@ -1,3 +1,3 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog # Jetty Logging using jetty-slf4j-impl
#org.eclipse.jetty.LEVEL=DEBUG #org.eclipse.jetty.LEVEL=DEBUG
#org.eclipse.jetty.annotations.LEVEL=DEBUG #org.eclipse.jetty.annotations.LEVEL=DEBUG

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-fragment xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-fragment_4_0.xsd" version="4.0">
<name>ardvaark</name>
</web-fragment>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-fragment xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-fragment_4_0.xsd" metadata-complete="true" version="4.0">
<name>badger</name>
</web-fragment>

View File

@ -49,21 +49,21 @@ import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.ServletMapping; import org.eclipse.jetty.servlet.ServletMapping;
import org.eclipse.jetty.servlet.Source; import org.eclipse.jetty.servlet.Source;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.PathResource; import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.MetaInfConfiguration; import org.eclipse.jetty.webapp.MetaInfConfiguration;
import org.eclipse.jetty.webapp.WebAppClassLoader; import org.eclipse.jetty.webapp.WebAppClassLoader;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration; import org.eclipse.jetty.xml.XmlConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Extension of WebAppContext to allow configuration via Ant environment. * Extension of WebAppContext to allow configuration via Ant environment.
*/ */
public class AntWebAppContext extends WebAppContext public class AntWebAppContext extends WebAppContext
{ {
private static final Logger LOG = Log.getLogger(WebAppContext.class); private static final Logger LOG = LoggerFactory.getLogger(WebAppContext.class);
public static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN = public static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN =
".*/.*jsp-api-[^/]*\\.jar$|.*/.*jsp-[^/]*\\.jar$|.*/.*taglibs[^/]*\\.jar$|.*/.*jstl[^/]*\\.jar$|.*/.*jsf-impl-[^/]*\\.jar$|.*/.*javax.faces-[^/]*\\.jar$|.*/.*myfaces-impl-[^/]*\\.jar$"; ".*/.*jsp-api-[^/]*\\.jar$|.*/.*jsp-[^/]*\\.jar$|.*/.*taglibs[^/]*\\.jar$|.*/.*jstl[^/]*\\.jar$|.*/.*jsf-impl-[^/]*\\.jar$|.*/.*javax.faces-[^/]*\\.jar$|.*/.*myfaces-impl-[^/]*\\.jar$";
@ -176,7 +176,7 @@ public class AntWebAppContext extends WebAppContext
} }
catch (Exception e) catch (Exception e)
{ {
LOG.ignore(e); LOG.trace("IGNORED", e);
} }
} }
} }

View File

@ -21,10 +21,10 @@ package org.eclipse.jetty.ant;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.Configuration; import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebXmlConfiguration; import org.eclipse.jetty.webapp.WebXmlConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* This configuration object provides additional way to inject application * This configuration object provides additional way to inject application
@ -34,7 +34,7 @@ import org.eclipse.jetty.webapp.WebXmlConfiguration;
*/ */
public class AntWebXmlConfiguration extends WebXmlConfiguration public class AntWebXmlConfiguration extends WebXmlConfiguration
{ {
private static final Logger LOG = Log.getLogger(WebXmlConfiguration.class); private static final Logger LOG = LoggerFactory.getLogger(WebXmlConfiguration.class);
/** /**
* List of classpath files. * List of classpath files.

View File

@ -26,8 +26,8 @@ import javax.servlet.ServletContext;
import org.eclipse.jetty.annotations.AnnotationConfiguration; import org.eclipse.jetty.annotations.AnnotationConfiguration;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* <p>A {@link ServletContainerInitializer} that introspects for a CDI API * <p>A {@link ServletContainerInitializer} that introspects for a CDI API
@ -48,7 +48,7 @@ import org.eclipse.jetty.util.log.Logger;
public class CdiServletContainerInitializer implements ServletContainerInitializer public class CdiServletContainerInitializer implements ServletContainerInitializer
{ {
public static final String CDI_INTEGRATION_ATTRIBUTE = "org.eclipse.jetty.cdi"; public static final String CDI_INTEGRATION_ATTRIBUTE = "org.eclipse.jetty.cdi";
private static final Logger LOG = Log.getLogger(CdiServletContainerInitializer.class); private static final Logger LOG = LoggerFactory.getLogger(CdiServletContainerInitializer.class);
@Override @Override
public void onStartup(Set<Class<?>> c, ServletContext ctx) public void onStartup(Set<Class<?>> c, ServletContext ctx)

View File

@ -26,8 +26,8 @@ import java.util.Map;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.Decorator; import org.eclipse.jetty.util.Decorator;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* A Decorator that invokes the CDI provider within a webapp to decorate objects created by * A Decorator that invokes the CDI provider within a webapp to decorate objects created by
@ -47,7 +47,7 @@ import org.eclipse.jetty.util.log.Logger;
*/ */
public class CdiSpiDecorator implements Decorator public class CdiSpiDecorator implements Decorator
{ {
private static final Logger LOG = Log.getLogger(CdiServletContainerInitializer.class); private static final Logger LOG = LoggerFactory.getLogger(CdiServletContainerInitializer.class);
public static final String MODE = "CdiSpiDecorator"; public static final String MODE = "CdiSpiDecorator";
private final ServletContextHandler _context; private final ServletContextHandler _context;

View File

@ -24,7 +24,6 @@
@{argLine} ${jetty.surefire.argLine} @{argLine} ${jetty.surefire.argLine}
--add-modules java.security.jgss --add-modules java.security.jgss
--add-modules org.eclipse.jetty.jmx --add-modules org.eclipse.jetty.jmx
--add-modules org.slf4j
</argLine> </argLine>
</configuration> </configuration>
</plugin> </plugin>
@ -157,11 +156,10 @@
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>slf4j-simple</artifactId> <artifactId>jetty-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -28,9 +28,11 @@ module org.eclipse.jetty.client
requires org.eclipse.jetty.alpn.client; requires org.eclipse.jetty.alpn.client;
requires transitive org.eclipse.jetty.http; requires transitive org.eclipse.jetty.http;
requires org.slf4j;
// Only required if using SPNEGO. // Only required if using SPNEGO.
requires static java.security.jgss; requires static java.security.jgss;
// Only required if using JMX. // Only required if using JMX.
requires static java.management;
requires static org.eclipse.jetty.jmx; requires static org.eclipse.jetty.jmx;
} }

View File

@ -29,13 +29,13 @@ import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
@ManagedObject @ManagedObject
public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
{ {
private static final Logger LOG = Log.getLogger(AbstractConnectionPool.class); private static final Logger LOG = LoggerFactory.getLogger(AbstractConnectionPool.class);
private final AtomicBoolean closed = new AtomicBoolean(); private final AtomicBoolean closed = new AtomicBoolean();

View File

@ -24,13 +24,13 @@ import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
@ManagedObject @ManagedObject
public abstract class AbstractHttpClientTransport extends ContainerLifeCycle implements HttpClientTransport public abstract class AbstractHttpClientTransport extends ContainerLifeCycle implements HttpClientTransport
{ {
protected static final Logger LOG = Log.getLogger(HttpClientTransport.class); protected static final Logger LOG = LoggerFactory.getLogger(HttpClientTransport.class);
private HttpClient client; private HttpClient client;
private ConnectionPool.Factory factory; private ConnectionPool.Factory factory;

View File

@ -39,13 +39,13 @@ import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.QuotedCSV; import org.eclipse.jetty.http.QuotedCSV;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public abstract class AuthenticationProtocolHandler implements ProtocolHandler public abstract class AuthenticationProtocolHandler implements ProtocolHandler
{ {
public static final int DEFAULT_MAX_CONTENT_LENGTH = 16 * 1024; public static final int DEFAULT_MAX_CONTENT_LENGTH = 16 * 1024;
public static final Logger LOG = Log.getLogger(AuthenticationProtocolHandler.class); public static final Logger LOG = LoggerFactory.getLogger(AuthenticationProtocolHandler.class);
private final HttpClient client; private final HttpClient client;
private final int maxContentLength; private final int maxContentLength;
private final ResponseNotifier notifier; private final ResponseNotifier notifier;

View File

@ -37,14 +37,14 @@ import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.component.DumpableCollection; import org.eclipse.jetty.util.component.DumpableCollection;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Sweeper; import org.eclipse.jetty.util.thread.Sweeper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ManagedObject @ManagedObject
public class DuplexConnectionPool extends AbstractConnectionPool implements Sweeper.Sweepable public class DuplexConnectionPool extends AbstractConnectionPool implements Sweeper.Sweepable
{ {
private static final Logger LOG = Log.getLogger(DuplexConnectionPool.class); private static final Logger LOG = LoggerFactory.getLogger(DuplexConnectionPool.class);
private final ReentrantLock lock = new ReentrantLock(); private final ReentrantLock lock = new ReentrantLock();
private final Deque<Connection> idleConnections; private final Deque<Connection> idleConnections;

View File

@ -19,12 +19,12 @@
package org.eclipse.jetty.client; package org.eclipse.jetty.client;
import org.eclipse.jetty.client.api.Result; import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public abstract class HttpChannel public abstract class HttpChannel
{ {
protected static final Logger LOG = Log.getLogger(HttpChannel.class); protected static final Logger LOG = LoggerFactory.getLogger(HttpChannel.class);
private final HttpDestination _destination; private final HttpDestination _destination;
private final TimeoutCompleteListener _totalTimeout; private final TimeoutCompleteListener _totalTimeout;

View File

@ -74,13 +74,13 @@ import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.DumpableCollection; import org.eclipse.jetty.util.component.DumpableCollection;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.ThreadPool; import org.eclipse.jetty.util.thread.ThreadPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* <p>HttpClient provides an efficient, asynchronous, non-blocking implementation * <p>HttpClient provides an efficient, asynchronous, non-blocking implementation
@ -122,7 +122,7 @@ import org.eclipse.jetty.util.thread.ThreadPool;
public class HttpClient extends ContainerLifeCycle public class HttpClient extends ContainerLifeCycle
{ {
public static final String USER_AGENT = "Jetty/" + Jetty.VERSION; public static final String USER_AGENT = "Jetty/" + Jetty.VERSION;
private static final Logger LOG = Log.getLogger(HttpClient.class); private static final Logger LOG = LoggerFactory.getLogger(HttpClient.class);
private final ConcurrentMap<Origin, HttpDestination> destinations = new ConcurrentHashMap<>(); private final ConcurrentMap<Origin, HttpDestination> destinations = new ConcurrentHashMap<>();
private final ProtocolHandlers handlers = new ProtocolHandlers(); private final ProtocolHandlers handlers = new ProtocolHandlers();

View File

@ -34,12 +34,12 @@ import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.util.HttpCookieStore; import org.eclipse.jetty.util.HttpCookieStore;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public abstract class HttpConnection implements IConnection public abstract class HttpConnection implements IConnection
{ {
private static final Logger LOG = Log.getLogger(HttpConnection.class); private static final Logger LOG = LoggerFactory.getLogger(HttpConnection.class);
private final HttpDestination destination; private final HttpDestination destination;
private int idleTimeoutGuard; private int idleTimeoutGuard;

View File

@ -25,12 +25,12 @@ import java.util.concurrent.ConcurrentLinkedDeque;
import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.util.AttributesMap; import org.eclipse.jetty.util.AttributesMap;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class HttpConversation extends AttributesMap public class HttpConversation extends AttributesMap
{ {
private static final Logger LOG = Log.getLogger(HttpConversation.class); private static final Logger LOG = LoggerFactory.getLogger(HttpConversation.class);
private final Deque<HttpExchange> exchanges = new ConcurrentLinkedDeque<>(); private final Deque<HttpExchange> exchanges = new ConcurrentLinkedDeque<>();
private volatile List<Response.ResponseListener> listeners; private volatile List<Response.ResponseListener> listeners;

View File

@ -46,16 +46,16 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.component.DumpableCollection; import org.eclipse.jetty.util.component.DumpableCollection;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.Sweeper; import org.eclipse.jetty.util.thread.Sweeper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ManagedObject @ManagedObject
public abstract class HttpDestination extends ContainerLifeCycle implements Destination, Closeable, Callback, Dumpable public abstract class HttpDestination extends ContainerLifeCycle implements Destination, Closeable, Callback, Dumpable
{ {
protected static final Logger LOG = Log.getLogger(HttpDestination.class); protected static final Logger LOG = LoggerFactory.getLogger(HttpDestination.class);
private final HttpClient client; private final HttpClient client;
private final Origin origin; private final Origin origin;

View File

@ -22,12 +22,12 @@ import java.util.List;
import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result; import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class HttpExchange public class HttpExchange
{ {
private static final Logger LOG = Log.getLogger(HttpExchange.class); private static final Logger LOG = LoggerFactory.getLogger(HttpExchange.class);
private final HttpDestination destination; private final HttpDestination destination;
private final HttpRequest request; private final HttpRequest request;

View File

@ -38,13 +38,13 @@ import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpProxy extends ProxyConfiguration.Proxy public class HttpProxy extends ProxyConfiguration.Proxy
{ {
private static final Logger LOG = Log.getLogger(HttpProxy.class); private static final Logger LOG = LoggerFactory.getLogger(HttpProxy.class);
public HttpProxy(String host, int port) public HttpProxy(String host, int port)
{ {

View File

@ -42,8 +42,8 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.MathUtils; import org.eclipse.jetty.util.MathUtils;
import org.eclipse.jetty.util.component.Destroyable; import org.eclipse.jetty.util.component.Destroyable;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* {@link HttpReceiver} provides the abstract code to implement the various steps of the receive of HTTP responses. * {@link HttpReceiver} provides the abstract code to implement the various steps of the receive of HTTP responses.
@ -72,7 +72,7 @@ import org.eclipse.jetty.util.log.Logger;
*/ */
public abstract class HttpReceiver public abstract class HttpReceiver
{ {
protected static final Logger LOG = Log.getLogger(HttpReceiver.class); protected static final Logger LOG = LoggerFactory.getLogger(HttpReceiver.class);
private final AtomicReference<ResponseState> responseState = new AtomicReference<>(ResponseState.IDLE); private final AtomicReference<ResponseState> responseState = new AtomicReference<>(ResponseState.IDLE);
private final HttpChannel channel; private final HttpChannel channel;
@ -286,7 +286,7 @@ public abstract class HttpReceiver
catch (IOException x) catch (IOException x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug(x); LOG.debug("Unable to store cookies {} from {}", field, uri, x);
} }
} }

View File

@ -33,8 +33,8 @@ import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result; import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.client.util.BufferingResponseListener; import org.eclipse.jetty.client.util.BufferingResponseListener;
import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* Utility class that handles HTTP redirects. * Utility class that handles HTTP redirects.
@ -60,7 +60,7 @@ import org.eclipse.jetty.util.log.Logger;
*/ */
public class HttpRedirector public class HttpRedirector
{ {
private static final Logger LOG = Log.getLogger(HttpRedirector.class); private static final Logger LOG = LoggerFactory.getLogger(HttpRedirector.class);
private static final String SCHEME_REGEXP = "(^https?)"; private static final String SCHEME_REGEXP = "(^https?)";
private static final String AUTHORITY_REGEXP = "([^/?#]+)"; private static final String AUTHORITY_REGEXP = "([^/?#]+)";
// The location may be relative so the scheme://authority part may be missing // The location may be relative so the scheme://authority part may be missing

View File

@ -29,8 +29,8 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* <p>HttpSender abstracts the algorithm to send HTTP requests, so that subclasses only * <p>HttpSender abstracts the algorithm to send HTTP requests, so that subclasses only
@ -48,7 +48,7 @@ import org.eclipse.jetty.util.log.Logger;
*/ */
public abstract class HttpSender public abstract class HttpSender
{ {
private static final Logger LOG = Log.getLogger(HttpSender.class); private static final Logger LOG = LoggerFactory.getLogger(HttpSender.class);
private final ContentConsumer consumer = new ContentConsumer(); private final ContentConsumer consumer = new ContentConsumer();
private final AtomicReference<RequestState> requestState = new AtomicReference<>(RequestState.QUEUED); private final AtomicReference<RequestState> requestState = new AtomicReference<>(RequestState.QUEUED);
@ -244,7 +244,7 @@ public abstract class HttpSender
catch (Throwable x) catch (Throwable x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug(x); LOG.debug("Failure invoking demand()", x);
anyToFailure(x); anyToFailure(x);
} }
} }
@ -259,7 +259,7 @@ public abstract class HttpSender
catch (RejectedExecutionException x) catch (RejectedExecutionException x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug(x); LOG.debug("Exchange aborted {}", exchange, x);
abort(exchange, failure); abort(exchange, failure);
} }
} }

View File

@ -22,12 +22,12 @@ import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.Destination; import org.eclipse.jetty.client.api.Destination;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.LeakDetector; import org.eclipse.jetty.util.LeakDetector;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class LeakTrackingConnectionPool extends DuplexConnectionPool public class LeakTrackingConnectionPool extends DuplexConnectionPool
{ {
private static final Logger LOG = Log.getLogger(LeakTrackingConnectionPool.class); private static final Logger LOG = LoggerFactory.getLogger(LeakTrackingConnectionPool.class);
private final LeakDetector<Connection> leakDetector = new LeakDetector<Connection>() private final LeakDetector<Connection> leakDetector = new LeakDetector<Connection>()
{ {

View File

@ -32,13 +32,13 @@ import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.component.DumpableCollection; import org.eclipse.jetty.util.component.DumpableCollection;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Sweeper; import org.eclipse.jetty.util.thread.Sweeper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MultiplexConnectionPool extends AbstractConnectionPool implements ConnectionPool.Multiplexable, Sweeper.Sweepable public class MultiplexConnectionPool extends AbstractConnectionPool implements ConnectionPool.Multiplexable, Sweeper.Sweepable
{ {
private static final Logger LOG = Log.getLogger(MultiplexConnectionPool.class); private static final Logger LOG = LoggerFactory.getLogger(MultiplexConnectionPool.class);
private final HttpDestination destination; private final HttpDestination destination;
private final Deque<Holder> idleConnections; private final Deque<Holder> idleConnections;

View File

@ -36,8 +36,8 @@ import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* <p>ClientConnectionFactory for the * <p>ClientConnectionFactory for the
@ -446,7 +446,7 @@ public abstract class ProxyProtocolClientConnectionFactory implements ClientConn
protected abstract static class ProxyProtocolConnection extends AbstractConnection implements Callback protected abstract static class ProxyProtocolConnection extends AbstractConnection implements Callback
{ {
protected static final Logger LOG = Log.getLogger(ProxyProtocolConnection.class); protected static final Logger LOG = LoggerFactory.getLogger(ProxyProtocolConnection.class);
private final ClientConnectionFactory factory; private final ClientConnectionFactory factory;
private final Map<String, Object> context; private final Map<String, Object> context;

View File

@ -22,12 +22,12 @@ import java.nio.ByteBuffer;
import java.util.List; import java.util.List;
import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class RequestNotifier public class RequestNotifier
{ {
private static final Logger LOG = Log.getLogger(ResponseNotifier.class); private static final Logger LOG = LoggerFactory.getLogger(ResponseNotifier.class);
private final HttpClient client; private final HttpClient client;

View File

@ -32,12 +32,12 @@ import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.CountingCallback; import org.eclipse.jetty.util.CountingCallback;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class ResponseNotifier public class ResponseNotifier
{ {
private static final Logger LOG = Log.getLogger(ResponseNotifier.class); private static final Logger LOG = LoggerFactory.getLogger(ResponseNotifier.class);
public void notifyBegin(List<Response.ResponseListener> listeners, Response response) public void notifyBegin(List<Response.ResponseListener> listeners, Response response)
{ {

View File

@ -35,8 +35,8 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class Socks4Proxy extends ProxyConfiguration.Proxy public class Socks4Proxy extends ProxyConfiguration.Proxy
{ {
@ -78,7 +78,7 @@ public class Socks4Proxy extends ProxyConfiguration.Proxy
private static class Socks4ProxyConnection extends AbstractConnection implements Callback private static class Socks4ProxyConnection extends AbstractConnection implements Callback
{ {
private static final Pattern IPv4_PATTERN = Pattern.compile("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})"); private static final Pattern IPv4_PATTERN = Pattern.compile("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})");
private static final Logger LOG = Log.getLogger(Socks4ProxyConnection.class); private static final Logger LOG = LoggerFactory.getLogger(Socks4ProxyConnection.class);
private final Socks4Parser parser = new Socks4Parser(); private final Socks4Parser parser = new Socks4Parser();
private final ClientConnectionFactory connectionFactory; private final ClientConnectionFactory connectionFactory;

View File

@ -26,13 +26,13 @@ import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result; import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.io.CyclicTimeout; import org.eclipse.jetty.io.CyclicTimeout;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.Scheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TimeoutCompleteListener extends CyclicTimeout implements Response.CompleteListener public class TimeoutCompleteListener extends CyclicTimeout implements Response.CompleteListener
{ {
private static final Logger LOG = Log.getLogger(TimeoutCompleteListener.class); private static final Logger LOG = LoggerFactory.getLogger(TimeoutCompleteListener.class);
private final AtomicReference<Request> request = new AtomicReference<>(); private final AtomicReference<Request> request = new AtomicReference<>();

View File

@ -30,9 +30,9 @@ import org.eclipse.jetty.client.api.Destination;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.component.DumpableCollection; import org.eclipse.jetty.util.component.DumpableCollection;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.Scheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* <p>A connection pool that validates connections before * <p>A connection pool that validates connections before
@ -59,7 +59,7 @@ import org.eclipse.jetty.util.thread.Scheduler;
*/ */
public class ValidatingConnectionPool extends DuplexConnectionPool public class ValidatingConnectionPool extends DuplexConnectionPool
{ {
private static final Logger LOG = Log.getLogger(ValidatingConnectionPool.class); private static final Logger LOG = LoggerFactory.getLogger(ValidatingConnectionPool.class);
private final Scheduler scheduler; private final Scheduler scheduler;
private final long timeout; private final long timeout;

View File

@ -43,13 +43,13 @@ import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Sweeper; import org.eclipse.jetty.util.thread.Sweeper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpConnectionOverHTTP extends AbstractConnection implements IConnection, org.eclipse.jetty.io.Connection.UpgradeFrom, Sweeper.Sweepable public class HttpConnectionOverHTTP extends AbstractConnection implements IConnection, org.eclipse.jetty.io.Connection.UpgradeFrom, Sweeper.Sweepable
{ {
private static final Logger LOG = Log.getLogger(HttpConnectionOverHTTP.class); private static final Logger LOG = LoggerFactory.getLogger(HttpConnectionOverHTTP.class);
private final AtomicBoolean closed = new AtomicBoolean(); private final AtomicBoolean closed = new AtomicBoolean();
private final AtomicInteger sweeps = new AtomicInteger(); private final AtomicInteger sweeps = new AtomicInteger();

View File

@ -142,10 +142,10 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
private void process() private void process()
{ {
HttpConnectionOverHTTP connection = getHttpConnection();
EndPoint endPoint = connection.getEndPoint();
try try
{ {
HttpConnectionOverHTTP connection = getHttpConnection();
EndPoint endPoint = connection.getEndPoint();
while (true) while (true)
{ {
// Always parse even empty buffers to advance the parser. // Always parse even empty buffers to advance the parser.
@ -192,7 +192,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
catch (Throwable x) catch (Throwable x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug(x); LOG.debug("Unable to fill from endpoint {}", endPoint, x);
networkBuffer.clear(); networkBuffer.clear();
releaseNetworkBuffer(); releaseNetworkBuffer();
failAndClose(x); failAndClose(x);

View File

@ -87,7 +87,7 @@ public class HttpSenderOverHTTP extends HttpSender
catch (Throwable x) catch (Throwable x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug(x); LOG.debug("Unable to send headers on exchange {}", exchange, x);
callback.failed(x); callback.failed(x);
} }
} }
@ -108,7 +108,7 @@ public class HttpSenderOverHTTP extends HttpSender
catch (Throwable x) catch (Throwable x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug(x); LOG.debug("Unable to send content on {}", exchange, x);
callback.failed(x); callback.failed(x);
} }
} }

View File

@ -36,8 +36,8 @@ import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
public class ProxyProtocolClientConnectionFactory implements ClientConnectionFactory public class ProxyProtocolClientConnectionFactory implements ClientConnectionFactory
{ {
@ -61,7 +61,7 @@ public class ProxyProtocolClientConnectionFactory implements ClientConnectionFac
private class ProxyProtocolConnection extends AbstractConnection implements Callback private class ProxyProtocolConnection extends AbstractConnection implements Callback
{ {
private final Logger log = Log.getLogger(ProxyProtocolConnection.class); private final Logger log = LoggerFactory.getLogger(ProxyProtocolConnection.class);
private final Map<String, Object> context; private final Map<String, Object> context;
public ProxyProtocolConnection(EndPoint endPoint, Executor executor, Map<String, Object> context) public ProxyProtocolConnection(EndPoint endPoint, Executor executor, Map<String, Object> context)

View File

@ -28,8 +28,8 @@ import java.util.NoSuchElementException;
import org.eclipse.jetty.client.api.ContentProvider; import org.eclipse.jetty.client.api.ContentProvider;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* A {@link ContentProvider} for an {@link InputStream}. * A {@link ContentProvider} for an {@link InputStream}.
@ -56,7 +56,7 @@ import org.eclipse.jetty.util.log.Logger;
@Deprecated @Deprecated
public class InputStreamContentProvider implements ContentProvider, Callback, Closeable public class InputStreamContentProvider implements ContentProvider, Callback, Closeable
{ {
private static final Logger LOG = Log.getLogger(InputStreamContentProvider.class); private static final Logger LOG = LoggerFactory.getLogger(InputStreamContentProvider.class);
private final InputStreamContentProviderIterator iterator = new InputStreamContentProviderIterator(); private final InputStreamContentProviderIterator iterator = new InputStreamContentProviderIterator();
private final InputStream stream; private final InputStream stream;
@ -134,7 +134,7 @@ public class InputStreamContentProvider implements ContentProvider, Callback, Cl
} }
catch (IOException x) catch (IOException x)
{ {
LOG.ignore(x); LOG.trace("IGNORED", x);
} }
} }
} }
@ -202,7 +202,7 @@ public class InputStreamContentProvider implements ContentProvider, Callback, Cl
catch (Throwable x) catch (Throwable x)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug(x); LOG.debug("Failed to read", x);
if (failure == null) if (failure == null)
{ {
failure = x; failure = x;

View File

@ -42,8 +42,8 @@ import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* Implementation of {@link Listener} that produces an {@link InputStream} * Implementation of {@link Listener} that produces an {@link InputStream}
@ -76,8 +76,9 @@ import org.eclipse.jetty.util.log.Logger;
*/ */
public class InputStreamResponseListener extends Listener.Adapter public class InputStreamResponseListener extends Listener.Adapter
{ {
private static final Logger LOG = Log.getLogger(InputStreamResponseListener.class); private static final Logger LOG = LoggerFactory.getLogger(InputStreamResponseListener.class);
private static final Chunk EOF = new Chunk(BufferUtil.EMPTY_BUFFER, Callback.NOOP); private static final Chunk EOF = new Chunk(BufferUtil.EMPTY_BUFFER, Callback.NOOP);
private final Object lock = this; private final Object lock = this;
private final CountDownLatch responseLatch = new CountDownLatch(1); private final CountDownLatch responseLatch = new CountDownLatch(1);
private final CountDownLatch resultLatch = new CountDownLatch(1); private final CountDownLatch resultLatch = new CountDownLatch(1);

View File

@ -39,8 +39,8 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.io.RuntimeIOException;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* <p>A {@link ContentProvider} for form uploads with the {@code "multipart/form-data"} * <p>A {@link ContentProvider} for form uploads with the {@code "multipart/form-data"}
@ -69,7 +69,7 @@ import org.eclipse.jetty.util.log.Logger;
@Deprecated @Deprecated
public class MultiPartContentProvider extends AbstractTypedContentProvider implements AsyncContentProvider, Closeable public class MultiPartContentProvider extends AbstractTypedContentProvider implements AsyncContentProvider, Closeable
{ {
private static final Logger LOG = Log.getLogger(MultiPartContentProvider.class); private static final Logger LOG = LoggerFactory.getLogger(MultiPartContentProvider.class);
private static final byte[] COLON_SPACE_BYTES = new byte[]{':', ' '}; private static final byte[] COLON_SPACE_BYTES = new byte[]{':', ' '};
private static final byte[] CR_LF_BYTES = new byte[]{'\r', '\n'}; private static final byte[] CR_LF_BYTES = new byte[]{'\r', '\n'};

View File

@ -33,8 +33,8 @@ import java.util.NoSuchElementException;
import org.eclipse.jetty.client.api.ContentProvider; import org.eclipse.jetty.client.api.ContentProvider;
import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* <p>A {@link ContentProvider} for files using JDK 7's {@code java.nio.file} APIs.</p> * <p>A {@link ContentProvider} for files using JDK 7's {@code java.nio.file} APIs.</p>
@ -49,7 +49,7 @@ import org.eclipse.jetty.util.log.Logger;
@Deprecated @Deprecated
public class PathContentProvider extends AbstractTypedContentProvider public class PathContentProvider extends AbstractTypedContentProvider
{ {
private static final Logger LOG = Log.getLogger(PathContentProvider.class); private static final Logger LOG = LoggerFactory.getLogger(PathContentProvider.class);
private final Path filePath; private final Path filePath;
private final long fileSize; private final long fileSize;
@ -186,7 +186,7 @@ public class PathContentProvider extends AbstractTypedContentProvider
} }
catch (Throwable x) catch (Throwable x)
{ {
LOG.ignore(x); LOG.trace("IGNORED", x);
} }
} }
} }

View File

@ -41,13 +41,13 @@ import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.util.Attributes; import org.eclipse.jetty.util.Attributes;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.ietf.jgss.GSSContext; import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSException; import org.ietf.jgss.GSSException;
import org.ietf.jgss.GSSManager; import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName; import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid; import org.ietf.jgss.Oid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* <p>Implementation of the SPNEGO (or "Negotiate") authentication defined in RFC 4559.</p> * <p>Implementation of the SPNEGO (or "Negotiate") authentication defined in RFC 4559.</p>
@ -61,7 +61,7 @@ import org.ietf.jgss.Oid;
*/ */
public class SPNEGOAuthentication extends AbstractAuthentication public class SPNEGOAuthentication extends AbstractAuthentication
{ {
private static final Logger LOG = Log.getLogger(SPNEGOAuthentication.class); private static final Logger LOG = LoggerFactory.getLogger(SPNEGOAuthentication.class);
private static final String NEGOTIATE = HttpHeader.NEGOTIATE.asString(); private static final String NEGOTIATE = HttpHeader.NEGOTIATE.asString();
private final GSSManager gssManager = GSSManager.getInstance(); private final GSSManager gssManager = GSSManager.getInstance();

View File

@ -80,6 +80,7 @@ import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.toolchain.test.Net; import org.eclipse.jetty.toolchain.test.Net;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
@ -90,7 +91,6 @@ import org.eclipse.jetty.util.FuturePromise;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.SocketAddressResolver; import org.eclipse.jetty.util.SocketAddressResolver;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.DisabledIfSystemProperty;

View File

@ -35,13 +35,14 @@ import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.client.util.ByteBufferRequestContent; import org.eclipse.jetty.client.util.ByteBufferRequestContent;
import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource; import org.junit.jupiter.params.provider.ArgumentsSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
@ -49,6 +50,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
{ {
private static final Logger LOG = LoggerFactory.getLogger(HttpConnectionLifecycleTest.class);
@Override @Override
public HttpClient newHttpClient(HttpClientTransport transport) public HttpClient newHttpClient(HttpClientTransport transport)
{ {
@ -403,7 +406,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
Collection<Connection> activeConnections = connectionPool.getActiveConnections(); Collection<Connection> activeConnections = connectionPool.getActiveConnections();
assertEquals(0, activeConnections.size()); assertEquals(0, activeConnections.size());
Log.getLogger(HttpConnection.class).info("Expecting java.lang.IllegalStateException: HttpParser{s=CLOSED,..."); LOG.info("Expecting java.lang.IllegalStateException: HttpParser{s=CLOSED,...");
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
ByteBuffer buffer = ByteBuffer.allocate(16 * 1024 * 1024); ByteBuffer buffer = ByteBuffer.allocate(16 * 1024 * 1024);

Some files were not shown because too many files have changed in this diff Show More