Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update to JDK21 - EXO-71474 - meeds-io/MIPs#91 #96

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions exo.core.component.database/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,7 @@
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
</configuration>
</plugin>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
*/
package org.exoplatform.services.database;

import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.database.table.IDGenerator;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;

import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;

import javax.sql.DataSource;

Expand Down Expand Up @@ -96,14 +93,7 @@ public class ExoDatasource
public ExoDatasource(final DataSource ds) throws Exception
{
xaDatasource_ = ds;
DatabaseMetaData metaData =
SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<DatabaseMetaData>()
{
public DatabaseMetaData run() throws SQLException
{
return ds.getConnection().getMetaData();
}
});
DatabaseMetaData metaData = ds.getConnection().getMetaData();

databaseName_ = metaData.getDatabaseProductName();
databaseVersion_ = metaData.getDatabaseProductVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import org.exoplatform.commons.utils.ClassLoading;
import org.exoplatform.commons.utils.IOUtil;
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.container.configuration.ConfigurationException;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
Expand All @@ -31,7 +30,6 @@
import org.exoplatform.services.database.utils.JDBCUtils;

import java.io.IOException;
import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
Expand Down Expand Up @@ -446,14 +444,8 @@ private Connection openConnection() throws DBCreatorException
{
ClassLoading.forName(connectionProperties.get(DRIVER_NAME), this);

conn = SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
{
public Connection run() throws Exception
{
return DriverManager.getConnection(serverUrl, connectionProperties.get(USERNAME),
connectionProperties.get(PASSWORD));
}
});
conn = DriverManager.getConnection(serverUrl, connectionProperties.get(USERNAME),
connectionProperties.get(PASSWORD));

return conn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import org.hibernate.cfg.Configuration;

