diff --git a/build.gradle b/build.gradle index a41d9aedd3..1f15e59fdc 100644 --- a/build.gradle +++ b/build.gradle @@ -57,7 +57,7 @@ def springVersion = '4.2.0.RELEASE' def springSecurityVersion = '4.0.2.RELEASE' def servletApi = [group: 'org.apache.tomcat', name: 'tomcat-servlet-api', version: '7.0.53'] -def groovyArtifact = [group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.1.6'] +def groovyArtifact = 'org.codehaus.groovy:groovy-all:2.4.4' //def asm = [group: 'org.ow2.asm', name: 'asm', version: '5.0.3'] def poi = [group: 'com.haulmont.thirdparty', name: 'poi', version: '3.9.20130515'] def postgres = [group: 'postgresql', name: 'postgresql', version: '9.1-901.jdbc4'] @@ -76,24 +76,24 @@ configure([sharedLibModule, globalModule, coreModule, clientModule, guiModule, apply(plugin: 'cuba') dependencies { - compile(group: 'commons-logging', name: 'commons-logging', version: '1.1.1') + compile('commons-logging:commons-logging:1.2') compile(group: 'commons-lang', name: 'commons-lang', version: '2.6') compile(group: 'commons-collections', name: 'commons-collections', version: '3.2.1') - compile(group: 'commons-io', name: 'commons-io', version: '1.4') - compile(group: 'commons-codec', name: 'commons-codec', version: '1.6') - compile(group: 'commons-cli', name: 'commons-cli', version: '1.2') - compile(group: 'commons-pool', name: 'commons-pool', version: '1.5.1') - compile(group: 'org.apache.commons', name: 'commons-compress', version: '1.1') + compile('commons-io:commons-io:2.4') + compile('commons-codec:commons-codec:1.10') + compile('commons-cli:commons-cli:1.3.1') + compile('org.apache.commons:commons-pool2:2.4.2') + compile('org.apache.commons:commons-compress:1.9') compile(group: 'dom4j', name: 'dom4j', version: '1.6.1') - compile(group: 'com.sun.mail', name: 'javax.mail', version: '1.5.1') + compile('com.sun.mail:javax.mail:1.5.4') compile(group: 'log4j', name: 'log4j', version: '1.2.16') compile(group: 'org.perf4j', name: 'perf4j', version: '0.9.16') - compile(group: 'com.google.code.findbugs', name: 'jsr305', version: '2.0.3') + compile('com.google.code.findbugs:jsr305:3.0.0') compile(group: 'com.haulmont.thirdparty', name: 'javaee-api', version: '6.0.20091228') compile(groovyArtifact) compile(group: 'antlr', name: 'antlr', version: '2.7.7') // compile(asm) - compile(group: 'com.google.guava', name: 'guava', version: '16.0.1') + compile('com.google.guava:guava:18.0') compile 'org.eclipse.persistence:javax.persistence:2.1.0' compile 'org.eclipse.persistence:commonj.sdo:2.1.1' @@ -101,7 +101,7 @@ configure([sharedLibModule, globalModule, coreModule, clientModule, guiModule, compile 'com.haulmont.thirdparty:eclipselink:2.6.0.cuba.1' compile(group: 'org.antlr', name: 'antlr-runtime', version: '3.5.2') - compile(group: 'org.freemarker', name: 'freemarker', version: '2.3.16') + compile('org.freemarker:freemarker:2.3.23') compile(group: 'aopalliance', name: 'aopalliance', version: '1.0') compile(group: 'org.springframework', name: 'spring-core', version: springVersion) compile(group: 'org.springframework', name: 'spring-beans', version: springVersion) @@ -240,10 +240,10 @@ configure(coreModule) { runtime(group: 'xmlpull', name: 'xmlpull', version: '1.1.3.1') compile(group: 'org.ocpsoft.prettytime', name: 'prettytime-nlp', version: '3.2.5.Final') compile(group: 'org.jgroups', name: 'jgroups', version: '3.6.1.Final') - compile(group: 'org.aspectj', name: 'aspectjrt', version: '1.8.4') - compile(group: 'org.aspectj', name: 'aspectjweaver', version: '1.8.4') - compile(group: 'org.mybatis', name: 'mybatis', version: '3.2.7') - compile(group: 'org.mybatis', name: 'mybatis-spring', version: '1.2.2') + compile('org.aspectj:aspectjrt:1.8.6') + compile('org.aspectj:aspectjweaver:1.8.6') + compile('org.mybatis:mybatis:3.3.0') + compile('org.mybatis:mybatis-spring:1.2.3') compile(group: 'org.springframework', name: 'spring-context-support', version: springVersion) compile(group: 'org.springframework', name: 'spring-orm', version: springVersion) compile(group: 'org.springframework', name: 'spring-tx', version: springVersion) @@ -255,7 +255,7 @@ configure(coreModule) { jdbc(postgres) jdbc(hsqldb) - testCompile(group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4') + testCompile('org.apache.commons:commons-dbcp2:2.1.1') testRuntime(servletApi) testRuntime(hsqldb) testRuntime(postgres) @@ -340,7 +340,7 @@ configure(coreModule) { configure(clientModule) { dependencies { compile(globalModule) - compile(group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.2.2') + compile('org.apache.httpcomponents:httpclient:4.5') } task testsJar(dependsOn: testClasses, type: Jar) { @@ -499,7 +499,7 @@ configure(webAuthModule) { compile(group: 'org.springframework.ldap', name: 'spring-ldap-core', version: '2.0.2.RELEASE') { exclude(group: 'org.slf4j', module: 'jcl-over-slf4j') // removed because it defines its own Log4j LogFactory via JDK services mechanism } - compile(group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.5') + compile('org.slf4j:slf4j-log4j12:1.7.12') provided(servletApi) } diff --git a/modules/core/test/com/haulmont/cuba/testsupport/TestDataSource.java b/modules/core/test/com/haulmont/cuba/testsupport/TestDataSource.java index 5a2c304dd2..f1507fcfef 100644 --- a/modules/core/test/com/haulmont/cuba/testsupport/TestDataSource.java +++ b/modules/core/test/com/haulmont/cuba/testsupport/TestDataSource.java @@ -4,7 +4,7 @@ */ package com.haulmont.cuba.testsupport; -import org.apache.commons.dbcp.BasicDataSource; +import org.apache.commons.dbcp2.BasicDataSource; import javax.sql.DataSource; import java.io.PrintWriter; @@ -22,7 +22,7 @@ public class TestDataSource implements DataSource { dataSource.setUrl(connUrl); dataSource.setUsername(user); dataSource.setPassword(password); - dataSource.setMaxActive(20); + dataSource.setMaxTotal(20); } public Connection getConnection() throws SQLException { diff --git a/modules/global/src/com/haulmont/cuba/core/sys/AbstractScripting.java b/modules/global/src/com/haulmont/cuba/core/sys/AbstractScripting.java index 3f83448b56..1be5ffac26 100644 --- a/modules/global/src/com/haulmont/cuba/core/sys/AbstractScripting.java +++ b/modules/global/src/com/haulmont/cuba/core/sys/AbstractScripting.java @@ -18,8 +18,11 @@ import groovy.util.ScriptException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.commons.pool.BaseKeyedPoolableObjectFactory; -import org.apache.commons.pool.impl.GenericKeyedObjectPool; +import org.apache.commons.pool2.BaseKeyedPooledObjectFactory; +import org.apache.commons.pool2.PooledObject; +import org.apache.commons.pool2.impl.DefaultPooledObject; +import org.apache.commons.pool2.impl.GenericKeyedObjectPool; +import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; import org.codehaus.groovy.control.CompilationFailedException; import org.codehaus.groovy.control.CompilerConfiguration; @@ -50,13 +53,13 @@ public abstract class AbstractScripting implements Scripting { protected String groovyClassPath; - protected Set imports = new HashSet(); + protected Set imports = new HashSet<>(); protected volatile GroovyScriptEngine gse; protected GroovyClassLoader gcl; - protected GenericKeyedObjectPool pool; + protected GenericKeyedObjectPool pool; protected GlobalConfig globalConfig; @@ -110,38 +113,35 @@ public abstract class AbstractScripting implements Scripting { return gcl; } - private synchronized GenericKeyedObjectPool getPool() { + private synchronized GenericKeyedObjectPool getPool() { if (pool == null) { - GenericKeyedObjectPool.Config poolConfig = new GenericKeyedObjectPool.Config(); - poolConfig.maxActive = -1; - poolConfig.maxIdle = globalConfig.getGroovyEvaluationPoolMaxIdle(); - pool = new GenericKeyedObjectPool( - new BaseKeyedPoolableObjectFactory() { - public Object makeObject(Object key) throws Exception { - if (!(key instanceof String)) - throw new IllegalArgumentException(); - String text = ((String) key); - + GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig(); + poolConfig.setMaxTotalPerKey(-1); + poolConfig.setMaxIdlePerKey(globalConfig.getGroovyEvaluationPoolMaxIdle()); + pool = new GenericKeyedObjectPool<>( + new BaseKeyedPooledObjectFactory() { + @Override + public Script create(String key) throws Exception { StringBuilder sb = new StringBuilder(); for (String importItem : imports) { sb.append("import ").append(importItem).append("\n"); } - Matcher matcher = IMPORT_PATTERN.matcher(text); + Matcher matcher = IMPORT_PATTERN.matcher(key); String result; if (matcher.find()) { StringBuffer s = new StringBuffer(); matcher.appendReplacement(s, sb + "$0"); result = matcher.appendTail(s).toString(); } else { - Matcher packageMatcher = PACKAGE_PATTERN.matcher(text); + Matcher packageMatcher = PACKAGE_PATTERN.matcher(key); if (packageMatcher.find()) { StringBuffer s = new StringBuffer(); packageMatcher.appendReplacement(s, "$0\n"+sb); result = packageMatcher.appendTail(s).toString(); } else { - result = sb.append(text).toString(); + result = sb.append(key).toString(); } } @@ -149,9 +149,15 @@ public abstract class AbstractScripting implements Scripting { cc.setClasspath(groovyClassPath); cc.setRecompileGroovySource(true); GroovyShell shell = new GroovyShell(javaClassLoader, new Binding(), cc); + //noinspection UnnecessaryLocalVariable Script script = shell.parse(result); return script; } + + @Override + public PooledObject