Skip to content

Commit

Permalink
Stop using deprecated URL constructors in o.e.jdt.ui.tests
Browse files Browse the repository at this point in the history
* Let Bundle.getEntry do full resolving
* If it's actually used to openConnection go through URI creation.
  • Loading branch information
akurtakov committed Jan 16, 2025
1 parent ada74e5 commit 8e287da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -48,7 +48,7 @@ public static IWorkspace getWorkspace() {

public File getFileInPlugin(IPath path) throws CoreException {
try {
URL installURL= new URL(getBundle().getEntry("/"), path.toString());
URL installURL= getBundle().getEntry("/"+ path.toString());
URL localURL= FileLocator.toFileURL(installURL);
return new File(localURL.getFile());
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2020 IBM Corporation and others.
* Copyright (c) 2013, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -17,7 +17,7 @@
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.net.URL;
import java.net.URI;

import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -239,7 +239,7 @@ public void testGetPackageAttacheddoc() throws Exception {
String connectionTestUrl= "https://docs.oracle.com/";
try {
// Trying to connect to the internet. Exception will be thrown if there is no net connection.
new URL(connectionTestUrl).openConnection().connect();
URI.create(connectionTestUrl).toURL().openConnection().connect();
assertTrue(actualHtmlContent, actualHtmlContent.contains("Provides classes for performing arbitrary-precision integer"));
} catch (Exception e) {
System.out.println("PackageJavadocTests.testGetPackageAttacheddoc(): no internet connection to access docs at " + connectionTestUrl);
Expand Down

0 comments on commit 8e287da

Please sign in to comment.