Skip to content

Commit

Permalink
Fix sonar cloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Sep 15, 2023
1 parent a4ddf09 commit a510c90
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<JFile> filter, int res ) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); } );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -92,11 +101,11 @@ public static DataBaseModel createModel( ConnectionFactory cf, String catalog, S
}

public static DataBaseModel createModel( ConnectionFactory cf, String catalog, String schema, List<String> 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<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

import lombok.extern.slf4j.Slf4j;

Expand All @@ -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 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class CacheWrapper<T> {

public CacheWrapper(PagedResult<T> page) {
super();
this.page = page;
this.cacheTime = System.currentTimeMillis();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a510c90

Please sign in to comment.