Skip to content

Merge 'main' into 'telemetry' #359

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

Merged
merged 9 commits into from
Dec 27, 2024
Merged
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
27 changes: 13 additions & 14 deletions patches/8036-draft.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java b/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java
index 76bb6080c73c..a708698bd008 100644
index 76bb6080c73c..5ac38f940612 100644
--- a/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java
+++ b/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java
@@ -26,6 +26,7 @@
Expand All @@ -20,26 +20,24 @@ index 76bb6080c73c..a708698bd008 100644

/**
* NetBeans implementation of a PAC script evaluator. This implementation
@@ -196,6 +200,8 @@ public class NbPacScriptEvaluator implements PacScriptEvaluator {
@@ -196,6 +200,7 @@ public class NbPacScriptEvaluator implements PacScriptEvaluator {
private static final String PAC_SOCKS5_FFEXT = "SOCKS5"; // Mozilla Firefox extension. Not part of original Netscape spec.
private static final String PAC_HTTP_FFEXT = "HTTP"; // Mozilla Firefox extension. Not part of original Netscape spec.
private static final String PAC_HTTPS_FFEXT = "HTTPS"; // Mozilla Firefox extension. Not part of original Netscape spec.
+ private static class RPSingleton { private static final RequestProcessor instance = new RequestProcessor(NbPacScriptEvaluator.class.getName(), Runtime.getRuntime().availableProcessors(), true, false); }
+ private static RequestProcessor getRequestProcessor() { return RPSingleton.instance; }
+ private static final RequestProcessor RP = new RequestProcessor(NbPacScriptEvaluator.class.getName(), Runtime.getRuntime().availableProcessors(), true, false);
private final String pacScriptSource;


@@ -213,7 +219,8 @@ public NbPacScriptEvaluator(String pacSourceCocde) throws PacParsingException {
@@ -213,7 +218,7 @@ public NbPacScriptEvaluator(String pacSourceCocde) throws PacParsingException {
@Override
public List<Proxy> findProxyForURL(URI uri) throws PacValidationException {

- List<Proxy> jsResultAnalyzed;
+ AtomicReference<List<Proxy>> resultHolder = new AtomicReference<>(null);
+ List<Proxy> jsResultAnalyzed = null;

// First try the cache
if (resultCache != null) {
@@ -222,38 +229,36 @@ public List<Proxy> findProxyForURL(URI uri) throws PacValidationException {
@@ -222,38 +227,37 @@ public List<Proxy> findProxyForURL(URI uri) throws PacValidationException {
return jsResultAnalyzed;
}
}
Expand Down Expand Up @@ -73,7 +71,8 @@ index 76bb6080c73c..a708698bd008 100644
+ if (timeout <= 0){
+ jsResultAnalyzed = executeProxyScript(uri);
+ } else {
+ Task task = getRequestProcessor().post(() -> {
+ AtomicReference<List<Proxy>> resultHolder = new AtomicReference<>(null);
+ Task task = RP.post(() -> {
+ resultHolder.set(executeProxyScript(uri));
+ });
+
Expand All @@ -93,18 +92,18 @@ index 76bb6080c73c..a708698bd008 100644
- LOGGER.log(Level.WARNING, "Error when executing PAC script function " + scriptEngine.getJsMainFunction().getJsFunctionName() + " : ", ex);
- return Collections.singletonList(Proxy.NO_PROXY);
+ jsResultAnalyzed = resultHolder.get();
+ }
}
+ if (canUseURLCaching && (resultCache != null) && (jsResultAnalyzed != null)) {
+ resultCache.put(uri, jsResultAnalyzed); // save the result in the cache
}
+ }
+ return jsResultAnalyzed != null ? jsResultAnalyzed : Collections.singletonList(Proxy.NO_PROXY);
}
-
+
@Override
public boolean usesCaching() {
return (canUseURLCaching && (resultCache != null));
@@ -275,6 +280,32 @@ public String getPacScriptSource() {
@@ -275,6 +279,32 @@ public String getPacScriptSource() {
return this.pacScriptSource;
}

Expand Down Expand Up @@ -210,15 +209,15 @@ index 178c9b162feb..90812bfa4612 100644
testPacFile2("pac-test4.js", factory);
}
diff --git a/platform/o.n.core/src/org/netbeans/core/ProxySettings.java b/platform/o.n.core/src/org/netbeans/core/ProxySettings.java
index 2d29427cd3c2..19e48d9bad82 100644
index 2d29427cd3c2..bb0bc42ae19f 100644
--- a/platform/o.n.core/src/org/netbeans/core/ProxySettings.java
+++ b/platform/o.n.core/src/org/netbeans/core/ProxySettings.java
@@ -49,6 +49,8 @@ public class ProxySettings {
public static final String USE_PROXY_ALL_PROTOCOLS = "useProxyAllProtocols"; // NOI18N
public static final String DIRECT = "DIRECT"; // NOI18N
public static final String PAC = "PAC"; // NOI18N
+ public static final String PAC_SCRIPT_TIMEOUT = "pacScriptTimeout"; // NOI18N
+ public static final int DEFAULT_TIMEOUT = 60000;
+ public static final int DEFAULT_TIMEOUT = 10000;

public static final String SYSTEM_PROXY_HTTP_HOST = "systemProxyHttpHost"; // NOI18N
public static final String SYSTEM_PROXY_HTTP_PORT = "systemProxyHttpPort"; // NOI18N
Expand All @@ -227,7 +226,7 @@ index 2d29427cd3c2..19e48d9bad82 100644
}

+ public static int getPacScriptTimeout() {
+ return NbPreferences.forModule(ProxySettings.class)
+ return getPreferences ()
+ .getInt(PAC_SCRIPT_TIMEOUT, DEFAULT_TIMEOUT);
+ }

Expand Down
9 changes: 9 additions & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@

-->

## Version 23.1.0
### What's Changed

#### Other Changes
* Minor README updates and fixes [#334](https://github.com/oracle/javavscode/pull/334) and [#339](https://github.com/oracle/javavscode/pull/339)
* Suppressed JNI warning during language server startup [#338](https://github.com/oracle/javavscode/pull/338)
* Dependency upgrades [#337](https://github.com/oracle/javavscode/pull/337)
* Extension maintainance changes [#348](https://github.com/oracle/javavscode/pull/348) and [#349](https://github.com/oracle/javavscode/pull/349)

## Version 23.0.1
### What's Changed

Expand Down
2 changes: 1 addition & 1 deletion vscode/src/test/integration/suite/general/explorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ suite('Explorer Test Suite', () => {
const lvp = await myExplorer.createViewProvider(await awaitClient(), 'foundProjects');
const firstLevelChildren = await (lvp.getChildren() as Thenable<any[]>);
assert.strictEqual(firstLevelChildren.length, 0, "No child under the root");
}).timeout(10000);
}).timeout(60000);
});
26 changes: 13 additions & 13 deletions vscode/src/test/integration/suite/general/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ suite('Extension Test Suite', function () {
// Create project which used be used for testing
this.beforeAll(async () => {
await prepareProject(filePaths);
}).timeout(10000);
}).timeout(60000);

// This test must be run first, in order to activate the extension and wait for the activation to complete
test("Extension loaded and activated", async () => {
Expand All @@ -59,7 +59,7 @@ suite('Extension Test Suite', function () {
}
assert.ok(cannotReassignVersion, "Cannot reassign value of version");

}).timeout(10000);
}).timeout(60000);

// Test if clusters are loaded or not
test('Find clusters', async () => {
Expand Down Expand Up @@ -93,7 +93,7 @@ suite('Extension Test Suite', function () {
for (let c of found) {
assert.ok(c.startsWith(nbcode.extensionPath), `All extensions are below ${nbcode.extensionPath}, but: ${c}`);
}
}).timeout(10000);
}).timeout(60000);

// Check if Jdk commands have been loaded
test("Jdk commands loaded", async () => {
Expand All @@ -107,7 +107,7 @@ suite('Extension Test Suite', function () {
}

assert.ok(containsJdkCommands, "No Jdk command has been loaded");
}).timeout(10000);
}).timeout(60000);

// Check if format document command is executed successfully
test("Format document", async () => {
Expand All @@ -118,7 +118,7 @@ suite('Extension Test Suite', function () {
const unformattedCode = SAMPLE_CODE_FORMAT_DOCUMENT.split('\n').length;
const isDocumentFormatted = formattedCode > unformattedCode;
assert.ok(isDocumentFormatted, "document is not formatted");
}).timeout(10000);
}).timeout(60000);

// Check if imports are getting sorted on saving document
test("Sort imports", async () => {
Expand All @@ -133,7 +133,7 @@ suite('Extension Test Suite', function () {
savedCode.indexOf('import java.util.ArrayList;');
assert.ok(isImportsSorted, "Imports are not sorted");

}).timeout(10000);
}).timeout(60000);

// Check if unused imports are getting removed on saving document
test("Remove unused imports", async () => {
Expand All @@ -148,7 +148,7 @@ suite('Extension Test Suite', function () {
savedCode.indexOf('import java.lang.Integer;') === -1;
assert.ok(areUnusedImportsRemoved, "Unused imports are not removed");

}).timeout(10000);
}).timeout(60000);

// Check if refactor actions are getting showing on UI and if they are working
test("Refactor actions executing", async () => {
Expand Down Expand Up @@ -176,7 +176,7 @@ suite('Extension Test Suite', function () {
}
}
}
}).timeout(10000);
}).timeout(60000);

// Tests explorer is loading properly
test("Test Explorer tests", async () => {
Expand All @@ -203,7 +203,7 @@ suite('Extension Test Suite', function () {
dumpJava();
throw error;
}
}).timeout(10000);
}).timeout(60000);

// Check if compile workspace command is excuted succesfully
test("Compile workspace", async () => {
Expand All @@ -221,7 +221,7 @@ suite('Extension Test Suite', function () {
const item = await (lvp.getTreeItem(firstLevelChildren[0]) as Thenable<TreeItem>);
assert.strictEqual(item?.label, "basicapp", "Element is named as the Maven project");
});
}).timeout(10000);
}).timeout(60000);

// Get Project info
test("Get project sources, classpath, and packages", async () => {
Expand Down Expand Up @@ -286,7 +286,7 @@ suite('Extension Test Suite', function () {
dumpJava();
throw error;
}
}).timeout(10000);
}).timeout(60000);

// Check if clean workspace command is excuted succesfully
test("Clean workspace", async () => {
Expand All @@ -296,7 +296,7 @@ suite('Extension Test Suite', function () {

const mainClass = path.join(folder, 'target');
assert.ok(!fs.existsSync(mainClass), "Class created by compilation: " + mainClass);
}).timeout(10000);
}).timeout(60000);

// Check if xml document formatting is executed successfully
test("XML Format document", async () => {
Expand All @@ -305,6 +305,6 @@ suite('Extension Test Suite', function () {

const formattedContents = editor.document.getText().trim();
assert.ok(formattedContents == FORMATTED_POM_XML.trim(), "pom.xml is not formatted");
}).timeout(10000);
}).timeout(60000);

});
4 changes: 2 additions & 2 deletions vscode/src/test/integration/suite/gradle/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ suite("Extension gradle tests", function () {
dumpJava();
throw error;
}
}).timeout(50000);
}).timeout(120*1000);

// Check if clean workspace command is excuted succesfully
test("Clean workspace - Gradle", async () => {
Expand All @@ -71,5 +71,5 @@ suite("Extension gradle tests", function () {
!fs.existsSync(mainClass),
"Class created by compilation: " + mainClass
);
}).timeout(10000);
}).timeout(60000);
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ suite("Extension localisation tests", function () {
assert.ok(matchKeys(enBundlePath, langBundlePath), `Keys of ${DEFAULT_BUNDLE_FILE_NAME} and bundle.l10n.${lang}.json don't match`);
assert.ok(matchValuesTemplate(enBundlePath, langBundlePath), `Value templates don't match for of the keys of ${DEFAULT_BUNDLE_FILE_NAME} and bundle.l10n.${lang}.json `);
}
}).timeout(10000);
}).timeout(60000);

test("Consistency of keys across package.nls.lang.json files for supported languages", async () => {
const extension = extensions.getExtension(EXTENSION_NAME);
Expand All @@ -57,7 +57,7 @@ suite("Extension localisation tests", function () {
assert.ok(fs.existsSync(langPackagePath), `package.nls.${lang}.json doesn't exists`);
assert.ok(matchKeys(enPackagePath, langPackagePath), `Keys of ${DEFAULT_PACKAGE_FILE_NAME} and package.nls.${lang}.json don't match`);
}
}).timeout(10000);
}).timeout(60000);

// Check localisable fields being appropriately localised for the contributes defined in package.json
test("Localisable fields in package.json localised properly ", async () => {
Expand All @@ -74,7 +74,7 @@ suite("Extension localisation tests", function () {
assert.ok(checkViewsLocalisation(contributes.views, validKeys), "Error some views is not localized");
assert.ok(checkDebuggersLocalisation(contributes.debuggers, validKeys), "Error some debugger labels not localized");
assert.ok(checkConfigurationLocalisation(contributes.configuration, validKeys), "Error some configuration labels not localized");
}).timeout(10000);
}).timeout(60000);


// Check if l10n.value is called with a valid key and the placeholder map has all the keys as required in the string template
Expand All @@ -86,6 +86,6 @@ suite("Extension localisation tests", function () {
assert(enBundlePath, `${DEFAULT_BUNDLE_FILE_NAME} not found`);
const validKeyValues = JSON.parse(fs.readFileSync(enBundlePath, 'utf8'));
assert(checkL10nUsageInFiles(path.join(extension.extensionPath, "out"), ignoredDirEntriesNames, validKeyValues) === 0, "Some files have invalid localisation keys used. Check the logs or error messages");
}).timeout(10000);
}).timeout(60000);

});
Loading