diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d0ae7c2..54ff481c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- MetaDataUtils types constant arrays removed in favor of public builder methods (may raise minor compatibility issues) + +### Fixed + - Javadoc generation with java 17 +- VirtualPageCache entry store did not work properly ## [8.2.8] - 2023-09-13 diff --git a/fj-core-jvfs/src/main/java/org/fugerit/java/core/jvfs/util/JFileUtilCP.java b/fj-core-jvfs/src/main/java/org/fugerit/java/core/jvfs/util/JFileUtilCP.java index 24741047..0fbb63bd 100644 --- a/fj-core-jvfs/src/main/java/org/fugerit/java/core/jvfs/util/JFileUtilCP.java +++ b/fj-core-jvfs/src/main/java/org/fugerit/java/core/jvfs/util/JFileUtilCP.java @@ -41,7 +41,7 @@ public static int copyFileRecurseForceVerbose( JFile from, JFile to ) throws IOE } public static int copyFile(JFile from, JFile to, boolean recurse, boolean force, boolean verbose) throws IOException { - return copyFile( from, to, recurse, force, verbose, ( f ) -> true ); + return copyFile( from, to, recurse, force, verbose, f -> true ); } private static int copyFileRecurse( JFile from, JFile to, boolean recurse, boolean force, boolean verbose, Predicate filter, int res ) throws IOException { diff --git a/fj-core/src/main/java/org/fugerit/java/core/cfg/CloseHelper.java b/fj-core/src/main/java/org/fugerit/java/core/cfg/CloseHelper.java index b196a6c4..190690e6 100644 --- a/fj-core/src/main/java/org/fugerit/java/core/cfg/CloseHelper.java +++ b/fj-core/src/main/java/org/fugerit/java/core/cfg/CloseHelper.java @@ -37,13 +37,13 @@ public static void close( Closeable ac ) throws ConfigException { public static void closeRuntimeEx( AutoCloseable ac ) { if ( ac != null ) { - SafeFunction.apply( () -> ac.close(), e -> { throw ConfigRuntimeException.convertEx( BASIC_CLOSE_MESSAGE+ac , e ); } ); + SafeFunction.apply( ac::close, e -> { throw ConfigRuntimeException.convertEx( BASIC_CLOSE_MESSAGE+ac , e ); } ); } } public static void closeRuntimeEx( Closeable ac ) { if ( ac != null ) { - SafeFunction.apply( () -> ac.close(), e -> { throw ConfigRuntimeException.convertEx( BASIC_CLOSE_MESSAGE+ac , e ); } ); + SafeFunction.apply( ac::close, e -> { throw ConfigRuntimeException.convertEx( BASIC_CLOSE_MESSAGE+ac , e ); } ); } } diff --git a/fj-core/src/main/java/org/fugerit/java/core/cfg/VersionUtils.java b/fj-core/src/main/java/org/fugerit/java/core/cfg/VersionUtils.java index b40beb2f..755c67db 100644 --- a/fj-core/src/main/java/org/fugerit/java/core/cfg/VersionUtils.java +++ b/fj-core/src/main/java/org/fugerit/java/core/cfg/VersionUtils.java @@ -37,7 +37,7 @@ public class VersionUtils { private VersionUtils() {} - private static Properties MODULES = new Properties(); + private static final Properties MODULES = new Properties(); public static final String CODE_01_NOT_FOUND = "[01] Module does not exist"; diff --git a/fj-core/src/main/java/org/fugerit/java/core/cfg/xml/PropertyCatalog.java b/fj-core/src/main/java/org/fugerit/java/core/cfg/xml/PropertyCatalog.java index 2e95aa5a..3e2d4137 100644 --- a/fj-core/src/main/java/org/fugerit/java/core/cfg/xml/PropertyCatalog.java +++ b/fj-core/src/main/java/org/fugerit/java/core/cfg/xml/PropertyCatalog.java @@ -85,7 +85,7 @@ public void configure(Element tag) throws ConfigException { } - private static ParamFinder PARAM_FINDER = ParamFinder.newFinder(); + private static final ParamFinder PARAM_FINDER = ParamFinder.newFinder(); private ParamProvider pathParamProvider; diff --git a/fj-core/src/main/java/org/fugerit/java/core/cfg/xml/PropertyHolder.java b/fj-core/src/main/java/org/fugerit/java/core/cfg/xml/PropertyHolder.java index 88fd510b..e7e2ef9b 100644 --- a/fj-core/src/main/java/org/fugerit/java/core/cfg/xml/PropertyHolder.java +++ b/fj-core/src/main/java/org/fugerit/java/core/cfg/xml/PropertyHolder.java @@ -117,10 +117,10 @@ private static void loadWorker( InputStream is, Properties props, boolean xml, S private static void handleException( String path, Exception e, String unsafe, String usafeMessage ) throws IOException { if ( UNSAFE_TRUE.equalsIgnoreCase( unsafe ) || UNSAFE_WARN.equalsIgnoreCase( unsafe ) ) { String unsafeMessafeWork = usafeMessage+" "; - if ( StringUtils.isNotEmpty( unsafeMessafeWork ) ) { - unsafeMessafeWork+=" "; + if ( StringUtils.isNotEmpty( usafeMessage ) ) { + unsafeMessafeWork+= usafeMessage+" "; } - unsafeMessafeWork = path + ", " + unsafe + ", " + e; + unsafeMessafeWork+= path + ", " + unsafe + ", " + e; if ( UNSAFE_WARN.equalsIgnoreCase( unsafe ) ) { log.warn( "Error loading unsafe property holder : {}", unsafeMessafeWork ); } else { diff --git a/fj-core/src/main/java/org/fugerit/java/core/db/connect/ConnectionFactoryImpl.java b/fj-core/src/main/java/org/fugerit/java/core/db/connect/ConnectionFactoryImpl.java index 123a37e4..0941f675 100644 --- a/fj-core/src/main/java/org/fugerit/java/core/db/connect/ConnectionFactoryImpl.java +++ b/fj-core/src/main/java/org/fugerit/java/core/db/connect/ConnectionFactoryImpl.java @@ -362,7 +362,7 @@ public static ConnectionFactoryImpl newInstance(String dsName) throws DAOExcepti */ public static ConnectionFactoryImpl newInstance(DataSource ds) throws DAOException { log.info( "ConnectionFactoryImpl.newInstance() data source : {}", ds ); - return new SupplierConnectionFactory( "dataSourceSupplier" , () -> ds.getConnection() ); + return new SupplierConnectionFactory( "dataSourceSupplier" , ds::getConnection ); } /* diff --git a/fj-core/src/main/java/org/fugerit/java/core/db/metadata/MetaDataUtils.java b/fj-core/src/main/java/org/fugerit/java/core/db/metadata/MetaDataUtils.java index 21fa3cf8..57460909 100644 --- a/fj-core/src/main/java/org/fugerit/java/core/db/metadata/MetaDataUtils.java +++ b/fj-core/src/main/java/org/fugerit/java/core/db/metadata/MetaDataUtils.java @@ -28,6 +28,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.fugerit.java.core.db.connect.ConnectionFactory; @@ -55,13 +56,21 @@ private MetaDataUtils() {} public static final String TYPE_VIEW = "VIEW"; - public static final String[] TYPES_TABLE = { TYPE_TABLE }; + public static final String[] typesAll() { + return Arrays.asList( TYPE_TABLE, TYPE_VIEW ).toArray( new String[0] ); + } - public static final String[] TYPES_VIEW = { TYPE_VIEW }; + public static final String[] typesDefault() { + return Arrays.asList( TYPE_TABLE ).toArray( new String[0] ); + } - public static final String[] TYPES_DEFAULT = TYPES_TABLE; + public static final String[] typesView() { + return Arrays.asList( TYPE_TABLE ).toArray( new String[0] ); + } - public static final String[] TYPES_ALL = { TYPE_TABLE, TYPE_VIEW }; + public static final String[] typesTable() { + return Arrays.asList( TYPE_TABLE ).toArray( new String[0] ); + } private static final String S_COLUMN_NAME = "COLUMN_NAME"; @@ -92,11 +101,11 @@ public static DataBaseModel createModel( ConnectionFactory cf, String catalog, S } public static DataBaseModel createModel( ConnectionFactory cf, String catalog, String schema, List tableNameList ) throws DAOException { - return createModel( cf , catalog, schema, (JdbcAdaptor) new DefaulJdbcdaptor( cf ), tableNameList, TYPES_DEFAULT ); + return createModel( cf , catalog, schema, new DefaulJdbcdaptor( cf ), tableNameList, typesDefault() ); } public static DataBaseModel createModel( ConnectionFactory cf, String catalog, String schema, List tableNameList, String[] types ) throws DAOException { - return createModel( cf , catalog, schema, (JdbcAdaptor) new DefaulJdbcdaptor( cf ), tableNameList, types ); + return createModel( cf , catalog, schema, new DefaulJdbcdaptor( cf ), tableNameList, types ); } private static final int MODE_LOOSE = 1; diff --git a/fj-core/src/main/java/org/fugerit/java/core/io/file/DeleteRecurseFileFun.java b/fj-core/src/main/java/org/fugerit/java/core/io/file/DeleteRecurseFileFun.java index 57e06967..22edd345 100644 --- a/fj-core/src/main/java/org/fugerit/java/core/io/file/DeleteRecurseFileFun.java +++ b/fj-core/src/main/java/org/fugerit/java/core/io/file/DeleteRecurseFileFun.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; import lombok.extern.slf4j.Slf4j; @@ -16,7 +17,7 @@ public class DeleteRecurseFileFun extends AbstractFileFun { @Override public void handleFile(File file) throws IOException { - boolean res = file.delete(); + boolean res = Files.deleteIfExists( file.toPath() ); if ( !res ) { log.warn( "false result on file.delete() : {}", file ); } diff --git a/fj-core/src/main/java/org/fugerit/java/core/lang/helpers/ClassHelper.java b/fj-core/src/main/java/org/fugerit/java/core/lang/helpers/ClassHelper.java index 790c3a32..5e523e10 100644 --- a/fj-core/src/main/java/org/fugerit/java/core/lang/helpers/ClassHelper.java +++ b/fj-core/src/main/java/org/fugerit/java/core/lang/helpers/ClassHelper.java @@ -52,14 +52,10 @@ public static Object newInstance( String type ) throws ClassNotFoundException, N ClassLoader classLoader = getDefaultClassLoader(); Class c = classLoader.loadClass( type ); result = c.getDeclaredConstructor().newInstance(); + } catch (ClassNotFoundException | NoSuchMethodException e) { + throw e; } catch (Exception e) { - if ( e instanceof ClassNotFoundException ) { - throw (ClassNotFoundException)e; - } else if ( e instanceof NoSuchMethodException ) { - throw (NoSuchMethodException)e; - } else { - throw ConfigException.convertExMethod( "newInstance" , e ); - } + throw ConfigException.convertExMethod( "newInstance" , e ); } return result; } diff --git a/fj-core/src/main/java/org/fugerit/java/core/util/result/VirtualPageCache.java b/fj-core/src/main/java/org/fugerit/java/core/util/result/VirtualPageCache.java index ad31cd2f..1798e397 100644 --- a/fj-core/src/main/java/org/fugerit/java/core/util/result/VirtualPageCache.java +++ b/fj-core/src/main/java/org/fugerit/java/core/util/result/VirtualPageCache.java @@ -69,6 +69,7 @@ class CacheWrapper { public CacheWrapper(PagedResult page) { super(); + this.page = page; this.cacheTime = System.currentTimeMillis(); } diff --git a/fj-core/src/test/java/test/org/fugerit/java/core/util/result/TestResult.java b/fj-core/src/test/java/test/org/fugerit/java/core/util/result/TestResult.java index f3735ca4..4fe86825 100644 --- a/fj-core/src/test/java/test/org/fugerit/java/core/util/result/TestResult.java +++ b/fj-core/src/test/java/test/org/fugerit/java/core/util/result/TestResult.java @@ -151,7 +151,7 @@ public void testVirtualCache() { int perPage = 3; int elementCount = DATA.size(); cache.addPageToCache( DefaultPagedResult.newPagedResult( perPage, elementCount, 0, DATA, 3, DATA.size(), "test" ) ); - Assert.assertNull( cache.getCachedPage( new DefaultVirtualFinder(perPage, elementCount, 3, DATA.size(), "test" ) ) ); + Assert.assertNotNull( cache.getCachedPage( new DefaultVirtualFinder(perPage, elementCount, 3, DATA.size(), "test" ) ) ); } @Test