1818 */
1919
2020/*
21- * Copyright (c) 2006, 2023 , Oracle and/or its affiliates. All rights reserved.
21+ * Copyright (c) 2006, 2024 , Oracle and/or its affiliates. All rights reserved.
2222 * Portions Copyright (c) 2019, Chris Fraire <[email protected] >. 2323 */
2424package org .opengrok .indexer .util ;
@@ -54,6 +54,10 @@ public class CtagsUtil {
5454
5555 public static final String SYSTEM_CTAGS_PROPERTY = "org.opengrok.indexer.analysis.Ctags" ;
5656
57+ /** Private to enforce static. */
58+ private CtagsUtil () {
59+ }
60+
5761 /**
5862 * Check that {@code ctags} program exists and is working.
5963 * @param ctagsBinary name of the ctags program or path
@@ -163,7 +167,7 @@ public static Set<String> getLanguages(String ctagsBinary) {
163167 Set <String > result = new HashSet <>();
164168 for (String lang : split ) {
165169 lang = lang .trim ();
166- if (lang .length () > 0 ) {
170+ if (! lang .isEmpty () ) {
167171 result .add (lang );
168172 }
169173 }
@@ -192,7 +196,7 @@ public static void deleteTempFiles() {
192196 continue ;
193197 }
194198
195- LOGGER .log (Level .FINER , "deleting Ctags temporary files in directory {0}" , directoryName );
199+ LOGGER .log (Level .FINER , "deleting Ctags temporary files in directory '' {0}'' " , directoryName );
196200 deleteTempFiles (directory );
197201 }
198202 }
@@ -205,14 +209,18 @@ private static void deleteTempFiles(File directory) {
205209 return matcher .find ();
206210 });
207211
212+ if (Objects .isNull (files )) {
213+ return ;
214+ }
215+
208216 for (File file : files ) {
209- if (file .isFile () && !file .delete ()) {
210- LOGGER .log (Level .WARNING , "cannot delete file {0}" , file );
217+ if (file .isFile ()) {
218+ try {
219+ Files .delete (file .toPath ());
220+ } catch (IOException exception ) {
221+ LOGGER .log (Level .WARNING , String .format ("cannot delete file '%s'" , file ), exception );
222+ }
211223 }
212224 }
213225 }
214-
215- /** Private to enforce static. */
216- private CtagsUtil () {
217- }
218226}
0 commit comments