Applied fix from trunk for revision: 1854683
=== Preparation for JDK11 update, Updated following code to fix warning with respect to JDK11 - Replaced Class::newInstance occurrences - Removed deprecated override method Object::finalize (OFBIZ-10757) git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release18.12@1854689 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -327,15 +327,11 @@ public class GenericDelegator implements Delegator {
|
||||
|
||||
try {
|
||||
Class<?> eecahClass = loader.loadClass(entityEcaHandlerClassName);
|
||||
EntityEcaHandler<?> entityEcaHandler = UtilGenerics.cast(eecahClass.newInstance());
|
||||
EntityEcaHandler<?> entityEcaHandler = UtilGenerics.cast(eecahClass.getDeclaredConstructor().newInstance());
|
||||
entityEcaHandler.setDelegator(this);
|
||||
return entityEcaHandler;
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (ReflectiveOperationException e) {
|
||||
Debug.logWarning(e, "EntityEcaHandler class with name " + entityEcaHandlerClassName + " was not found, Entity ECA Rules will be disabled", module);
|
||||
} catch (InstantiationException e) {
|
||||
Debug.logWarning(e, "EntityEcaHandler class with name " + entityEcaHandlerClassName + " could not be instantiated, Entity ECA Rules will be disabled", module);
|
||||
} catch (IllegalAccessException e) {
|
||||
Debug.logWarning(e, "EntityEcaHandler class with name " + entityEcaHandlerClassName + " could not be accessed (illegal), Entity ECA Rules will be disabled", module);
|
||||
} catch (ClassCastException e) {
|
||||
Debug.logWarning(e, "EntityEcaHandler class with name " + entityEcaHandlerClassName + " does not implement the EntityEcaHandler interface, Entity ECA Rules will be disabled", module);
|
||||
}
|
||||
@@ -2627,15 +2623,11 @@ public class GenericDelegator implements Delegator {
|
||||
|
||||
try {
|
||||
Class<?> dccClass = loader.loadClass(distributedCacheClearClassName);
|
||||
DistributedCacheClear distributedCacheClear = UtilGenerics.cast(dccClass.newInstance());
|
||||
DistributedCacheClear distributedCacheClear = UtilGenerics.cast(dccClass.getDeclaredConstructor().newInstance());
|
||||
distributedCacheClear.setDelegator(this, this.delegatorInfo.getDistributedCacheClearUserLoginId());
|
||||
return distributedCacheClear;
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (ReflectiveOperationException e) {
|
||||
Debug.logWarning(e, "DistributedCacheClear class with name " + distributedCacheClearClassName + " was not found, distributed cache clearing will be disabled", module);
|
||||
} catch (InstantiationException e) {
|
||||
Debug.logWarning(e, "DistributedCacheClear class with name " + distributedCacheClearClassName + " could not be instantiated, distributed cache clearing will be disabled", module);
|
||||
} catch (IllegalAccessException e) {
|
||||
Debug.logWarning(e, "DistributedCacheClear class with name " + distributedCacheClearClassName + " could not be accessed (illegal), distributed cache clearing will be disabled", module);
|
||||
} catch (ClassCastException e) {
|
||||
Debug.logWarning(e, "DistributedCacheClear class with name " + distributedCacheClearClassName + " does not implement the DistributedCacheClear interface, distributed cache clearing will be disabled", module);
|
||||
}
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ public class DBCPConnectionFactory implements ConnectionFactory {
|
||||
synchronized (DBCPConnectionFactory.class) {
|
||||
// Sync needed for MS SQL JDBC driver. See OFBIZ-5216.
|
||||
try {
|
||||
jdbcDriver = (Driver) Class.forName(driverName, true, Thread.currentThread().getContextClassLoader()).newInstance();
|
||||
jdbcDriver = (Driver) Class.forName(driverName, true, Thread.currentThread().getContextClassLoader()).getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
Debug.logError(e, module);
|
||||
throw new GenericEntityException(e.getMessage(), e);
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class ConnectionFactoryLoader {
|
||||
}
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
Class<?> tfClass = loader.loadClass(className);
|
||||
instance = (ConnectionFactory) tfClass.newInstance();
|
||||
instance = (ConnectionFactory) tfClass.getDeclaredConstructor().newInstance();
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
Debug.logError(cnfe, "Could not find connection factory class", module);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -116,14 +116,10 @@ public class DatabaseUtil {
|
||||
if (driverName != null) {
|
||||
if (DriverManager.getDriver(driverName) == null) {
|
||||
try {
|
||||
Driver driver = (Driver) Class.forName(driverName, true, Thread.currentThread().getContextClassLoader()).newInstance();
|
||||
Driver driver = (Driver) Class.forName(driverName, true, Thread.currentThread().getContextClassLoader()).getDeclaredConstructor().newInstance();
|
||||
DriverManager.registerDriver(driver);
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (ReflectiveOperationException e) {
|
||||
Debug.logWarning(e, "Unable to load driver [" + driverName + "]", module);
|
||||
} catch (InstantiationException e) {
|
||||
Debug.logWarning(e, "Unable to instantiate driver [" + driverName + "]", module);
|
||||
} catch (IllegalAccessException e) {
|
||||
Debug.logWarning(e, "Illegal access exception [" + driverName + "]", module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,16 +829,6 @@ public class SQLProcessor implements AutoCloseable {
|
||||
_ind++;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
this.close();
|
||||
} catch (Exception e) {
|
||||
Debug.logError(e, "Error closing the result, connection, etc in finalize SQLProcessor", module);
|
||||
}
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
protected void testConnection(Connection con) throws GenericEntityException {
|
||||
if (SQLProcessor.ENABLE_TEST) {
|
||||
if (SQLProcessor.CONNECTION_TEST_LIST.contains(con.toString())) {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class TransactionFactoryLoader {
|
||||
}
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
Class<?> tfClass = loader.loadClass(className);
|
||||
instance = (TransactionFactory) tfClass.newInstance();
|
||||
instance = (TransactionFactory) tfClass.getDeclaredConstructor().newInstance();
|
||||
} catch (GenericEntityConfException gece) {
|
||||
Debug.logError(gece, "Could not find transaction factory class name definition", module);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
|
||||
@@ -525,27 +525,6 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
|
||||
throw new GeneralRuntimeException("CursorListIterator currently only supports read-only access");
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends {@link Object#finalize()} to make sure that the {@link EntityListIterator} is closed when it is garbage collected.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
if (!closed) {
|
||||
this.close();
|
||||
Debug.logError("\n==============================================================================\n"
|
||||
+ "EntityListIterator Not Closed for Entity [%s], caught in Finalize\n"
|
||||
+ "\n==============================================================================\n",
|
||||
module, modelEntity == null ? "" : modelEntity.getEntityName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debug.logError(e, "Error closing the SQLProcessor in finalize EntityListIterator", module);
|
||||
}
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the {@link EntityListIterator} and logs a warning if it isn't already closed.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user