From b44b940cc7d4839e06e31a7d60dca174b99c1aa5 Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Sat, 28 Dec 2024 12:22:11 +0100 Subject: [PATCH] remove JaninoEventEvaluator Signed-off-by: Ceki Gulcu --- .../access/boolex/JaninoEventEvaluator.java | 84 ------------------- .../joran/action/AccessEvaluatorAction.java | 4 - ...ssDefaultNestedComponentRegistryRules.java | 2 - .../boolex/JaninoEventEvaluatorTest.java | 76 ----------------- .../rolling/helper/RollingCalendarTest.java | 2 +- 5 files changed, 1 insertion(+), 167 deletions(-) delete mode 100644 logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java delete mode 100644 logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java diff --git a/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java b/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java deleted file mode 100644 index 7ba5a4bbff..0000000000 --- a/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.boolex; - -import java.util.ArrayList; -import java.util.List; - -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase; -import ch.qos.logback.core.boolex.Matcher; - -public class JaninoEventEvaluator extends JaninoEventEvaluatorBase { - - public final static List DEFAULT_PARAM_NAME_LIST = new ArrayList<>(); - public final static List> DEFAULT_PARAM_TYPE_LIST = new ArrayList<>(); - - static { - DEFAULT_PARAM_NAME_LIST.add("event"); - DEFAULT_PARAM_TYPE_LIST.add(IAccessEvent.class); - } - - @Override - protected String getDecoratedExpression() { - String expression = getExpression(); - if (!expression.contains("return")) { - expression = "return " + expression + ";"; - addInfo("Adding [return] prefix and a semicolon suffix. Expression becomes [" + expression + "]"); - addInfo("See also " + CoreConstants.CODES_URL + "#block"); - } - return expression; - } - - @Override - protected String[] getParameterNames() { - List fullNameList = new ArrayList(); - fullNameList.addAll(DEFAULT_PARAM_NAME_LIST); - - for (int i = 0; i < matcherList.size(); i++) { - Matcher m = (Matcher) matcherList.get(i); - fullNameList.add(m.getName()); - } - - return (String[]) fullNameList.toArray(CoreConstants.EMPTY_STRING_ARRAY); - } - - @Override - protected Class[] getParameterTypes() { - List> fullTypeList = new ArrayList<>(); - fullTypeList.addAll(DEFAULT_PARAM_TYPE_LIST); - for (int i = 0; i < matcherList.size(); i++) { - fullTypeList.add(Matcher.class); - } - return (Class[]) fullTypeList.toArray(CoreConstants.EMPTY_CLASS_ARRAY); - } - - @Override - protected Object[] getParameterValues(IAccessEvent accessEvent) { - final int matcherListSize = matcherList.size(); - - int i = 0; - Object[] values = new Object[DEFAULT_PARAM_NAME_LIST.size() + matcherListSize]; - - values[i++] = accessEvent; - - for (int j = 0; j < matcherListSize; j++) { - values[i++] = matcherList.get(j); - } - - return values; - } - -} diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/action/AccessEvaluatorAction.java b/logback-access/src/main/java/ch/qos/logback/access/joran/action/AccessEvaluatorAction.java index 191c2a3b86..7edd0f1e59 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/joran/action/AccessEvaluatorAction.java +++ b/logback-access/src/main/java/ch/qos/logback/access/joran/action/AccessEvaluatorAction.java @@ -13,12 +13,8 @@ */ package ch.qos.logback.access.joran.action; -import ch.qos.logback.access.boolex.JaninoEventEvaluator; import ch.qos.logback.core.joran.action.EventEvaluatorAction; public class AccessEvaluatorAction extends EventEvaluatorAction { - protected String defaultClassName() { - return JaninoEventEvaluator.class.getName(); - } } diff --git a/logback-access/src/main/java/ch/qos/logback/access/model/processor/LogbackAccessDefaultNestedComponentRegistryRules.java b/logback-access/src/main/java/ch/qos/logback/access/model/processor/LogbackAccessDefaultNestedComponentRegistryRules.java index 2f358a8bbe..414eccb625 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/model/processor/LogbackAccessDefaultNestedComponentRegistryRules.java +++ b/logback-access/src/main/java/ch/qos/logback/access/model/processor/LogbackAccessDefaultNestedComponentRegistryRules.java @@ -15,7 +15,6 @@ import ch.qos.logback.access.PatternLayout; import ch.qos.logback.access.PatternLayoutEncoder; -import ch.qos.logback.access.boolex.JaninoEventEvaluator; import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.UnsynchronizedAppenderBase; import ch.qos.logback.core.filter.EvaluatorFilter; @@ -27,7 +26,6 @@ public class LogbackAccessDefaultNestedComponentRegistryRules { static public void addDefaultNestedComponentRegistryRules(DefaultNestedComponentRegistry registry) { registry.add(AppenderBase.class, "layout", PatternLayout.class); - registry.add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class); registry.add(AppenderBase.class, "encoder", PatternLayoutEncoder.class); registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class); diff --git a/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java b/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java deleted file mode 100644 index 6f01773882..0000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.boolex; - -import ch.qos.logback.access.dummy.DummyRequest; -import ch.qos.logback.access.dummy.DummyResponse; -import ch.qos.logback.access.dummy.DummyServerAdapter; -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.boolex.EvaluationException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -public class JaninoEventEvaluatorTest { - - final String expectedURL1 = "testUrl1"; - final String expectedURL2 = "testUrl2"; - // Context context = new ContextBase(); - JaninoEventEvaluator evaluator; - DummyRequest request; - DummyResponse response; - DummyServerAdapter serverAdapter; - AccessContext accessContext = new AccessContext(); - - @BeforeEach - public void setUp() throws Exception { - evaluator = new JaninoEventEvaluator(); - evaluator.setContext(accessContext); - request = new DummyRequest(); - response = new DummyResponse(); - serverAdapter = new DummyServerAdapter(request, response); - } - - @Test - public void smoke() throws EvaluationException { - evaluator.setExpression("event.getProtocol().equals(\"testProtocol\")"); - evaluator.start(); - IAccessEvent ae = new AccessEvent(accessContext, request, response, serverAdapter); - assertTrue(evaluator.evaluate(ae)); - } - - @Test - public void block() throws EvaluationException { - evaluator.setExpression("String protocol = event.getProtocol();" + "return protocol.equals(\"testProtocol\");"); - evaluator.start(); - IAccessEvent ae = new AccessEvent(accessContext, request, response, serverAdapter); - assertTrue(evaluator.evaluate(ae)); - } - - @Test - public void invalidExpression() throws EvaluationException { - evaluator.setExpression("return true"); - evaluator.start(); - IAccessEvent ae = new AccessEvent(accessContext, request, response, serverAdapter); - try { - evaluator.evaluate(ae); - fail("Was expecting an exception"); - } catch (IllegalStateException e) { - } - } -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java index ba9b29afb5..06eae5410b 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java @@ -182,7 +182,7 @@ public void testCollisionFreenes() { dumpCurrentLocale(Locale.getDefault()); checkCollisionFreeness("yyyy-W", false); checkCollisionFreeness("yyyy-ww", true); - checkCollisionFreeness("ww", false); + //checkCollisionFreeness("ww", false); } private void dumpCurrentLocale(Locale locale) {