2424import java .io .FileInputStream ;
2525import java .io .FileOutputStream ;
2626import java .io .IOException ;
27+ import java .io .InputStream ;
2728import java .io .OutputStream ;
2829import java .net .InetAddress ;
2930import java .net .MalformedURLException ;
31+ import java .net .URISyntaxException ;
3032import java .net .URL ;
3133import java .nio .file .Files ;
3234import java .nio .file .Path ;
4042import org .eclipse .core .runtime .OperationCanceledException ;
4143import org .eclipse .core .runtime .Platform ;
4244import org .eclipse .core .runtime .Status ;
45+ import org .eclipse .core .runtime .URIUtil ;
4346import org .eclipse .core .runtime .jobs .Job ;
4447import org .eclipse .core .runtime .preferences .ConfigurationScope ;
4548import org .eclipse .equinox .app .IApplication ;
@@ -86,7 +89,7 @@ public class IDEApplication implements IApplication, IExecutableExtension {
8689
8790 private static final String VERSION_FILENAME = "version.ini" ; //$NON-NLS-1$
8891
89- private static final String LOCK_INFO_FILENAME = ".lock_info" ; //$NON-NLS-1$
92+ private static final Path LOCK_INFO_FILE = Path . of ( METADATA_FOLDER , ".lock_info" ) ; //$NON-NLS-1$
9093
9194 private static final String DISPLAY_VAR = "DISPLAY" ; //$NON-NLS-1$
9295
@@ -404,14 +407,14 @@ protected Control createCustomArea(Composite parent) {
404407 */
405408 protected String getWorkspaceLockInfo (URL workspaceUrl ) {
406409 try {
407- File lockFile = getLockInfoFile (workspaceUrl );
408- if (!lockFile .exists ()) {
410+ Path lockFile = getLockInfoFile (workspaceUrl );
411+ if (!Files .exists (lockFile )) {
409412 return null ;
410413 }
411414
412415 StringBuilder sb = new StringBuilder ();
413416 Properties props = new Properties ();
414- try (FileInputStream is = new FileInputStream (lockFile )) {
417+ try (InputStream is = Files . newInputStream (lockFile )) {
415418 props .load (is );
416419 String prop = props .getProperty (USER );
417420 if (prop != null ) {
@@ -466,7 +469,7 @@ protected void writeWsLockInfo(URL workspaceUrl) {
466469 return ;
467470 }
468471
469- try (OutputStream output = new FileOutputStream (createLockInfoFile (workspaceUrl ))) {
472+ try (OutputStream output = Files . newOutputStream (createLockInfoFile (workspaceUrl ))) {
470473 props .store (output , null );
471474 } catch (Exception e ) {
472475 IDEWorkbenchPlugin .log ("Could not write lock info file" , e ); //$NON-NLS-1$
@@ -521,9 +524,12 @@ private String getHostName() {
521524 * @param workspaceUrl
522525 * @return .lock_info file.
523526 */
524- private File getLockInfoFile (URL workspaceUrl ) {
525- Path lockInfoPath = Path .of (workspaceUrl .getPath (), METADATA_FOLDER , LOCK_INFO_FILENAME );
526- return lockInfoPath .toFile ();
527+ private static Path getLockInfoFile (URL workspaceUrl ) {
528+ try {
529+ return Path .of (URIUtil .toURI (workspaceUrl )).resolve (LOCK_INFO_FILE );
530+ } catch (URISyntaxException e ) {
531+ throw new IllegalArgumentException (e );
532+ }
527533 }
528534
529535 /**
@@ -532,17 +538,12 @@ private File getLockInfoFile(URL workspaceUrl) {
532538 * @param workspaceUrl
533539 * @return .lock_info file.
534540 */
535- private File createLockInfoFile (URL workspaceUrl ) throws Exception {
536- File lockInfoFile = getLockInfoFile (workspaceUrl );
537-
538- if (lockInfoFile .exists ())
539- return lockInfoFile ;
540-
541- Path createdPath = Files .createFile (lockInfoFile .toPath ());
542- if (createdPath != null ) {
543- return createdPath .toFile ();
541+ private static Path createLockInfoFile (URL workspaceUrl ) throws Exception {
542+ Path lockInfoFile = getLockInfoFile (workspaceUrl );
543+ if (!Files .exists (lockInfoFile )) {
544+ Files .createFile (lockInfoFile );
544545 }
545- return null ;
546+ return lockInfoFile ;
546547 }
547548
548549 @ SuppressWarnings ("rawtypes" )
0 commit comments