import org.exoplatform.commons.exception.ObjectNotFoundException;
import org.exoplatform.commons.utils.PrivilegedSystemHelper;
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.component.ComponentRequestLifecycle;
import org.exoplatform.container.xml.InitParams;
Expand Down Expand Up @@ -64,11 +62,7 @@ public class HibernateServiceImpl implements HibernateService, ComponentRequestL
public HibernateServiceImpl(InitParams initParams) {
threadLocal_ = new ThreadLocal<Session>();
PropertiesParam param = initParams.getPropertiesParam("hibernate.properties");
conf_ = SecurityHelper.doPrivilegedAction(new PrivilegedAction<HibernateConfigurationImpl>() {
public HibernateConfigurationImpl run() {
return new HibernateConfigurationImpl();
}
});
conf_ = new HibernateConfigurationImpl();
Iterator<?> properties = param.getPropertyIterator();
while (properties.hasNext()) {
Property p = (Property) properties.next();
Expand All @@ -79,7 +73,7 @@ public HibernateConfigurationImpl run() {
String connectionURL = conf_.getProperty("hibernate.connection.url");
if (connectionURL != null) {
connectionURL =
connectionURL.replace("${java.io.tmpdir}", PrivilegedSystemHelper.getProperty("java.io.tmpdir"));
connectionURL.replace("${java.io.tmpdir}", System.getProperty("java.io.tmpdir"));
conf_.setProperty("hibernate.connection.url", connectionURL);
}
}
Expand All @@ -93,12 +87,7 @@ public Configuration getHibernateConfiguration() {
*/
public SessionFactory getSessionFactory() {
if (sessionFactory_ == null) {
sessionFactory_ = SecurityHelper.doPrivilegedAction(new PrivilegedAction<SessionFactory>() {
public SessionFactory run() {
SessionFactory factory = conf_.buildSessionFactory();
return factory;
}
});
sessionFactory_ = conf_.buildSessionFactory();
}

return sessionFactory_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@

import org.enhydra.jdbc.pool.StandardXAPoolDataSource;
import org.enhydra.jdbc.standard.StandardXADataSource;
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.services.database.DatabaseService;
import org.exoplatform.services.database.ExoDatasource;
import org.exoplatform.services.transaction.TransactionService;

import java.security.PrivilegedAction;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -96,13 +94,7 @@ public TransactionService getTransactionService() throws Exception

private DataSource createDatasource(Map<String, String> props) throws Exception
{
StandardXADataSource ds = SecurityHelper.doPrivilegedAction(new PrivilegedAction<StandardXADataSource>()
{
public StandardXADataSource run()
{
return new StandardXADataSource();
}
});
StandardXADataSource ds = new StandardXADataSource();

ds.setDriverName(props.get("connection.driver"));
ds.setUrl(props.get("connection.url"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
*/
package org.exoplatform.services.database.utils;

import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;

import java.security.PrivilegedExceptionAction;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;

Expand Down Expand Up @@ -51,14 +49,7 @@ public class DialectDetecter
*/
public static String detect(final DatabaseMetaData metaData) throws SQLException
{
final String databaseName =
SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<String>()
{
public String run() throws Exception
{
return metaData.getDatabaseProductName();
}
});
final String databaseName = metaData.getDatabaseProductName();

if ("HSQL Database Engine".equals(databaseName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
*/
package org.exoplatform.services.database.utils;

import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;

import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down Expand Up @@ -272,13 +270,7 @@ public static String getAppropriateCharType(DataSource dataSource) throws SQLExc
*/
public static String resolveDialect(final DataSource dataSource) throws SQLException
{
Connection jdbcConn = SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
{
public Connection run() throws Exception
{
return dataSource.getConnection();
}
});
Connection jdbcConn = dataSource.getConnection();

try
{
Expand Down
6 changes: 0 additions & 6 deletions exo.core.component.organization.api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.codehaus.groovy.control.CompilationFailedException;

import org.exoplatform.commons.utils.IOUtil;
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.component.ComponentPlugin;
Expand Down Expand Up @@ -136,26 +135,14 @@ public Object instantiateScript(InputStream stream, String name) throws IOExcept
GroovyClassLoader loader;
if (mapping.size() > 0)
{
JarJarClassLoader jarjarLoader = SecurityHelper.doPrivilegedAction(new PrivilegedAction<JarJarClassLoader>()
{
public JarJarClassLoader run()
{
return new JarJarClassLoader();
}
});
JarJarClassLoader jarjarLoader = new JarJarClassLoader();

jarjarLoader.addMapping(mapping);
loader = jarjarLoader;
}
else
{
loader = SecurityHelper.doPrivilegedAction(new PrivilegedAction<GroovyClassLoader>()
{
public GroovyClassLoader run()
{
return new GroovyClassLoader();
}
});
loader = new GroovyClassLoader();
}
return instantiateScript(stream, name, loader);
}
Expand All @@ -181,40 +168,8 @@ public Object instantiateScript(final InputStream stream, final String name, Gro
loader = new GroovyClassLoader();
}
Class<?> clazz = null;
try
{
final GroovyClassLoader fLoader = loader;
clazz = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Class<?>>()
{
public Class<?> run() throws Exception
{
if (name != null && name.length() > 0)
{
return fLoader.parseClass(stream, name);
}
else
{
return fLoader.parseClass(IOUtil.getStreamContentAsString(stream));
}
}
});
}
catch (PrivilegedActionException pae)
{
Throwable cause = pae.getCause();
if (cause instanceof CompilationFailedException)
{
throw new IOException("Error occurs when parse stream, compiler error:\n " + cause.getMessage(), cause);
}
else if (cause instanceof RuntimeException)
{
throw (RuntimeException)cause;
}
else
{
throw new RuntimeException(cause);
}
}
final GroovyClassLoader fLoader = loader;
clazz = fLoader.parseClass(IOUtil.getStreamContentAsString(stream));

try
{
Expand Down Expand Up @@ -253,13 +208,7 @@ public Object instantiateScript(final GroovyCodeSource codeSource, GroovyClassLo
}

final GroovyClassLoader fLoader = loader;
Class<?> clazz = SecurityHelper.doPrivilegedAction(new PrivilegedAction<Class<?>>()
{
public Class<?> run()
{
return fLoader.parseClass(codeSource);
}
});
Class<?> clazz = fLoader.parseClass(codeSource);

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.Phases;
import org.codehaus.groovy.control.SourceUnit;
import org.exoplatform.commons.utils.SecurityHelper;

import java.security.CodeSource;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -98,13 +96,7 @@ protected CompilationUnit createCompilationUnit(final CompilerConfiguration comp
final CodeSource codeSource)
{
//
final CompilationUnit unit = SecurityHelper.doPrivilegedAction(new PrivilegedAction<CompilationUnit>()
{
public CompilationUnit run()
{
return JarJarClassLoader.super.createCompilationUnit(compilerConfiguration, codeSource);
}
});
final CompilationUnit unit = JarJarClassLoader.super.createCompilationUnit(compilerConfiguration, codeSource);

//
unit.addPhaseOperation(new CompilationUnit.PrimaryClassNodeOperation()
Expand Down Expand Up @@ -148,12 +140,6 @@ public void call(SourceUnit sourceUnit, GeneratorContext generatorContext, Class

static protected JarJarClassLoader createJarJarClassLoaderInPrivilegedMode(final ClassLoader classLoader)
{
return SecurityHelper.doPrivilegedAction(new PrivilegedAction<JarJarClassLoader>()
{
public JarJarClassLoader run()
{
return new JarJarClassLoader(classLoader);
}
});
return new JarJarClassLoader(classLoader);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import junit.framework.Assert;
import junit.framework.AssertionFailedError;

import org.exoplatform.commons.utils.PrivilegedSystemHelper;

import java.io.IOException;
import java.net.URL;

Expand Down Expand Up @@ -54,7 +52,7 @@ public Object execute(Mapping mapping)
mapping.configure(loader);

// Obtain script class
URL url = PrivilegedSystemHelper.getResource("jarjar/" + name);
URL url = Thread.currentThread().getContextClassLoader().getResource("jarjar/" + name);
Assert.assertNotNull(url);
GroovyCodeSource gcs;
try
Expand Down
6 changes: 0 additions & 6 deletions exo.core.component.security.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
Expand Down
Loading