From d997a1171b29d01d9a2291510f082a8637202e0d Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 10 Jun 2021 09:04:50 -0500 Subject: [PATCH] Issue #6354 - OSGI manifest for slf4j-api packages lower limit should be 1.7 (#6381) Issue #6354 - OSGI manifest for slf4j-api packages lower limit should be 1.7 * Fixed OSGi manifest in all jars. * Make osgi tests work with slf4j < 2.0.0. This required to remove the dependency on SLF4J from the demos. Signed-off-by: Joakim Erdfelt Co-authored-by: Jan Bartel --- demos/demo-jetty-webapp/pom.xml | 9 ---- .../src/main/java/com/acme/ChatServlet.java | 22 +++------ .../src/main/java/com/acme/Dump.java | 8 ++-- .../main/java/com/acme/SecureModeServlet.java | 7 +-- .../src/main/java/com/acme/TestFilter.java | 7 +-- jetty-alpn/jetty-alpn-client/pom.xml | 2 +- .../jetty-alpn-conscrypt-client/pom.xml | 2 +- .../jetty-alpn-conscrypt-server/pom.xml | 2 +- jetty-annotations/pom.xml | 2 +- jetty-jndi/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot/pom.xml | 47 +++++++++---------- jetty-osgi/test-jetty-osgi-context/pom.xml | 13 ++++- jetty-osgi/test-jetty-osgi-server/pom.xml | 13 ++++- jetty-osgi/test-jetty-osgi/pom.xml | 12 +++++ .../eclipse/jetty/osgi/test/TestOSGiUtil.java | 33 ++++++++++--- .../test/resources/simplelogger.properties | 1 + jetty-plus/pom.xml | 2 +- pom.xml | 5 +- 18 files changed, 108 insertions(+), 81 deletions(-) create mode 100644 jetty-osgi/test-jetty-osgi/src/test/resources/simplelogger.properties diff --git a/demos/demo-jetty-webapp/pom.xml b/demos/demo-jetty-webapp/pom.xml index 27c416ccdfe7..5709abf0b987 100644 --- a/demos/demo-jetty-webapp/pom.xml +++ b/demos/demo-jetty-webapp/pom.xml @@ -126,15 +126,6 @@ - - org.slf4j - slf4j-api - - - org.eclipse.jetty - jetty-slf4j-impl - compile - org.eclipse.jetty jetty-servlets diff --git a/demos/demo-jetty-webapp/src/main/java/com/acme/ChatServlet.java b/demos/demo-jetty-webapp/src/main/java/com/acme/ChatServlet.java index 2856ff8f87d1..6b456b020007 100644 --- a/demos/demo-jetty-webapp/src/main/java/com/acme/ChatServlet.java +++ b/demos/demo-jetty-webapp/src/main/java/com/acme/ChatServlet.java @@ -27,17 +27,12 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - // Simple asynchronous Chat room. // This does not handle duplicate usernames or multiple frames/tabs from the same browser // Some code is duplicated for clarity. @SuppressWarnings("serial") public class ChatServlet extends HttpServlet { - private static final Logger LOG = LoggerFactory.getLogger(ChatServlet.class); - private long asyncTimeout = 10000; @Override @@ -63,7 +58,7 @@ class Member implements AsyncListener @Override public void onTimeout(AsyncEvent event) throws IOException { - LOG.debug("resume request"); + getServletContext().log("resume request"); AsyncContext async = _async.get(); if (async != null && _async.compareAndSet(async, null)) { @@ -102,10 +97,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) String message = request.getParameter("message"); String username = request.getParameter("user"); - LOG.debug("doPost called. join={},message={},username={}", join, message, username); + getServletContext().log("doPost called. join=" + join + " message=" + message + " username=" + username); if (username == null) { - LOG.debug("no parameter user set, sending 503"); + getServletContext().log("no parameter user set, sending 503"); response.sendError(503, "user==null"); return; } @@ -125,14 +120,14 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) { synchronized (member) { - LOG.debug("Queue size: {}", member._queue.size()); + getServletContext().log("Queue size: " + member._queue.size()); if (!member._queue.isEmpty()) { sendSingleMessage(response, member); } else { - LOG.debug("starting async"); + getServletContext().log("starting async"); AsyncContext async = request.startAsync(); async.setTimeout(asyncTimeout); async.addListener(member); @@ -147,7 +142,7 @@ private Member getMember(String username, Map room) Member member = room.get(username); if (member == null) { - LOG.debug("user: {} in room: {} doesn't exist. Creating new user.", username, room); + getServletContext().log("user: " + username + " in room: " + room + " doesn't exist. Creating new user."); member = new Member(username); room.put(username, member); } @@ -159,7 +154,7 @@ private Map getRoom(String path) Map room = _rooms.get(path); if (room == null) { - LOG.debug("room: {} doesn't exist. Creating new room.", path); + getServletContext().log("room: " + path + " doesn't exist. Creating new room."); room = new HashMap<>(); _rooms.put(path, room); } @@ -192,7 +187,6 @@ private void sendSingleMessage(HttpServletResponse response, Member member) thro private void sendMessageToAllMembers(String message, String username, Map room) { - LOG.debug("Sending message: {} from: {}", message, username); for (Member m : room.values()) { synchronized (m) @@ -202,10 +196,8 @@ private void sendMessageToAllMembers(String message, String username, Map"); - LOG.info("testing logging"); + getServletContext().log("testing logging"); out.println("status: SUCCESS - expected
"); } catch (SecurityException e) diff --git a/demos/demo-jetty-webapp/src/main/java/com/acme/TestFilter.java b/demos/demo-jetty-webapp/src/main/java/com/acme/TestFilter.java index 7493f1ba4b25..f09b0f50bebb 100644 --- a/demos/demo-jetty-webapp/src/main/java/com/acme/TestFilter.java +++ b/demos/demo-jetty-webapp/src/main/java/com/acme/TestFilter.java @@ -27,9 +27,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * TestFilter. * @@ -39,8 +36,6 @@ */ public class TestFilter implements Filter { - private static final Logger LOG = LoggerFactory.getLogger(TestFilter.class); - private boolean _remote; private ServletContext _context; private final Set _allowed = new HashSet(); @@ -54,7 +49,7 @@ public void init(FilterConfig filterConfig) throws ServletException _allowed.add("/jetty_banner.gif"); _allowed.add("/remote.html"); - LOG.debug("TestFilter#remote=" + _remote); + filterConfig.getServletContext().log("TestFilter#remote=" + _remote); } @Override diff --git a/jetty-alpn/jetty-alpn-client/pom.xml b/jetty-alpn/jetty-alpn-client/pom.xml index a577cfd699ee..c27fb3dd79cc 100644 --- a/jetty-alpn/jetty-alpn-client/pom.xml +++ b/jetty-alpn/jetty-alpn-client/pom.xml @@ -24,7 +24,7 @@ - org.eclipse.jetty.alpn;resolution:=optional,* + ${osgi.slf4j.import.packages},org.eclipse.jetty.alpn;resolution:=optional,* osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional, osgi.serviceloader; filter:="(osgi.serviceloader=org.eclipse.jetty.io.ssl.ALPNProcessor$Client)";resolution:=optional;cardinality:=multiple diff --git a/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml b/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml index 5f1b5180a482..7e54dc25f4a6 100644 --- a/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml +++ b/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml @@ -52,7 +52,7 @@ Conscrypt Client ALPN - org.conscrypt;version="${conscrypt.version}",* + ${osgi.slf4j.import.packages},org.conscrypt;version="${conscrypt.version}",* * osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional osgi.serviceloader; osgi.serviceloader=org.eclipse.jetty.io.ssl.ALPNProcessor$Client diff --git a/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml b/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml index 554fd99abc25..e9ca1cc140f0 100644 --- a/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml +++ b/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml @@ -80,7 +80,7 @@ Conscrypt ALPN - org.conscrypt;version="${conscrypt.version}",* + ${osgi.slf4j.import.packages},org.conscrypt;version="${conscrypt.version}",* osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional osgi.serviceloader;osgi.serviceloader=org.eclipse.jetty.io.ssl.ALPNProcessor$Server <_nouses>true diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index 004c3e4775c8..9429961dfc94 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -30,7 +30,7 @@ true - org.objectweb.asm;version="5",* + ${osgi.slf4j.import.packages},org.objectweb.asm;version="5",* osgi.serviceloader; filter:="(osgi.serviceloader=javax.servlet.ServletContainerInitializer)";resolution:=optional;cardinality:=multiple, osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index ef93ea29417d..011a72d405c9 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -31,7 +31,7 @@ true - javax.mail.*;resolution:=optional,* + ${osgi.slf4j.import.packages},javax.mail.*;resolution:=optional,* diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index c75a930bdf9b..0b02f4c57365 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -71,30 +71,29 @@ org.eclipse.jetty.osgi.boot;singleton:=true org.eclipse.jetty.osgi.boot.JettyBootstrapActivator org.eclipse.jetty.*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;+;${parsedVersion.osgiVersion}))" - javax.mail;version="1.4.0";resolution:=optional, - javax.mail.event;version="1.4.0";resolution:=optional, - javax.mail.internet;version="1.4.0";resolution:=optional, - javax.mail.search;version="1.4.0";resolution:=optional, - javax.mail.util;version="1.4.0";resolution:=optional, - javax.servlet;version="[$(version;==;${servlet.api.version}),$(version;+;${servlet.api.version}))", - javax.servlet.http;version="[$(version;==;${servlet.api.version}),$(version;+;${servlet.api.version}))", - javax.transaction;version="1.1.0";resolution:=optional, - javax.transaction.xa;version="1.1.0";resolution:=optional, - org.objectweb.asm;version="$(version;=;${asm.version})";resolution:=optional, - org.osgi.framework, - org.osgi.service.cm;version="1.4.0", - org.osgi.service.event;version="1.4.0", - org.osgi.service.packageadmin, - org.osgi.service.startlevel;version="1.0.0", - org.osgi.service.url;version="1.0.0", - org.osgi.util.tracker;version="1.3.0", - org.slf4j;resolution:=optional, - org.slf4j.spi;resolution:=optional, - org.slf4j.helpers;resolution:=optional, - org.xml.sax, - org.xml.sax.helpers, - org.eclipse.jetty.annotations;resolution:=optional, - * + + ${osgi.slf4j.import.packages}, + javax.mail;version="1.4.0";resolution:=optional, + javax.mail.event;version="1.4.0";resolution:=optional, + javax.mail.internet;version="1.4.0";resolution:=optional, + javax.mail.search;version="1.4.0";resolution:=optional, + javax.mail.util;version="1.4.0";resolution:=optional, + javax.servlet;version="[$(version;==;${servlet.api.version}),$(version;+;${servlet.api.version}))", + javax.servlet.http;version="[$(version;==;${servlet.api.version}),$(version;+;${servlet.api.version}))", + javax.transaction;version="1.1.0";resolution:=optional, + javax.transaction.xa;version="1.1.0";resolution:=optional, + org.objectweb.asm;version="$(version;=;${asm.version})";resolution:=optional, + org.osgi.framework, + org.osgi.service.cm;version="1.4.0", + org.osgi.service.event;version="1.4.0", + org.osgi.service.packageadmin, + org.osgi.service.startlevel;version="1.0.0", + org.osgi.service.url;version="1.0.0", + org.osgi.util.tracker;version="1.3.0", + org.xml.sax, + org.xml.sax.helpers, + org.eclipse.jetty.annotations;resolution:=optional, + * osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)" diff --git a/jetty-osgi/test-jetty-osgi-context/pom.xml b/jetty-osgi/test-jetty-osgi-context/pom.xml index ee75b3a3d9c0..ff9585fd152b 100644 --- a/jetty-osgi/test-jetty-osgi-context/pom.xml +++ b/jetty-osgi/test-jetty-osgi-context/pom.xml @@ -74,7 +74,18 @@ compilation time. --> <_nouses>true - javax.servlet;version="[3.1,4.1)", javax.servlet.resources;version="[3.1,4.1)", org.osgi.framework, org.osgi.service.cm;version="1.2.0", org.osgi.service.packageadmin, org.osgi.service.startlevel;version="1.0.0", org.osgi.service.url;version="1.0.0", org.osgi.util.tracker;version="1.3.0", org.slf4j;resolution:=optional, org.slf4j.spi;resolution:=optional, org.slf4j.helpers;resolution:=optional, org.xml.sax, org.xml.sax.helpers, * + ${osgi.slf4j.import.packages}, + javax.servlet;version="[3.1,4.1)", + javax.servlet.resources;version="[3.1,4.1)", + org.osgi.framework, + org.osgi.service.cm;version="1.2.0", + org.osgi.service.packageadmin, + org.osgi.service.startlevel;version="1.0.0", + org.osgi.service.url;version="1.0.0", + org.osgi.util.tracker;version="1.3.0", + org.xml.sax, + org.xml.sax.helpers, + * org.eclipse.jetty.*;version="[$(version;==;${parsedVersion.osgiVersion}),$(version;+;${parsedVersion.osgiVersion}))" diff --git a/jetty-osgi/test-jetty-osgi-server/pom.xml b/jetty-osgi/test-jetty-osgi-server/pom.xml index b841cae9d5ed..8b28b4a4c5fb 100644 --- a/jetty-osgi/test-jetty-osgi-server/pom.xml +++ b/jetty-osgi/test-jetty-osgi-server/pom.xml @@ -66,7 +66,18 @@ compilation time. --> <_nouses>true - javax.servlet;version="[3.1,4.1)", javax.servlet.resources;version="[3.1,4.1)", org.osgi.framework, org.osgi.service.cm;version="1.2.0", org.osgi.service.packageadmin, org.osgi.service.startlevel;version="1.0.o", org.osgi.service.url;version="1.0.0", org.osgi.util.tracker;version="1.3.0", org.slf4j;resolution:=optional, org.slf4j.spi;resolution:=optional, org.slf4j.helpers;resolution:=optional, org.xml.sax, org.xml.sax.helpers, * + ${osgi.slf4j.import.packages}, + javax.servlet;version="[3.1,4.1)", + javax.servlet.resources;version="[3.1,4.1)", + org.osgi.framework, + org.osgi.service.cm;version="1.2.0", + org.osgi.service.packageadmin, + org.osgi.service.startlevel;version="1.0.0", + org.osgi.service.url;version="1.0.0", + org.osgi.util.tracker;version="1.3.0", + org.xml.sax, + org.xml.sax.helpers, + * org.eclipse.jetty.*;version="[$(version;==;${parsedVersion.osgiVersion}),$(version;+;${parsedVersion.osgiVersion}))" diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 4f787c7d9ec0..bdf15a204e84 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -135,6 +135,18 @@
+ + org.slf4j + slf4j-api + 1.7.30 + test + + + org.slf4j + slf4j-simple + 1.7.30 + test + org.eclipse.jetty jetty-slf4j-impl diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java index daa3f96dc314..088ee4e308e6 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java @@ -142,13 +142,36 @@ public static List