18
18
*/
19
19
20
20
/*
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.
22
22
* Portions Copyright (c) 2019, Chris Fraire <[email protected] >.
23
23
*/
24
24
package org .opengrok .indexer .util ;
@@ -54,6 +54,10 @@ public class CtagsUtil {
54
54
55
55
public static final String SYSTEM_CTAGS_PROPERTY = "org.opengrok.indexer.analysis.Ctags" ;
56
56
57
+ /** Private to enforce static. */
58
+ private CtagsUtil () {
59
+ }
60
+
57
61
/**
58
62
* Check that {@code ctags} program exists and is working.
59
63
* @param ctagsBinary name of the ctags program or path
@@ -163,7 +167,7 @@ public static Set<String> getLanguages(String ctagsBinary) {
163
167
Set <String > result = new HashSet <>();
164
168
for (String lang : split ) {
165
169
lang = lang .trim ();
166
- if (lang .length () > 0 ) {
170
+ if (! lang .isEmpty () ) {
167
171
result .add (lang );
168
172
}
169
173
}
@@ -192,7 +196,7 @@ public static void deleteTempFiles() {
192
196
continue ;
193
197
}
194
198
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 );
196
200
deleteTempFiles (directory );
197
201
}
198
202
}
@@ -205,14 +209,18 @@ private static void deleteTempFiles(File directory) {
205
209
return matcher .find ();
206
210
});
207
211
212
+ if (Objects .isNull (files )) {
213
+ return ;
214
+ }
215
+
208
216
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
+ }
211
223
}
212
224
}
213
225
}
214
-
215
- /** Private to enforce static. */
216
- private CtagsUtil () {
217
- }
218
226
}
0 commit comments