From 3ebd13be3575a933cc2dfda8954f289fbd8d337b Mon Sep 17 00:00:00 2001 From: linghengqian Date: Sun, 26 Nov 2023 18:30:34 +0800 Subject: [PATCH] Update dependencies --- infra/expr/type/espresso/pom.xml | 100 ----------- .../EspressoInlineExpressionParser.java | 167 ------------------ ...here.infra.expr.spi.InlineExpressionParser | 18 -- .../EspressoInlineExpressionParserTest.java | 148 ---------------- pom.xml | 76 ++++---- proxy/frontend/core/pom.xml | 4 +- 6 files changed, 39 insertions(+), 474 deletions(-) delete mode 100644 infra/expr/type/espresso/pom.xml delete mode 100644 infra/expr/type/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java delete mode 100644 infra/expr/type/espresso/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser delete mode 100644 infra/expr/type/espresso/src/test/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParserTest.java diff --git a/infra/expr/type/espresso/pom.xml b/infra/expr/type/espresso/pom.xml deleted file mode 100644 index b538e1be97a6ee..00000000000000 --- a/infra/expr/type/espresso/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - 4.0.0 - - org.apache.shardingsphere - shardingsphere-infra-expr-type - 5.4.2-SNAPSHOT - - shardingsphere-infra-expr-espresso - ${project.artifactId} - - - 23.1.1 - - - - - org.apache.shardingsphere - shardingsphere-infra-expr-spi - ${project.version} - - - org.apache.shardingsphere - shardingsphere-infra-exception-core - ${project.version} - - - org.apache.shardingsphere - shardingsphere-infra-util - ${project.version} - - - org.apache.shardingsphere - shardingsphere-test-util - ${project.version} - test - - - - org.graalvm.polyglot - polyglot - ${graalvm.version} - - - org.graalvm.polyglot - java-community - ${graalvm.version} - pom - provided - - - - - - - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - copy-dependencies - - copy - - process-resources - - ${project.build.directory}/classes/espresso-need-libs - - - org.apache.groovy - groovy - ${groovy.version} - jar - true - - - true - - - - - - - diff --git a/infra/expr/type/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java b/infra/expr/type/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java deleted file mode 100644 index 70aac2441dafc7..00000000000000 --- a/infra/expr/type/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.expr.espresso; - -import com.google.common.base.Strings; -import com.google.common.collect.Sets; -import groovy.lang.GroovyShell; -import org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser; -import org.apache.shardingsphere.infra.util.groovy.GroovyUtils; -import org.graalvm.polyglot.Context; -import org.graalvm.polyglot.Value; - -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * Espresso inline expression parser. - */ -public final class EspressoInlineExpressionParser implements InlineExpressionParser { - - private static final String JAVA_CLASSPATH; - - private String inlineExpression; - - /** - * TODO espressoHome not defined not yet closed. - * Maybe sometimes we need `.option("java.Properties.org.graalvm.home", System.getenv("JAVA_HOME"))` - * - * @see org.graalvm.polyglot.Context - */ - private final Context context = Context.newBuilder() - .allowAllAccess(true) - .option("java.Classpath", JAVA_CLASSPATH) - .build(); - - static { - URL resource = Thread.currentThread().getContextClassLoader().getResource("espresso-need-libs"); - String dir = null == resource ? null : resource.getPath(); - JAVA_CLASSPATH = dir + File.separator + "groovy.jar"; - } - - @Override - public void init(final Properties props) { - inlineExpression = props.getProperty(INLINE_EXPRESSION_KEY); - } - - @Override - public String handlePlaceHolder() { - return handlePlaceHolder(inlineExpression); - } - - /** - * Replace all inline expression placeholders. - * - * @param inlineExpression inline expression with {@code $->} - * @return result inline expression with {@code $} - */ - private String handlePlaceHolder(final String inlineExpression) { - return inlineExpression.contains("$->{") ? inlineExpression.replaceAll("\\$->\\{", "\\$\\{") : inlineExpression; - } - - @Override - public List splitAndEvaluate() { - return Strings.isNullOrEmpty(inlineExpression) ? Collections.emptyList() : flatten(evaluate(GroovyUtils.split(handlePlaceHolder(inlineExpression)), context)); - } - - private List evaluate(final List inlineExpressions, final Context context) { - List result = new ArrayList<>(inlineExpressions.size()); - for (String each : inlineExpressions) { - StringBuilder expression = new StringBuilder(handlePlaceHolder(each)); - if (!each.startsWith("\"")) { - expression.insert(0, '"'); - } - if (!each.endsWith("\"")) { - expression.append('"'); - } - result.add(evaluate(expression.toString(), context)); - } - return result; - } - - private Value evaluate(final String expression, final Context context) { - return context.getBindings("java") - .getMember(GroovyShell.class.getName()) - .newInstance() - .invokeMember("parse", expression) - .invokeMember("run"); - } - - private List flatten(final List segments) { - List result = new ArrayList<>(); - for (Value each : segments) { - if (!each.isString()) { - result.addAll(assemblyCartesianSegments(each)); - } else { - result.add(each.toString()); - } - } - return result; - } - - private List assemblyCartesianSegments(final Value segment) { - Set> cartesianValues = getCartesianValues(segment); - List result = new ArrayList<>(cartesianValues.size()); - for (List each : cartesianValues) { - result.add(assemblySegment(each, segment)); - } - return result; - } - - @SuppressWarnings("unchecked") - private Set> getCartesianValues(final Value segment) { - Object[] temp = segment.invokeMember("getValues").as(Object[].class); - List> result = new ArrayList<>(temp.length); - for (Object each : temp) { - if (null == each) { - continue; - } - if (each instanceof Collection) { - result.add(((Collection) each).stream().map(Object::toString).collect(Collectors.toCollection(LinkedHashSet::new))); - } else { - result.add(Sets.newHashSet(each.toString())); - } - } - return Sets.cartesianProduct(result); - } - - private String assemblySegment(final List cartesianValue, final Value segment) { - String[] temp = segment.invokeMember("getStrings").as(String[].class); - StringBuilder result = new StringBuilder(); - for (int i = 0; i < temp.length; i++) { - result.append(temp[i]); - if (i < cartesianValue.size()) { - result.append(cartesianValue.get(i)); - } - } - return result.toString(); - } - - @Override - public String getType() { - return "ESPRESSO"; - } -} diff --git a/infra/expr/type/espresso/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser b/infra/expr/type/espresso/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser deleted file mode 100644 index 12e69c796a85c7..00000000000000 --- a/infra/expr/type/espresso/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -org.apache.shardingsphere.infra.expr.espresso.EspressoInlineExpressionParser diff --git a/infra/expr/type/espresso/src/test/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParserTest.java b/infra/expr/type/espresso/src/test/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParserTest.java deleted file mode 100644 index 594e58b51daf5f..00000000000000 --- a/infra/expr/type/espresso/src/test/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParserTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.expr.espresso; - -import org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser; -import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.test.util.PropertiesBuilder; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -import static org.hamcrest.CoreMatchers.hasItems; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; - -@Disabled("Unit tests for this class only run on GraalVM CE 23.0.1 For JDK17. Wait for https://github.com/oracle/graal/issues/7500 .") -class EspressoInlineExpressionParserTest { - - @Test - void assertEvaluateForExpressionIsNull() { - InlineExpressionParser parser = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", new Properties()); - List expected = parser.splitAndEvaluate(); - assertThat(expected, is(Collections.emptyList())); - } - - @Test - void assertEvaluateForSimpleString() { - List expected = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, " t_order_0, t_order_1 "))).splitAndEvaluate(); - assertThat(expected.size(), is(2)); - assertThat(expected, hasItems("t_order_0", "t_order_1")); - } - - @Test - void assertEvaluateForNull() { - List expected = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_order_${null}"))).splitAndEvaluate(); - assertThat(expected.size(), is(1)); - assertThat(expected, hasItems("t_order_")); - } - - @Test - void assertEvaluateForLiteral() { - List expected = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_order_${'xx'}"))).splitAndEvaluate(); - assertThat(expected.size(), is(1)); - assertThat(expected, hasItems("t_order_xx")); - } - - @Test - void assertEvaluateForArray() { - List expected = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_order_${[0, 1, 2]},t_order_item_${[0, 2]}"))).splitAndEvaluate(); - assertThat(expected.size(), is(5)); - assertThat(expected, hasItems("t_order_0", "t_order_1", "t_order_2", "t_order_item_0", "t_order_item_2")); - } - - @Test - void assertEvaluateForRange() { - List expected = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_order_${0..2},t_order_item_${0..1}"))).splitAndEvaluate(); - assertThat(expected.size(), is(5)); - assertThat(expected, hasItems("t_order_0", "t_order_1", "t_order_2", "t_order_item_0", "t_order_item_1")); - } - - @Test - void assertEvaluateForComplex() { - List expected = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_${['new','old']}_order_${1..2}, t_config"))).splitAndEvaluate(); - assertThat(expected.size(), is(5)); - assertThat(expected, hasItems("t_new_order_1", "t_new_order_2", "t_old_order_1", "t_old_order_2", "t_config")); - } - - @Test - void assertEvaluateForCalculate() { - List expected = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_${[\"new${1+2}\",'old']}_order_${1..2}"))).splitAndEvaluate(); - assertThat(expected.size(), is(4)); - assertThat(expected, hasItems("t_new3_order_1", "t_new3_order_2", "t_old_order_1", "t_old_order_2")); - } - - @Test - void assertEvaluateForExpressionPlaceHolder() { - List expected = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_$->{[\"new$->{1+2}\",'old']}_order_$->{1..2}"))).splitAndEvaluate(); - assertThat(expected.size(), is(4)); - assertThat(expected, hasItems("t_new3_order_1", "t_new3_order_2", "t_old_order_1", "t_old_order_2")); - } - - @Test - void assertEvaluateForLong() { - StringBuilder expression = new StringBuilder(); - for (int i = 0; i < 1024; i++) { - expression.append("ds_"); - expression.append(i / 64); - expression.append(".t_user_"); - expression.append(i); - if (i != 1023) { - expression.append(","); - } - } - List expected = TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, expression.toString()))).splitAndEvaluate(); - assertThat(expected.size(), is(1024)); - assertThat(expected, hasItems("ds_0.t_user_0", "ds_15.t_user_1023")); - } - - @Test - void assertHandlePlaceHolder() { - assertThat(TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_$->{[\"new$->{1+2}\"]}"))).handlePlaceHolder(), is("t_${[\"new${1+2}\"]}")); - assertThat(TypedSPILoader.getService(InlineExpressionParser.class, "ESPRESSO", PropertiesBuilder.build( - new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_${[\"new$->{1+2}\"]}"))).handlePlaceHolder(), is("t_${[\"new${1+2}\"]}")); - } - - /** - * This method needs to avoid returning a `Closure` class instance, and instead return the result of `Closure#call`. - * Because `Value#as` does not allow this type to be returned from the guest JVM. - * - * @see groovy.lang.Closure - * @see org.graalvm.polyglot.Value - */ - @Test - void assertEvaluateClosure() { - assertThrows(UnsupportedOperationException.class, () -> TypedSPILoader.getService( - InlineExpressionParser.class, "ESPRESSO", - PropertiesBuilder.build(new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "${1+2}"))).evaluateClosure().call().toString()); - } -} diff --git a/pom.xml b/pom.xml index d122c2a47fcdb8..f1a53874e94634 100644 --- a/pom.xml +++ b/pom.xml @@ -63,53 +63,53 @@ **/autogen/**/* - 32.1.2-jre - 3.39.0 - 2.22.0 - 1.3 + 32.1.3-jre + 3.40.0 + 2.23.0 + 2.8 - 3.12.0 + 3.14.0 4.4 1.16.0 3.6.1 2.9.3 - 2.14.2 + 2.14.3 - 4.10.1 + 4.13.1 2.2 2.10.1 2.16.0 2.8.0 - 2.4.10 - 2.4.9 - 9.3 - 4.0.10 - 2.3.31 - 1.14.8 + 2.5.0 + 2.5.0 + 9.6 + 4.0.16 + 2.3.32 + 1.14.10 8.0.0 2.3.9 1.35.0 - 2.9.3 + 2.10.0 6.0.0 5.12.4.Final 7.6.0.Final 3.2.1.Final - 1.6.1 + 2.0.0 - 4.1.99.Final - 1.70 + 4.1.101.Final + 1.77 5.5.0 - 3.9.0 - 0.12.0 + 3.9.1 + 0.13.0 0.7.6 1.4.5 - 1.58.0 - 3.21.12 + 1.59.0 + 3.25.1 4.5.14 4.12.0 @@ -117,35 +117,33 @@ 1.7.36 1.2.13 - 1.2 + 1.3.0 1.18.30 - 42.4.3 - 8.0.31 - 6.1.7.jre8-preview - 1.7.1 + 42.6.0 + 8.2.0 + 12.4.2.jre8 + 2.5.6 2.2.224 - 3.1.0-og - 2.4.2 + 5.1.0-og + 2.7.11 4.0.3 - 3.14.15 + 3.14.16 - 0.11.0 - 0.16.1 - 1.31.0 - 1.9.10 + 0.16.0 + 0.20.0 + 1.32.0 + 1.9.21 - 5.10.0 + 5.10.1 2.2 4.11.0 4.2.0 1.19.3 - 1.9.0 - - 21.2.0 + 1.10.0 0.6.1 @@ -341,12 +339,12 @@ org.bouncycastle - bcpkix-jdk15on + bcpkix-jdk18on ${bouncycastle.version} org.bouncycastle - bctls-jdk15on + bctls-jdk18on ${bouncycastle.version} diff --git a/proxy/frontend/core/pom.xml b/proxy/frontend/core/pom.xml index 6fb9aaf4115654..f9ddbc204b9ce0 100644 --- a/proxy/frontend/core/pom.xml +++ b/proxy/frontend/core/pom.xml @@ -98,11 +98,11 @@ org.bouncycastle - bcpkix-jdk15on + bcpkix-jdk18on org.bouncycastle - bctls-jdk15on + bctls-jdk18on