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 14, 2023
1 parent 341e48a commit 5b71ae6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
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 @@ -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 @@ -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

0 comments on commit 5b71ae6

Please sign in to comment.