@@ -164,9 +164,12 @@ public static void main(String [] args, PerfTestOptions perfTestOptions) {
164164 if (outputFile != null ) {
165165 File file = new File (outputFile );
166166 if (file .exists ()) {
167- file .delete ();
167+ boolean deleted = file .delete ();
168+ if (!deleted ) {
169+ LOGGER .warn ("Could not delete existing CSV file, will try to append at the end of the file" );
170+ }
168171 }
169- output = new PrintWriter (new BufferedWriter (new FileWriter (file )), true ); //NOSONAR
172+ output = new PrintWriter (new BufferedWriter (new FileWriter (file , true )), true ); //NOSONAR
170173 Runtime .getRuntime ().addShutdownHook (new Thread (() -> output .close ()));
171174 } else {
172175 output = null ;
@@ -288,7 +291,7 @@ public static void main(String [] args, PerfTestOptions perfTestOptions) {
288291 usage (options );
289292 } catch (Exception e ) {
290293 System .err .println ("Main thread caught exception: " + e );
291- e . printStackTrace ( );
294+ LOGGER . error ( "Main thread caught exception" , e );
292295 systemExiter .exit (1 );
293296 } finally {
294297 if (metrics != null ) {
@@ -803,10 +806,10 @@ public void exit(int status) {
803806
804807 }
805808
806- public static Function <String , String > LONG_OPTION_TO_ENVIRONMENT_VARIABLE = option ->
809+ static final Function <String , String > LONG_OPTION_TO_ENVIRONMENT_VARIABLE = option ->
807810 option .replace ('-' , '_' ).toUpperCase (Locale .ENGLISH );
808811
809- public static Function <String , String > ENVIRONMENT_VARIABLE_PREFIX = name -> {
812+ private static final Function <String , String > ENVIRONMENT_VARIABLE_PREFIX = name -> {
810813 String prefix = System .getenv ("RABBITMQ_PERF_TEST_ENV_PREFIX" );
811814 if (prefix == null || prefix .trim ().isEmpty ()) {
812815 return name ;
@@ -818,6 +821,6 @@ public void exit(int status) {
818821 }
819822 };
820823
821- static Function <String , String > ENVIRONMENT_VARIABLE_LOOKUP = name -> System .getenv (name );
824+ private static final Function <String , String > ENVIRONMENT_VARIABLE_LOOKUP = name -> System .getenv (name );
822825
823826}
0 commit comments