Skip to content

Replace deprecated File.toURL() #2937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-SymbolicName: org.eclipse.e4.ui.css.core;singleton:=true
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-Version: 0.14.500.qualifier
Bundle-Version: 0.14.600.qualifier
Export-Package: org.eclipse.e4.ui.css.core;x-internal:=true,
org.eclipse.e4.ui.css.core.css2;x-friends:="org.eclipse.e4.ui.css.swt.theme,org.eclipse.e4.ui.css.swt,org.eclipse.e4.ui.css.jface",
org.eclipse.e4.ui.css.core.dom;x-friends:="org.eclipse.e4.ui.css.swt,org.eclipse.ui.views.properties.tabbed,org.eclipse.ui.forms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.e4.ui.css.core.util.impl.resources;

import java.io.File;
import java.io.InputStream;
import java.net.URL;
import org.eclipse.e4.ui.css.core.util.resources.IResourceLocator;
Expand All @@ -33,7 +32,7 @@ public String resolve(String uri) {

@Override
public InputStream getInputStream(String uri) throws Exception {
URL url = new java.net.URL((new File("./")).toURL(), uri);
URL url = new URL(uri);
return url.openStream();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
import java.io.IOException;
import java.io.Reader;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.StringTokenizer;

import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
Expand Down Expand Up @@ -540,13 +543,12 @@ private static URL getPersistenceUrl(URL baseUrl, boolean create) {
}

// make sure the file exists
url = new URL(dir.toURL(), PERS_FILENAME);
File persFile = new File(url.getFile());
if (!persFile.exists() && (!create || !persFile.createNewFile())) {
Path p = Path.of(URIUtil.toURI(baseUrl.getPath() + File.pathSeparator + PERS_FILENAME));
if (!Files.exists(p) && (!create || !p.toFile().createNewFile())) {
return null;
}

return persFile.toURL();
return p.toUri().toURL();
} catch (IOException e) {
// cannot log because instance area has not been set
return null;
Expand Down
Loading